Active messages using dynamically allocated memory
[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 <sys/queue.h>
15 #include <trap.h>
16 #include <atomic.h>
17 #include <process.h>
18 #include <workqueue.h>
19 #include <env.h>
20
21 #ifdef __SHARC__
22 typedef sharC_env_t;
23 #endif
24 // will want this padded out to cacheline alignment
25 struct per_cpu_info {
26         spinlock_t lock;
27         bool preempt_pending;
28         struct workqueue NTPTV(t) workqueue;
29
30 #ifdef __SHARC__
31         // held spin-locks. this will have to go elsewhere if multiple kernel
32         // threads can share a CPU.
33         // zra: Used by Ivy. Let me know if this should go elsewhere.
34         sharC_env_t sharC_env;
35 #endif
36
37         spinlock_t amsg_lock;
38         struct active_msg_list active_msgs;
39 };
40
41 typedef struct per_cpu_info NTPTV(t) NTPTV(a0t) NTPTV(a1t) NTPTV(a2t) per_cpu_info_t;
42
43 extern per_cpu_info_t (RO per_cpu_info)[MAX_NUM_CPUS];
44 extern volatile uint8_t RO num_cpus;
45
46 /* SMP bootup functions */
47 void smp_boot(void);
48 void smp_idle(void);
49
50 /* SMP utility functions */
51 int smp_call_function_self(poly_isr_t handler, TV(t) data,
52                            handler_wrapper_t** wait_wrapper);
53 int smp_call_function_all(poly_isr_t handler, TV(t) data,
54                           handler_wrapper_t** wait_wrapper);
55 int smp_call_function_single(uint32_t dest, poly_isr_t handler, TV(t) data,
56                              handler_wrapper_t** wait_wrapper);
57 int smp_call_wait(handler_wrapper_t*SAFE wrapper);
58
59 #endif /* !ROS_INC_SMP_H */