c722a71487320853fbb44231d288a89be1d9076a
[akaros.git] / kern / src / manager.c
1 /*
2  * Copyright (c) 2009 The Regents of the University of California
3  * See LICENSE for details.
4  */
5
6 #ifdef __DEPUTY__
7 #pragma nodeputy
8 #endif
9
10 #include <arch/types.h>
11 #include <smp.h>
12
13 #include <assert.h>
14 #include <manager.h>
15 #include <env.h>
16 #include <workqueue.h>
17 #include <syscall.h>
18 #include <testing.h>
19
20 /*
21  * Currently, if you leave this function by way of env_run (process_workqueue
22  * that env_runs), you will never come back to where you left off, and the
23  * function will start from the top.  Hence the hack 'progress'.
24  */
25 void manager(void)
26 {
27         static uint8_t progress = 0;
28         env_t *envs[256];
29
30         switch (progress++) {
31         
32         #ifdef __i386__
33
34                 case 0:
35                         envs[0] = ENV_CREATE(parlib_channel_test_client);
36                         envs[1] = ENV_CREATE(parlib_channel_test_server);
37                         smp_call_function_single(1, run_env_handler, envs[0], 0);
38                         smp_call_function_single(2, run_env_handler, envs[1], 0);
39
40         #if 0
41                 case 0:
42                         printk("Beginning Tests\n");
43                         test_run_measurements(progress-1);  // should never return
44                         break;
45         #endif
46
47                 case 1:
48                 case 2:
49                 case 3:
50         #else
51
52                 case 0:
53                         envs[0] = ENV_CREATE(roslib_proctests);
54                         envs[1] = ENV_CREATE(roslib_proctests);
55                         envs[2] = ENV_CREATE(roslib_proctests);
56                         envs[3] = ENV_CREATE(roslib_fptest);
57                         envs[4] = ENV_CREATE(roslib_fptest);
58                         envs[4] = ENV_CREATE(roslib_fptest);
59                         envs[5] = ENV_CREATE(roslib_hello);
60                         envs[6] = ENV_CREATE(roslib_null);
61                         //envs[6] = ENV_CREATE(roslib_measurements);
62                         env_run(envs[0]);
63                         break;
64                 case 1:
65                 case 2:
66                 case 3:
67
68         #endif
69
70                 case 4:
71                 case 5:
72                 case 6:
73                 case 7:
74                 case 8:
75                 case 9:
76                 case 10:
77                 case 11:
78                 case 12:
79                 case 13:
80                 case 14:
81                         //test_run_measurements(progress-1);
82                         break;
83                 default:
84                         printk("Manager Progress: %d\n", progress);
85                         schedule();
86         }
87         panic("If you see me, then you probably screwed up");
88
89         /*
90         printk("Servicing syscalls from Core 0:\n\n");
91         while (1) {
92                 process_generic_syscalls(&envs[0], 1);
93                 cpu_relax();
94         }
95         */
96         return;
97 }
98