All local system calls are asynchronous (XCC)
[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 <syscall.h>
19
20 #ifdef __SHARC__
21 typedef sharC_env_t;
22 #endif
23
24 struct per_cpu_info {
25         spinlock_t lock;
26         /* Process management */
27         // cur_proc should be valid on all cores that are not management cores.
28         struct proc *cur_proc;
29         trapframe_t *cur_tf;
30         struct kthread *spare;          /* useful when restarting */
31         /* Syscall management */
32         struct syscall *syscalls;       /* ptr is into cur_proc's address space */
33         unsigned int nr_calls;
34         int *errno_loc;
35         uintreg_t *tf_retval_loc;
36
37 #ifdef __SHARC__
38         // held spin-locks. this will have to go elsewhere if multiple kernel
39         // threads can share a CPU.
40         // zra: Used by Ivy. Let me know if this should go elsewhere.
41         sharC_env_t sharC_env;
42 #endif
43 #ifdef __i386__
44         taskstate_t *tss;
45         segdesc_t *gdt;
46 #endif
47         /* KMSGs */
48         spinlock_t immed_amsg_lock;
49         struct kernel_msg_list NTPTV(a0t) NTPTV(a1t) NTPTV(a2t) immed_amsgs;
50         spinlock_t routine_amsg_lock;
51         struct kernel_msg_list NTPTV(a0t) NTPTV(a1t) NTPTV(a2t) routine_amsgs;
52 }__attribute__((aligned(HW_CACHE_ALIGN)));
53
54 typedef struct per_cpu_info NTPTV(t) NTPTV(a0t) NTPTV(a1t) NTPTV(a2t) per_cpu_info_t;
55
56 extern per_cpu_info_t (RO per_cpu_info)[MAX_NUM_CPUS];
57 extern volatile uint32_t RO num_cpus;
58
59 /* SMP bootup functions */
60 void smp_boot(void);
61 void smp_idle(void) __attribute__((noreturn));
62 void smp_percpu_init(void); // this must be called by each core individually
63
64 /* SMP utility functions */
65 int smp_call_function_self(poly_isr_t handler, TV(t) data,
66                            handler_wrapper_t** wait_wrapper);
67 int smp_call_function_all(poly_isr_t handler, TV(t) data,
68                           handler_wrapper_t** wait_wrapper);
69 int smp_call_function_single(uint32_t dest, poly_isr_t handler, TV(t) data,
70                              handler_wrapper_t** wait_wrapper);
71 int smp_call_wait(handler_wrapper_t*SAFE wrapper);
72
73 #endif /* !ROS_INC_SMP_H */