diff --git a/sys/riscv/riscv/locore.S b/sys/riscv/riscv/locore.S index fb39402267e3..4b2e6ad6eed0 100644 --- a/sys/riscv/riscv/locore.S +++ b/sys/riscv/riscv/locore.S @@ -263,6 +263,21 @@ END(mpentry) * Called by a core when it is being brought online. */ ENTRY(mpentry) + /* + * Calculate the offset to __riscv_boot_ap + * for the current core, cpuid is in a0. + */ + li t1, 4 + mulw t1, t1, a0 + /* Get the pointer */ + la t0, __riscv_boot_ap + add t0, t0, t1 + +1: + /* Wait the kernel to be ready */ + lw t1, 0(t0) + beqz t1, 1b + /* Setup stack pointer */ la t0, secondary_stacks li t1, (PAGE_SIZE * KSTACK_PAGES) @@ -296,20 +311,6 @@ mpva: /* Ensure sscratch is zero */ li t0, 0 csrw sscratch, t0 - /* - * Calculate the offset to __riscv_boot_ap - * for current core, cpuid in a0. - */ - li t1, 4 - mulw t1, t1, a0 - /* Get pointer */ - la t0, __riscv_boot_ap - add t0, t0, t1 - -1: - /* Wait the kernel to be ready */ - lw t1, 0(t0) - beqz t1, 1b call init_secondary END(mpentry)