diff options
author | stefan <stefan@s00.xyz> | 2023-04-15 05:02:02 +0000 |
---|---|---|
committer | stefan <stefan@s00.xyz> | 2023-04-15 05:02:02 +0000 |
commit | af1ce4b2e637ceb418ea72d51c49a3eee276a938 (patch) | |
tree | 4d6a33644f8489e4f582f6e320bd6581b94fb642 /sys/kern/entry.S | |
parent | 8cceb31dcaf4641d43f324fa3301b37859ebfade (diff) | |
download | sv-af1ce4b2e637ceb418ea72d51c49a3eee276a938.tar.gz |
added multiprocessor support
Diffstat (limited to 'sys/kern/entry.S')
-rw-r--r-- | sys/kern/entry.S | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/sys/kern/entry.S b/sys/kern/entry.S index 03ff76c..9bf72ea 100644 --- a/sys/kern/entry.S +++ b/sys/kern/entry.S @@ -1,8 +1,14 @@ .section ".text.init" +// entrypoint for boot hart(s). a0: hartid, a1: *fdt .globl _start -_start: - /* disable interrupts and poging */ + + +// entrypoint for other harts. a0: hartid, a1: unused for now +.global _mpentry + +_start: + /* disable interrupts and paging */ csrw satp, zero csrw sie, zero csrw sip, zero @@ -12,7 +18,9 @@ _start: la gp, __global_pointer$ .option pop - /* setup stack */ + /* setup stack. + * stack grows toward lower address so sp will mark end of frame. + */ addi t0, a0, 1 li t1, PAGE_SIZE la sp, __stack_start @@ -22,11 +30,11 @@ _start: /* 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 */ + /* the label _boot_hart is shared between threads. after the first atomic swap, all other harts will branch to mpentry */ li a2, 1 lla a3, _boot_hart amoswap.w a3, a2, (a3) - bnez a3, 2f + bnez a3, _mpentry /* clear the bss section */ la a2, __bss_start @@ -39,9 +47,16 @@ _start: call init j _spin +_mpentry: + /* satp = 0, sstatus.sie = 0, a0 = hartid, a1 = opaque */ + + call mpinit + /* shouldn't reach this point */ + j _spin + _spin: wfi - j _spin + j _spin .section ".data" _boot_hart: @@ -51,3 +66,4 @@ _boot_hart: /* linker imports */ .globl HEAP_START HEAP_START: .dword __heap_start + |