2 * Copyright (c) 2009 The Regents of the University of California
3 * Barret Rhoden <brho@cs.berkeley.edu>
4 * See LICENSE for details.
11 #include <ros/common.h>
13 #include <arch/init.h>
19 #include <workqueue.h>
27 #include <colored_caches.h>
31 * Currently, if you leave this function by way of proc_run (process_workqueue
32 * that proc_runs), you will never come back to where you left off, and the
33 * function will start from the top. Hence the hack 'progress'.
37 #ifndef DEVELOPER_NAME
38 #define DEVELOPER_NAME brho
42 #define PASTE(s1,s2) s1 ## s2
43 #define MANAGER_FUNC(dev) PASTE(manager_,dev)
45 void MANAGER_FUNC(DEVELOPER_NAME)(void);
46 MANAGER_FUNC(DEVELOPER_NAME)();
49 void manager_brho(void)
51 static uint8_t RACY progress = 0;
53 static struct proc *envs[256];
54 static struct proc *p ;
56 // for testing taking cores, check in case 1 for usage
57 uint32_t corelist[MAX_NUM_CPUS];
62 // TODO: need to store the pid for future manager runs, not the *p
63 p = kfs_proc_create(kfs_lookup_path("parlib_mhello"));
64 //p = kfs_proc_create(kfs_lookup_path("roslib_mhello"));
65 //p = kfs_proc_create(kfs_lookup_path("roslib_mproctests"));
66 //p = kfs_proc_create(kfs_lookup_path("roslib_spawn"));
67 // being proper and all:
68 spin_lock_irqsave(&p->proc_lock);
69 __proc_set_state(p, PROC_RUNNABLE_S);
70 // normal single-cored way
71 spin_unlock_irqsave(&p->proc_lock);
75 // this is how you can transition to a parallel process manually
76 // make sure you don't proc run first
77 __proc_set_state(p, PROC_RUNNING_S);
78 __proc_set_state(p, PROC_RUNNABLE_M);
79 p->resources[RES_CORES].amt_wanted = 5;
80 spin_unlock_irqsave(&p->proc_lock);
82 panic("This is okay");
89 // this is a ghetto way to test restarting an _M
90 printk("\nattempting to ghetto preempt...\n");
91 spin_lock_irqsave(&p->proc_lock);
92 proc_take_allcores(p, __death);
93 __proc_set_state(p, PROC_RUNNABLE_M);
94 spin_unlock_irqsave(&p->proc_lock);
96 printk("\nattempting to restart...\n");
97 core_request(p); // proc still wants the cores
98 panic("This is okay");
99 // this tests taking some cores, and later killing an _M
100 printk("taking 3 cores from p\n");
101 for (int i = 0; i < num; i++)
102 corelist[i] = 7-i; // 7, 6, and 5
103 spin_lock_irqsave(&p->proc_lock);
104 proc_take_cores(p, corelist, &num, __death);
105 spin_unlock_irqsave(&p->proc_lock);
107 printk("Killing p\n");
109 printk("Killed p\n");
110 panic("This is okay");
112 envs[0] = kfs_proc_create(kfs_lookup_path("roslib_hello"));
113 __proc_set_state(envs[0], PROC_RUNNABLE_S);
119 panic("Do not panic");
120 envs[0] = kfs_proc_create(kfs_lookup_path("parlib_channel_test_client"));
121 envs[1] = kfs_proc_create(kfs_lookup_path("parlib_channel_test_server"));
122 smp_call_function_single(1, run_env_handler, envs[0], 0);
123 smp_call_function_single(2, run_env_handler, envs[1], 0);
129 printk("Beginning Tests\n");
130 test_run_measurements(progress-1); // should never return
133 envs[0] = kfs_proc_create(kfs_lookup_path("parlib_channel_test_client"));
134 envs[1] = kfs_proc_create(kfs_lookup_path("parlib_channel_test_server"));
135 smp_call_function_single(1, run_env_handler, envs[0], 0);
136 smp_call_function_single(2, run_env_handler, envs[1], 0);
141 test_smp_call_functions();
145 test_lapic_status_bit();
159 //test_run_measurements(progress-1);
161 printk("Manager Progress: %d\n", progress);
162 // delay if you want to test rescheduling an MCP that yielded
166 panic("If you see me, then you probably screwed up");
169 printk("Servicing syscalls from Core 0:\n\n");
171 process_generic_syscalls(&envs[0], 1);
178 void manager_klueska()
180 static struct proc *envs[256];
181 static volatile uint8_t progress = 0;
185 envs[0] = kfs_proc_create(kfs_lookup_path("parlib_matrix"));
186 __proc_set_state(envs[0], PROC_RUNNABLE_S);
191 panic("DON'T PANIC");
194 void manager_waterman()
199 void manager_pearce()
208 itoa(int num, char* buf0, size_t base)
223 buf[len++] = "0123456789abcdef"[num%base];
227 for(i = 0; i < len/2; i++)
230 buf[i] = buf[len-i-1];
238 void gsf_set_frame_cycles(int cycles)
240 store_alternate(26*4,2,cycles);
243 void gsf_set_partition_credits(int partition, int credits)
245 store_alternate((32+partition)*4,2,credits);
248 void gsf_set_core_partition(int core, int partition)
250 store_alternate((64+core)*4,2,partition);