Changeset View
Changeset View
Standalone View
Standalone View
head/sys/riscv/riscv/mp_machdep.c
Show First 20 Lines • Show All 221 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
struct pcpu *pcpup; | struct pcpu *pcpup; | ||||
/* Setup the pcpu pointer */ | /* Setup the pcpu pointer */ | ||||
pcpup = &__pcpu[cpu]; | pcpup = &__pcpu[cpu]; | ||||
__asm __volatile("mv gp, %0" :: "r"(pcpup)); | __asm __volatile("mv gp, %0" :: "r"(pcpup)); | ||||
/* Workaround: make sure wfi doesn't halt the hart */ | /* Workaround: make sure wfi doesn't halt the hart */ | ||||
intr_disable(); | |||||
csr_set(sie, SIE_SSIE); | csr_set(sie, SIE_SSIE); | ||||
csr_set(sip, SIE_SSIE); | csr_set(sip, SIE_SSIE); | ||||
/* Spin until the BSP releases the APs */ | /* Spin until the BSP releases the APs */ | ||||
while (!aps_ready) | while (!aps_ready) | ||||
__asm __volatile("wfi"); | __asm __volatile("wfi"); | ||||
/* Initialize curthread */ | /* Initialize curthread */ | ||||
KASSERT(PCPU_GET(idlethread) != NULL, ("no idle thread")); | KASSERT(PCPU_GET(idlethread) != NULL, ("no idle thread")); | ||||
pcpup->pc_curthread = pcpup->pc_idlethread; | pcpup->pc_curthread = pcpup->pc_idlethread; | ||||
pcpup->pc_curpcb = pcpup->pc_idlethread->td_pcb; | pcpup->pc_curpcb = pcpup->pc_idlethread->td_pcb; | ||||
/* | /* | ||||
* Identify current CPU. This is necessary to setup | * Identify current CPU. This is necessary to setup | ||||
* affinity registers and to provide support for | * affinity registers and to provide support for | ||||
* runtime chip identification. | * runtime chip identification. | ||||
*/ | */ | ||||
identify_cpu(); | identify_cpu(); | ||||
/* Enable software interrupts */ | /* Enable software interrupts */ | ||||
riscv_unmask_ipi(); | riscv_unmask_ipi(); | ||||
/* Start per-CPU event timers. */ | /* Start per-CPU event timers. */ | ||||
cpu_initclocks_ap(); | cpu_initclocks_ap(); | ||||
/* Enable interrupts */ | |||||
intr_enable(); | |||||
/* Enable external (PLIC) interrupts */ | /* Enable external (PLIC) interrupts */ | ||||
csr_set(sie, SIE_SEIE); | csr_set(sie, SIE_SEIE); | ||||
mtx_lock_spin(&ap_boot_mtx); | mtx_lock_spin(&ap_boot_mtx); | ||||
atomic_add_rel_32(&smp_cpus, 1); | atomic_add_rel_32(&smp_cpus, 1); | ||||
▲ Show 20 Lines • Show All 195 Lines • Show Last 20 Lines |