Merge branch 'master' into net-dev
[akaros.git] / kern / include / smp.h
1 #ifndef ROS_INC_SMP_H
2 #define ROS_INC_SMP_H
3
4 /* SMP related functions */
5
6 #include <arch/smp.h>
7 #include <arch/types.h>
8 #include <trap.h>
9 #include <atomic.h>
10 #include <workqueue.h>
11
12 #ifdef __BOCHS__
13 #define SMP_CALL_FUNCTION_TIMEOUT    0x00ffffff
14 #define SMP_BOOT_TIMEOUT             0x0000ffff
15 #else
16 #define SMP_CALL_FUNCTION_TIMEOUT    0x7ffffff0
17 #define SMP_BOOT_TIMEOUT             0x002fffff
18 #endif
19
20 typedef struct per_cpu_info {
21         uint32_t lock;
22         // Once we have a real kmalloc, we can make this dynamic.  Want a queue.
23         work_t delayed_work;
24         // will want it padded out to an even cacheline
25 } per_cpu_info_t;
26
27 extern per_cpu_info_t per_cpu_info[MAX_NUM_CPUS];
28 extern volatile uint8_t num_cpus;
29
30 /* SMP bootup functions */
31 void smp_boot(void);
32 void smp_idle(void);
33
34 /* SMP utility functions */
35 int smp_call_function_self(isr_t handler, void* data,
36                            handler_wrapper_t** wait_wrapper);
37 int smp_call_function_all(isr_t handler, void* data,
38                           handler_wrapper_t** wait_wrapper);
39 int smp_call_function_single(uint8_t dest, isr_t handler, void* data,
40                              handler_wrapper_t** wait_wrapper);
41 int smp_call_wait(handler_wrapper_t*SAFE wrapper);
42
43 #endif /* !ROS_INC_SMP_H */