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