Bare support for dispatching parallel processes
[akaros.git] / kern / include / smp.h
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 #ifndef ROS_INC_SMP_H
8 #define ROS_INC_SMP_H
9
10 /* SMP related functions */
11
12 #include <arch/smp.h>
13 #include <arch/types.h>
14 #include <trap.h>
15 #include <atomic.h>
16 #include <process.h>
17 #include <workqueue.h>
18 #include <env.h>
19
20 // will want this padded out to cacheline alignment
21 struct per_cpu_info {
22         uint32_t lock;
23         bool preempt_pending;
24         /* a proc_startcore IPI will run these.  replace with a dispatch map? */
25         struct proc *p_to_run;
26         trapframe_t *SAFE tf_to_pop;
27         struct workqueue workqueue;
28 };
29 extern struct per_cpu_info per_cpu_info[MAX_NUM_CPUS];
30 extern volatile uint8_t num_cpus;
31
32 /* SMP bootup functions */
33 void smp_boot(void);
34 void smp_idle(void);
35
36 /* SMP utility functions */
37 int smp_call_function_self(poly_isr_t handler, TV(t) data,
38                            handler_wrapper_t** wait_wrapper);
39 int smp_call_function_all(poly_isr_t handler, TV(t) data,
40                           handler_wrapper_t** wait_wrapper);
41 int smp_call_function_single(uint8_t dest, poly_isr_t handler, TV(t) data,
42                              handler_wrapper_t** wait_wrapper);
43 int smp_call_wait(handler_wrapper_t*SAFE wrapper);
44
45 #endif /* !ROS_INC_SMP_H */