summaryrefslogtreecommitdiff
path: root/sys/kern/entry.S
diff options
context:
space:
mode:
authorstefan <stefan@s00.xyz>2023-04-04 06:01:50 +0000
committerstefan <stefan@s00.xyz>2023-04-04 06:01:50 +0000
commit25108684fe235d4296c3cbc480298df209682586 (patch)
tree59f051e13154764da2b98dfdc1ce66e363d801da /sys/kern/entry.S
parent254ffbc869c2376e77ecc298dfd396f077e9d58a (diff)
downloadsv-25108684fe235d4296c3cbc480298df209682586.tar.gz
build system and some other stuff
Diffstat (limited to 'sys/kern/entry.S')
-rw-r--r--sys/kern/entry.S39
1 files changed, 39 insertions, 0 deletions
diff --git a/sys/kern/entry.S b/sys/kern/entry.S
new file mode 100644
index 0000000..5ad0490
--- /dev/null
+++ b/sys/kern/entry.S
@@ -0,0 +1,39 @@
+.section ".text.init"
+
+.globl _start
+_start:
+ csrw satp, zero
+ csrw sie, zero
+ csrw sip, zero
+
+ .option push
+ .option norelax
+ la gp, __global_pointer$
+ .option pop
+
+ la sp, __stack_start
+ li t1, PAGE_SIZE
+ mul t1, t1, a0
+ add sp, sp, t1
+
+ li a2, 1
+ lla a3, _boot_hart
+ amoswap.w a3, a2, (a3)
+ bnez a3, _spin
+
+ la a2, __bss_start
+ la a3, __bss_end
+1:
+ sd zero, (a2)
+ addi a2, a2, __SIZEOF_POINTER__
+ blt a2, a3, 1b
+
+ call init
+
+
+_spin:
+ wfi
+ j _spin
+
+.section ".data"
+_boot_hart: .word 0