Fixed up ivy annotations on the new structure supporting page_coloring.
[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 #include <arch/types.h>
8 #include <smp.h>
9
10 #include <assert.h>
11 #include <manager.h>
12 #include <process.h>
13 #include <schedule.h>
14 #include <workqueue.h>
15 #include <syscall.h>
16 #include <testing.h>
17 #include <kfs.h>
18 #include <stdio.h>
19
20 /*
21  * Currently, if you leave this function by way of proc_run (process_workqueue
22  * that proc_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                 case 0:
32                         envs[0] = kfs_proc_create(kfs_lookup_path("roslib_hello"));
33                         proc_set_state(envs[0], PROC_RUNNABLE_S);
34                         proc_run(envs[0]);
35                         break;
36         #ifdef __i386__
37                 case 1:
38                         panic("Do not panic");
39                         envs[0] = kfs_proc_create(kfs_lookup_path("parlib_channel_test_client"));
40                         envs[1] = kfs_proc_create(kfs_lookup_path("parlib_channel_test_server"));
41                         smp_call_function_single(1, run_env_handler, envs[0], 0);
42                         smp_call_function_single(2, run_env_handler, envs[1], 0);
43                         break;
44                 case 2:
45                 case 3:
46         #else // sparc
47                 case 1:
48                         panic("Do not panic");
49                         envs[0] = kfs_proc_create(kfs_lookup_path("roslib_proctests"));
50                         envs[1] = kfs_proc_create(kfs_lookup_path("roslib_proctests"));
51                         envs[2] = kfs_proc_create(kfs_lookup_path("roslib_proctests"));
52                         envs[3] = kfs_proc_create(kfs_lookup_path("roslib_fptest"));
53                         envs[4] = kfs_proc_create(kfs_lookup_path("roslib_fptest"));
54                         envs[4] = kfs_proc_create(kfs_lookup_path("roslib_fptest"));
55                         envs[5] = kfs_proc_create(kfs_lookup_path("roslib_hello"));
56                         envs[6] = kfs_proc_create(kfs_lookup_path("roslib_null"));
57                         proc_run(envs[0]);
58                         break;
59                 case 2:
60                         #if 0
61                         // reminder of how to spawn remotely
62                         for (int i = 0; i < 8; i++) {
63                                 envs[i] = kfs_proc_create(kfs_lookup_path("roslib_hello"));
64                                 proc_set_state(envs[i], PROC_RUNNABLE_S);
65                                 smp_call_function_single(i, run_env_handler, envs[i], 0);
66                         }
67                         process_workqueue();
68                         #endif
69                 case 3:
70         #endif
71
72                 #if 0
73                 case 4:
74                         printk("Beginning Tests\n");
75                         test_run_measurements(progress-1);  // should never return
76                         break;
77                 case 5:
78                         envs[0] = kfs_proc_create(kfs_lookup_path("parlib_channel_test_client"));
79                         envs[1] = kfs_proc_create(kfs_lookup_path("parlib_channel_test_server"));
80                         smp_call_function_single(1, run_env_handler, envs[0], 0);
81                         smp_call_function_single(2, run_env_handler, envs[1], 0);
82                 case 6:
83                 #endif
84                 case 4:
85                         /*
86                         test_smp_call_functions();
87                         test_checklists();
88                         test_barrier();
89                         test_print_info();
90                         test_lapic_status_bit();
91                         test_ipi_sending();
92                         test_pit();
93                         */
94                 case 5:
95                 case 6:
96                 case 7:
97                 case 8:
98                 case 9:
99                 case 10:
100                 case 11:
101                 case 12:
102                 case 13:
103                 case 14:
104                         //test_run_measurements(progress-1);
105                 default:
106                         printk("Manager Progress: %d\n", progress);
107                         schedule();
108         }
109         panic("If you see me, then you probably screwed up");
110
111         /*
112         printk("Servicing syscalls from Core 0:\n\n");
113         while (1) {
114                 process_generic_syscalls(&envs[0], 1);
115                 cpu_relax();
116         }
117         */
118         return;
119 }
120