Changeset View
Changeset View
Standalone View
Standalone View
head/sys/riscv/riscv/locore.S
Show First 20 Lines • Show All 281 Lines • ▼ Show 20 Lines | |||||
ENTRY(mpentry) | ENTRY(mpentry) | ||||
/* | /* | ||||
* Calculate the offset to __riscv_boot_ap | * Calculate the offset to __riscv_boot_ap | ||||
* for the current core, cpuid is in a0. | * for the current core, cpuid is in a0. | ||||
*/ | */ | ||||
li t1, 4 | li t1, 4 | ||||
mulw t1, t1, a0 | mulw t1, t1, a0 | ||||
/* Get the pointer */ | /* Get the pointer */ | ||||
la t0, __riscv_boot_ap | lla t0, __riscv_boot_ap | ||||
add t0, t0, t1 | add t0, t0, t1 | ||||
1: | 1: | ||||
/* Wait the kernel to be ready */ | /* Wait the kernel to be ready */ | ||||
lw t1, 0(t0) | lw t1, 0(t0) | ||||
beqz t1, 1b | beqz t1, 1b | ||||
/* Setup stack pointer */ | /* Setup stack pointer */ | ||||
la t0, secondary_stacks | lla t0, secondary_stacks | ||||
li t1, (PAGE_SIZE * KSTACK_PAGES) | li t1, (PAGE_SIZE * KSTACK_PAGES) | ||||
mulw t2, t1, a0 | mulw t2, t1, a0 | ||||
add t0, t0, t2 | add t0, t0, t2 | ||||
add t0, t0, t1 | add t0, t0, t1 | ||||
sub t0, t0, s9 | sub t0, t0, s9 | ||||
li t1, KERNBASE | li t1, KERNBASE | ||||
add sp, t0, t1 | add sp, t0, t1 | ||||
/* Setup supervisor trap vector */ | /* Setup supervisor trap vector */ | ||||
la t0, mpva | lla t0, mpva | ||||
sub t0, t0, s9 | sub t0, t0, s9 | ||||
li t1, KERNBASE | li t1, KERNBASE | ||||
add t0, t0, t1 | add t0, t0, t1 | ||||
csrw stvec, t0 | csrw stvec, t0 | ||||
/* Set page tables base register */ | /* Set page tables base register */ | ||||
la s2, pagetable_l1 | lla s2, pagetable_l1 | ||||
srli s2, s2, PAGE_SHIFT | srli s2, s2, PAGE_SHIFT | ||||
li t0, SATP_MODE_SV39 | li t0, SATP_MODE_SV39 | ||||
or s2, s2, t0 | or s2, s2, t0 | ||||
sfence.vma | sfence.vma | ||||
csrw satp, s2 | csrw satp, s2 | ||||
.align 2 | .align 2 | ||||
mpva: | mpva: | ||||
Show All 17 Lines |