Keyboard Work - setting up PLIC, UART, Interrupts
This commit is contained in:
parent
4c0a4958a2
commit
50757427be
12 changed files with 295 additions and 68 deletions
|
|
@ -1,22 +1,20 @@
|
|||
.section .text
|
||||
.section .text.boot
|
||||
.global _start
|
||||
_start:
|
||||
la sp, stack_top # Set up the stack pointer
|
||||
la t0, trap_entry # Set up the trap handler
|
||||
csrw mtvec, t0 # Set the trap vector to our trap handler
|
||||
li t0, 0x00006000 # Load the mask for FS bits. enable float
|
||||
csrs mstatus, t0 # Set the FS bits to 11 (Dirty/Initial). enable float
|
||||
call kmain # Jump to our C code
|
||||
# 1. Set up the stack pointer using the symbol from our linker script
|
||||
la sp, stack_top
|
||||
|
||||
# 2. Set up the trap handler (pointing to the one in traps.S)
|
||||
la t0, trap_entry
|
||||
csrw mtvec, t0
|
||||
|
||||
# 3. Enable FPU (Floating Point)
|
||||
li t0, 0x00006000
|
||||
csrs mstatus, t0
|
||||
|
||||
# 4. Jump to C
|
||||
call kmain
|
||||
|
||||
loop:
|
||||
wfi # Wait for Interrupt (saves CPU)
|
||||
j loop # Infinite loop if C returns
|
||||
.align 4
|
||||
trap_entry:
|
||||
csrr a0, mcause # Argument 1: mcause
|
||||
csrr a1, mepc # Argument 2: mepc
|
||||
j handle_trap
|
||||
.section .bss
|
||||
.align 16
|
||||
stack_low:
|
||||
.skip 4096 # 4KB of stack space
|
||||
stack_top:
|
||||
wfi
|
||||
j loop
|
||||
Loading…
Add table
Add a link
Reference in a new issue