Arch independent per-cpu initialization
[akaros.git] / kern / arch / sparc / smp.c
index bd13f22..b00ac84 100644 (file)
@@ -3,7 +3,7 @@
 #include <arch/smp.h>
 #include <stdio.h>
 #include <string.h>
-#include <ros/error.h>
+#include <error.h>
 #include <assert.h>
 #include <atomic.h>
 
@@ -20,30 +20,33 @@ smp_boot(void)
 {
        extern int time_for_smp_init;
        num_cpus = 1;
-       cprintf("Cores, report in!\n");
+       printd("Cores, report in!\n");
        time_for_smp_init = 1;
 
-       while(*(volatile uint8_t*)&num_cpus < num_cores());
+       smp_percpu_init();
 
-       cprintf("All cores reporting!\n");
+       while(*(volatile uint32_t*)&num_cpus < num_cores());
+
+       printd("%d cores reporting!\n",num_cpus);
 }
 
 void
 smp_init(void)
 {
-       static spinlock_t report_in_lock = 0;
-
-       cprintf("Good morning, Vietnam! (core id = %d)\n",core_id());
+       static spinlock_t report_in_lock = SPINLOCK_INITIALIZER;
 
+       smp_percpu_init();
        spin_lock(&report_in_lock);
        num_cpus++;
        spin_unlock(&report_in_lock);
 
+       printd("Good morning, Vietnam! (core id = %d)\n",core_id());
+
        smp_idle();
 }
 
 handler_wrapper_t
-wrapper_pool[MAX_NUM_CPUS*8] = {{{0},0}};
+wrapper_pool[MAX_NUM_CPUS*8] = {{{0},SPINLOCK_INITIALIZER}};
 
 handler_wrapper_t*
 smp_make_wrapper()
@@ -94,13 +97,13 @@ int smp_call_function_all(isr_t handler, void* data,
                if(i == core_id())
                        continue;
 
-               while(send_active_message(i,(amr_t)smp_call_wrapper,
-                                         handler, wrapper, data) != 0);
+               send_kernel_message(i,(amr_t)smp_call_wrapper,
+                                         handler, wrapper, data, KMSG_IMMEDIATE);
        }
 
        // send to me
-       while(send_active_message(core_id(),(amr_t)smp_call_wrapper,
-                                 handler,wrapper,data) != 0);
+       send_kernel_message(core_id(),(amr_t)smp_call_wrapper,
+                                 handler,wrapper,data, KMSG_IMMEDIATE);
 
        cpu_relax(); // wait to get the interrupt
 
@@ -124,8 +127,8 @@ int smp_call_function_single(uint32_t dest, isr_t handler, void* data,
 
        enable_irqsave(&state);
 
-       while(send_active_message(dest,(amr_t)smp_call_wrapper,
-                                 handler,wrapper,data) != 0);
+       send_kernel_message(dest,(amr_t)smp_call_wrapper,
+                                 handler,wrapper,data, KMSG_IMMEDIATE);
 
        cpu_relax(); // wait to get the interrupt, if it's to this core
 
@@ -147,9 +150,6 @@ int smp_call_wait(handler_wrapper_t* wrapper)
 /* Perform any initialization needed by per_cpu_info.  Right now, this just
  * inits the amsg list (which sparc will probably also want).  Make sure every
  * core calls this at some point in the smp_boot process. */
-void smp_percpu_init(void)
+void __arch_pcpu_init(uint32_t coreid)
 {
-       static_assert(0);
-       uint32_t coreid = core_id();
-       STAILQ_INIT(&per_cpu_info[coreid].active_msgs);
 }