Get things to build with Ivy.
[akaros.git] / kern / include / smp.h
index 77909b4..1114feb 100644 (file)
 /* SMP related functions */
 
 #include <arch/smp.h>
-#include <arch/types.h>
+#include <ros/common.h>
+#include <sys/queue.h>
 #include <trap.h>
 #include <atomic.h>
+#include <process.h>
 #include <workqueue.h>
+#include <env.h>
 
-// be careful changing this, esp if you go over 16
-#define NUM_HANDLER_WRAPPERS           5
+#ifdef __SHARC__
+typedef sharC_env_t;
+#endif
 
-typedef struct HandlerWrapper {
-       checklist_t* cpu_list;
-       uint8_t vector;
-} handler_wrapper_t;
-
-// will want this padded out to cacheline alignment
 struct per_cpu_info {
-       uint32_t lock;
-       struct workqueue workqueue;
-};
-extern struct per_cpu_info  per_cpu_info[MAX_NUM_CPUS];
-extern volatile uint8_t num_cpus;
+       spinlock_t lock;
+       bool preempt_pending;
+       struct workqueue NTPTV(t) workqueue;
+
+#ifdef __SHARC__
+       // held spin-locks. this will have to go elsewhere if multiple kernel
+       // threads can share a CPU.
+       // zra: Used by Ivy. Let me know if this should go elsewhere.
+       sharC_env_t sharC_env;
+#endif
+
+       spinlock_t amsg_lock;
+       struct active_msg_list NTPTV(a0t) NTPTV(a1t) NTPTV(a2t) active_msgs;
+}__attribute__((aligned(HW_CACHE_ALIGN)));
+
+typedef struct per_cpu_info NTPTV(t) NTPTV(a0t) NTPTV(a1t) NTPTV(a2t) per_cpu_info_t;
+
+extern per_cpu_info_t (RO per_cpu_info)[MAX_NUM_CPUS];
+extern volatile uint8_t RO num_cpus;
 
 /* SMP bootup functions */
 void smp_boot(void);
 void smp_idle(void);
+void smp_percpu_init(void); // this must be called by each core individually
 
 /* SMP utility functions */
-int smp_call_function_self(isr_t handler, void* data,
+int smp_call_function_self(poly_isr_t handler, TV(t) data,
                            handler_wrapper_t** wait_wrapper);
-int smp_call_function_all(isr_t handler, void* data,
+int smp_call_function_all(poly_isr_t handler, TV(t) data,
                           handler_wrapper_t** wait_wrapper);
-int smp_call_function_single(uint8_t dest, isr_t handler, void* data,
+int smp_call_function_single(uint32_t dest, poly_isr_t handler, TV(t) data,
                              handler_wrapper_t** wait_wrapper);
 int smp_call_wait(handler_wrapper_t*SAFE wrapper);