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