36be0bba6202c4b81b0f908ef2ba88db6708c35c
[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 <ros/common.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         spinlock_t lock;
23         bool preempt_pending;
24         struct workqueue TP(void*) workqueue;
25 #ifdef __i386__
26         spinlock_t amsg_lock;
27         unsigned amsg_current;
28         active_message_t active_msgs[NUM_ACTIVE_MESSAGES];
29 #endif
30 };
31 extern struct per_cpu_info per_cpu_info[MAX_NUM_CPUS];
32 extern volatile uint8_t num_cpus;
33
34 /* SMP bootup functions */
35 void smp_boot(void);
36 void smp_idle(void);
37
38 /* SMP utility functions */
39 int smp_call_function_self(poly_isr_t handler, TV(t) data,
40                            handler_wrapper_t** wait_wrapper);
41 int smp_call_function_all(poly_isr_t handler, TV(t) data,
42                           handler_wrapper_t** wait_wrapper);
43 int smp_call_function_single(uint32_t dest, poly_isr_t handler, TV(t) data,
44                              handler_wrapper_t** wait_wrapper);
45 int smp_call_wait(handler_wrapper_t*SAFE wrapper);
46
47 #endif /* !ROS_INC_SMP_H */