2026-02-08 21:23:47 +00:00
|
|
|
.section .text
|
|
|
|
|
.global _start
|
|
|
|
|
_start:
|
|
|
|
|
la sp, stack_top # Set up the stack pointer
|
2026-02-08 22:41:38 +00:00
|
|
|
la t0, trap_entry # Set up the trap handler
|
|
|
|
|
csrw mtvec, t0 # Set the trap vector to our trap handler
|
2026-02-09 02:55:15 +00:00
|
|
|
li t0, 0x00006000 # Load the mask for FS bits. enable float
|
|
|
|
|
csrs mstatus, t0 # Set the FS bits to 11 (Dirty/Initial). enable float
|
2026-02-08 21:23:47 +00:00
|
|
|
call kmain # Jump to our C code
|
|
|
|
|
loop:
|
|
|
|
|
wfi # Wait for Interrupt (saves CPU)
|
|
|
|
|
j loop # Infinite loop if C returns
|
2026-02-08 22:41:38 +00:00
|
|
|
.align 4
|
|
|
|
|
trap_entry:
|
2026-02-09 02:55:15 +00:00
|
|
|
csrr a0, mcause # Argument 1: mcause
|
|
|
|
|
csrr a1, mepc # Argument 2: mepc
|
2026-02-08 22:41:38 +00:00
|
|
|
j handle_trap
|
2026-02-08 21:23:47 +00:00
|
|
|
.section .bss
|
|
|
|
|
.align 16
|
|
|
|
|
stack_low:
|
|
|
|
|
.skip 4096 # 4KB of stack space
|
|
|
|
|
stack_top:
|