From fe456c2014c8d1d88b7fd5b24ebda7f7b4c53460 Mon Sep 17 00:00:00 2001 From: Matthew Wozniak Date: Fri, 29 May 2026 21:59:53 -0400 Subject: basic physical memory page allocator Signed-off-by: Matthew Wozniak --- src/asm/boot.S | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/asm/boot.S (limited to 'src/asm/boot.S') 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 -- cgit v1.2.3-54-g00ecf