aboutsummaryrefslogtreecommitdiff
path: root/src/baremetal/start_riscv.S
diff options
context:
space:
mode:
authorGravatar Moon Flower <moonflower@elhenney.local> 2026-10-12 08:46:23 +0330
committerGravatar Moon Flower <moonflower@elhenney.local> 2026-10-12 08:46:23 +0330
commitecc350ca5c2eb50be8309c5f14f8bf0d87db9a02 (patch)
tree70e0af76a1b13affff7c6cc8aac7b3e6ef960478 /src/baremetal/start_riscv.S
a
Diffstat (limited to 'src/baremetal/start_riscv.S')
-rw-r--r--src/baremetal/start_riscv.S20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/baremetal/start_riscv.S b/src/baremetal/start_riscv.S
new file mode 100644
index 0000000..527f109
--- /dev/null
+++ b/src/baremetal/start_riscv.S
@@ -0,0 +1,20 @@
+/* RISC-V virt, machine mode, no firmware. Stack, clear bss, enter C. */
+.section .text.init
+.global _start
+_start:
+ /* FS = Dirty, so a compiler that emits float ops does not trap. */
+ li t0, 0x6000
+ csrs mstatus, t0
+ la sp, _stack_top
+ la t0, _sbss
+ la t1, _ebss
+1:
+ bgeu t0, t1, 2f
+ sd zero, 0(t0)
+ addi t0, t0, 8
+ j 1b
+2:
+ call bare_main
+3:
+ wfi
+ j 3b