int smp_call_wait(handler_wrapper_t* wrapper) { int i; for(i = 0; i < num_cores(); i++) while(wrapper->wait_list[i]); spin_unlock(&wrapper->lock); return 0; }
int smp_call_function_all(isr_t handler, void* data, handler_wrapper_t** wait_wrapper) { int8_t state = 0; int i; handler_wrapper_t* wrapper = 0; if(wait_wrapper) { wrapper = *wait_wrapper = smp_make_wrapper(); if(!wrapper) return -ENOMEM; for(i = 0; i < num_cores(); i++) wrapper->wait_list[i] = 1; } enable_irqsave(&state); // send to others for(i = 0; i < num_cores(); i++) { if(i == core_id()) continue; send_kernel_message(i,(amr_t)smp_call_wrapper, handler, wrapper, data, KMSG_IMMEDIATE); } // send to me send_kernel_message(core_id(),(amr_t)smp_call_wrapper, handler,wrapper,data, KMSG_IMMEDIATE); cpu_relax(); // wait to get the interrupt disable_irqsave(&state); return 0; }
void smp_boot(void) { extern int time_for_smp_init; num_cpus = 1; printd("Cores, report in!\n"); time_for_smp_init = 1; smp_percpu_init(); while(*(volatile uint32_t*)&num_cpus < num_cores()); printd("%d cores reporting!\n",num_cpus); }
int su_num_cores(su_state *s) { return num_cores(); }