Reworked the user VM map and added sysevent queue
[akaros.git] / kern / src / manager.c
1 /*
2  * Copyright (c) 2009 The Regents of the University of California
3  * Barret Rhoden <brho@cs.berkeley.edu>
4  * See LICENSE for details.
5  */
6
7 #ifdef __DEPUTY__
8 #pragma nodeputy
9 #endif
10
11 #include <arch/types.h>
12 #include <smp.h>
13
14 #include <assert.h>
15 #include <manager.h>
16 #include <process.h>
17 #include <workqueue.h>
18 #include <syscall.h>
19 #include <testing.h>
20 #include <kfs.h>
21 #include <stdio.h>
22
23 /*
24  * Currently, if you leave this function by way of env_run (process_workqueue
25  * that env_runs), you will never come back to where you left off, and the
26  * function will start from the top.  Hence the hack 'progress'.
27  */
28 void manager(void)
29 {
30         static uint8_t progress = 0;
31         env_t *envs[256];
32
33         switch (progress++) {
34                 case 0:
35                         envs[0] = kfs_proc_create(kfs_lookup_path("roslib_hello"));
36                         proc_set_state(envs[0], PROC_RUNNABLE_S);
37                         env_run(envs[0]);
38                         break;
39         #ifdef __i386__
40                 case 1:
41                         panic("Do not panic");
42                         envs[0] = ENV_CREATE(parlib_channel_test_client);
43                         envs[1] = ENV_CREATE(parlib_channel_test_server);
44                         smp_call_function_single(1, run_env_handler, envs[0], 0);
45                         smp_call_function_single(2, run_env_handler, envs[1], 0);
46                         break;
47                 case 2:
48                 case 3:
49         #else // sparc
50                 case 1:
51                         panic("Do not panic");
52                         envs[0] = ENV_CREATE(roslib_proctests);
53                         envs[1] = ENV_CREATE(roslib_proctests);
54                         envs[2] = ENV_CREATE(roslib_proctests);
55                         envs[3] = ENV_CREATE(roslib_fptest);
56                         envs[4] = ENV_CREATE(roslib_fptest);
57                         envs[4] = ENV_CREATE(roslib_fptest);
58                         envs[5] = ENV_CREATE(roslib_hello);
59                         envs[6] = ENV_CREATE(roslib_null);
60                         env_run(envs[0]);
61                         break;
62                 case 2:
63                         #if 0
64                         // reminder of how to spawn remotely
65                         for (int i = 0; i < 8; i++) {
66                                 envs[i] = kfs_proc_create(kfs_lookup_path("roslib_hello"));
67                                 proc_set_state(envs[i], PROC_RUNNABLE_S);
68                                 smp_call_function_single(i, run_env_handler, envs[i], 0);
69                         }
70                         process_workqueue();
71                         #endif
72                 case 3:
73         #endif
74
75                 #if 0
76                 case 4:
77                         printk("Beginning Tests\n");
78                         test_run_measurements(progress-1);  // should never return
79                         break;
80                 case 5:
81                         envs[0] = ENV_CREATE(parlib_channel_test_client);
82                         envs[1] = ENV_CREATE(parlib_channel_test_server);
83                         smp_call_function_single(1, run_env_handler, envs[0], 0);
84                         smp_call_function_single(2, run_env_handler, envs[1], 0);
85                 case 6:
86                 #endif
87                 case 4:
88                         /*
89                         test_smp_call_functions();
90                         test_checklists();
91                         test_barrier();
92                         test_print_info();
93                         test_lapic_status_bit();
94                         test_ipi_sending();
95                         test_pit();
96                         */
97                 case 5:
98                 case 6:
99                 case 7:
100                 case 8:
101                 case 9:
102                 case 10:
103                 case 11:
104                 case 12:
105                 case 13:
106                 case 14:
107                         //test_run_measurements(progress-1);
108                 default:
109                         printk("Manager Progress: %d\n", progress);
110                         schedule();
111         }
112         panic("If you see me, then you probably screwed up");
113
114         /*
115         printk("Servicing syscalls from Core 0:\n\n");
116         while (1) {
117                 process_generic_syscalls(&envs[0], 1);
118                 cpu_relax();
119         }
120         */
121         return;
122 }
123