summaryrefslogtreecommitdiff
path: root/sys/kern/entry.S
diff options
context:
space:
mode:
authorstefan <stefan@s00.xyz>2023-04-08 20:42:18 -0400
committerstefan <stefan@s00.xyz>2023-04-08 20:42:18 -0400
commit1aac36f788834699b6891aea7a83eb950bd5e8f6 (patch)
tree18e0a6c26b83e71c101193e60149f49b1641daf0 /sys/kern/entry.S
parenta1a97aa7b2b0c3d1f3b6766446d605f83de1c561 (diff)
downloadsv-1aac36f788834699b6891aea7a83eb950bd5e8f6.tar.gz
no idea whot i changed lol
Diffstat (limited to 'sys/kern/entry.S')
-rw-r--r--sys/kern/entry.S18
1 files changed, 14 insertions, 4 deletions
diff --git a/sys/kern/entry.S b/sys/kern/entry.S
index fccd80f..03ff76c 100644
--- a/sys/kern/entry.S
+++ b/sys/kern/entry.S
@@ -2,6 +2,7 @@
.globl _start
_start:
+ /* disable interrupts and poging */
csrw satp, zero
csrw sie, zero
csrw sip, zero
@@ -11,33 +12,42 @@ _start:
la gp, __global_pointer$
.option pop
+ /* setup stack */
addi t0, a0, 1
li t1, PAGE_SIZE
la sp, __stack_start
mul t1, t1, t0
add sp, sp, t1
+ /* setup thread pointer */
+ mv tp, a0
+
+ /* the label _boot_hart is shared between threads. only one hart will branch before it is no longer 0 */
li a2, 1
lla a3, _boot_hart
amoswap.w a3, a2, (a3)
- bnez a3, _spin
+ bnez a3, 2f
+ /* clear the bss section */
la a2, __bss_start
la a3, __bss_end
1:
sd zero, (a2)
addi a2, a2, __SIZEOF_POINTER__
blt a2, a3, 1b
-
+2:
call init
-
+ j _spin
_spin:
wfi
j _spin
.section ".data"
-_boot_hart: .word 0
+_boot_hart:
+ .word 0
+
.section ".rodata"
+/* linker imports */
.globl HEAP_START
HEAP_START: .dword __heap_start