Files
riscv-operating-system-mooc/code/os/03-contextswitch/start.S
Wang Chen 100cc9f1d9 This commitment contains following changes:
- updated openday report
- fixed I41BDM
- I3ZLLK, code part & errata part fixing
- fixed I3XWKC, ppt & errata part
- fixed I418VG
2021-07-22 17:10:04 +08:00

43 lines
1004 B
ArmAsm

#include "platform.h"
# size of each hart's stack is 1024 bytes
.equ STACK_SIZE, 1024
.global _start
.text
_start:
# park harts with id != 0
csrr t0, mhartid # read current hart id
mv tp, t0 # keep CPU's hartid in its tp for later usage.
bnez t0, park # if we're not on the hart 0
# we park the hart
# Set all bytes in the BSS section to zero.
la a0, _bss_start
la a1, _bss_end
bgeu a0, a1, 2f
1:
sw zero, (a0)
addi a0, a0, 4
bltu a0, a1, 1b
2:
# Setup stacks, the stack grows from bottom to top, so we put the
# stack pointer to the very end of the stack range.
slli t0, t0, 10 # shift left the hart id by 1024
la sp, stacks + STACK_SIZE # set the initial stack pointer
# to the end of the first stack space
add sp, sp, t0 # move the current hart stack pointer
# to its place in the stack space
j start_kernel # hart 0 jump to c
park:
wfi
j park
stacks:
.skip STACK_SIZE * MAXNUM_CPU # allocate space for all the harts stacks
.end # End of file