Split atomic library
[akaros.git] / include / arch / smp.h
1 #ifndef ROS_INC_SMP_H
2 #define ROS_INC_SMP_H
3
4 /* SMP related functions */
5
6 #include <arch/types.h>
7
8 #include <ros/queue.h>
9
10 #include <atomic.h>
11 #include <trap.h>
12 #include <workqueue.h>
13
14 #ifdef __BOCHS__
15 #define SMP_CALL_FUNCTION_TIMEOUT    0x00ffffff
16 #define SMP_BOOT_TIMEOUT             0x0000ffff
17 #else
18 #define SMP_CALL_FUNCTION_TIMEOUT    0x7ffffff0
19 #define SMP_BOOT_TIMEOUT             0x002fffff
20 #endif
21
22 // be careful changing this, esp if you go over 16
23 #define NUM_HANDLER_WRAPPERS            5
24
25 typedef struct HandlerWrapper {
26         checklist_t* cpu_list;
27         uint8_t vector;
28 } handler_wrapper_t;
29
30 typedef struct per_cpu_info {
31         uint32_t lock;
32         // Once we have a real kmalloc, we can make this dynamic.  Want a queue.
33         work_t delayed_work;
34         // will want it padded out to an even cacheline
35 } per_cpu_info_t;
36 extern per_cpu_info_t per_cpu_info[MAX_NUM_CPUS];
37 extern volatile uint8_t num_cpus;
38
39 /* SMP bootup functions */
40 void smp_boot(void);
41 void smp_idle(void);
42
43 /* SMP utility functions */
44 int smp_call_function_self(isr_t handler, void* data,
45                            handler_wrapper_t** wait_wrapper);
46 int smp_call_function_all(isr_t handler, void* data,
47                           handler_wrapper_t** wait_wrapper);
48 int smp_call_function_single(uint8_t dest, isr_t handler, void* data,
49                              handler_wrapper_t** wait_wrapper);
50 int smp_call_wait(handler_wrapper_t* wrapper);
51
52 #endif /* !ROS_INC_SMP_H */