diff options
| author | 2026-05-29 21:59:53 -0400 | |
|---|---|---|
| committer | 2026-05-29 22:04:38 -0400 | |
| commit | fe456c2014c8d1d88b7fd5b24ebda7f7b4c53460 (patch) | |
| tree | a1ae3682aede1ea7550f4be76a79118bd6502902 /src/asm/boot.S | |
| download | quail-fe456c2014c8d1d88b7fd5b24ebda7f7b4c53460.tar.gz quail-fe456c2014c8d1d88b7fd5b24ebda7f7b4c53460.zip | |
basic physical memory page allocator
Signed-off-by: Matthew Wozniak <me@woz.blue>
Diffstat (limited to 'src/asm/boot.S')
| -rw-r--r-- | src/asm/boot.S | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/asm/boot.S b/src/asm/boot.S new file mode 100644 index 0000000..bd50b4c --- /dev/null +++ b/src/asm/boot.S @@ -0,0 +1,42 @@ +# bootloader for my kernel +.option norvc +.section .data +.section .text.init +.global _start +_start: + # any harts not bootstrapping need to wait for an IPI + csrr t0, mhartid + bnez t0, 3f + # satp should be zero, but make sure + csrw satp, zero +.option push +.option norelax + la gp, __global_pointer$ +.option pop + # clear bss + la a0, _bss_start + la a1, _bss_end + bgeu a0, a1, 2f +1: + sd zero, (a0) + addi a0, a0, 8 + bltu a0, a1, 1b +2: + # set up stack + la sp, _stack_end + # set kmain to the return address and then return + li t0, (0b11 << 11) | (1 << 7) | (1 << 3) + la t1, kmain + la t2, asm_trap_vector + li t3, 0 # (1 << 3) | (1 << 7) | (1 << 11) + csrw mstatus, t0 + csrw mepc, t1 + csrw mtvec, t2 + csrw mie, t3 + mret + + +# wait for interrupt +3: + wfi + j 3b |
