Changeset View
Changeset View
Standalone View
Standalone View
head/sys/riscv/riscv/locore.S
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | #include <machine/pte.h> | ||||
/* Trap entries */ | /* Trap entries */ | ||||
.text | .text | ||||
/* Reset vector */ | /* Reset vector */ | ||||
.text | .text | ||||
.globl _start | .globl _start | ||||
_start: | _start: | ||||
/* Set the global pointer */ | |||||
.option push | |||||
.option norelax | |||||
lla gp, __global_pointer$ | |||||
.option pop | |||||
/* Get the physical address kernel loaded to */ | /* Get the physical address kernel loaded to */ | ||||
lla t0, virt_map | lla t0, virt_map | ||||
ld t1, 0(t0) | ld t1, 0(t0) | ||||
sub t1, t1, t0 | sub t1, t1, t0 | ||||
li t2, KERNBASE | li t2, KERNBASE | ||||
sub s9, t2, t1 /* s9 = physmem base */ | sub s9, t2, t1 /* s9 = physmem base */ | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | 2: | ||||
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 | ||||
va: | va: | ||||
/* Set the global pointer again, this time with the virtual address. */ | |||||
.option push | |||||
.option norelax | |||||
lla gp, __global_pointer$ | |||||
.option pop | |||||
/* Setup supervisor trap vector */ | /* Setup supervisor trap vector */ | ||||
la t0, cpu_exception_handler | la t0, cpu_exception_handler | ||||
csrw stvec, t0 | csrw stvec, t0 | ||||
/* Ensure sscratch is zero */ | /* Ensure sscratch is zero */ | ||||
li t0, 0 | li t0, 0 | ||||
csrw sscratch, t0 | csrw sscratch, t0 | ||||
/* Set the global pointer */ | |||||
.option push | |||||
.option norelax | |||||
la gp, __global_pointer$ | |||||
.option pop | |||||
/* Initialize stack pointer */ | /* Initialize stack pointer */ | ||||
la s3, initstack_end | la s3, initstack_end | ||||
mv sp, s3 | mv sp, s3 | ||||
/* Allocate space for thread0 PCB and riscv_bootparams */ | /* Allocate space for thread0 PCB and riscv_bootparams */ | ||||
addi sp, sp, -(PCB_SIZE + RISCV_BOOTPARAMS_SIZE) & ~STACKALIGNBYTES | addi sp, sp, -(PCB_SIZE + RISCV_BOOTPARAMS_SIZE) & ~STACKALIGNBYTES | ||||
/* Clear BSS */ | /* Clear BSS */ | ||||
▲ Show 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | 1: | ||||
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: | ||||
/* Set the global pointer again, this time with the virtual address. */ | |||||
.option push | |||||
.option norelax | |||||
lla gp, __global_pointer$ | |||||
.option pop | |||||
/* Setup supervisor trap vector */ | /* Setup supervisor trap vector */ | ||||
la t0, cpu_exception_handler | la t0, cpu_exception_handler | ||||
csrw stvec, t0 | csrw stvec, t0 | ||||
/* Ensure sscratch is zero */ | /* Ensure sscratch is zero */ | ||||
li t0, 0 | li t0, 0 | ||||
csrw sscratch, t0 | csrw sscratch, t0 | ||||
/* Set the global pointer */ | |||||
.option push | |||||
.option norelax | |||||
la gp, __global_pointer$ | |||||
.option pop | |||||
call init_secondary | call init_secondary | ||||
END(mpentry) | END(mpentry) | ||||
#endif | #endif |