59 lines
1.2 KiB
ArmAsm
59 lines
1.2 KiB
ArmAsm
.section .text
|
|
.globl _entry
|
|
_entry:
|
|
# Both call and j will work here, but since ra will be cleared,
|
|
# we will need a jump instruction back (from _clear) to continue.
|
|
call _clear
|
|
|
|
continue:
|
|
# Set up a stack for C.
|
|
la sp, stack0
|
|
li a0, 1024*4 # a0 = 4096
|
|
csrr a1, mhartid # a1 = hart id
|
|
addi a1, a1, 1 # hartid + 1
|
|
mul a0, a0, a1 # a0 *= hartid+1
|
|
add sp, sp, a0 # sp += a0
|
|
|
|
# Jump to start() in start.c
|
|
call start
|
|
|
|
1:
|
|
j 1b # Infinite loop
|
|
|
|
.section .text
|
|
.globl _clear
|
|
_clear:
|
|
li x1, 0x0 # ra: Return address
|
|
li x2, 0x0 # sp: Stack points
|
|
li x3, 0x0 # gp: Global pointer
|
|
li x4, 0x0 # tp: Thread pointer
|
|
li x5, 0x0
|
|
li x6, 0x0
|
|
li x7, 0x0
|
|
li x8, 0x0
|
|
li x9, 0x0
|
|
li x10, 0x0
|
|
li x11, 0x0
|
|
li x12, 0x0
|
|
li x13, 0x0
|
|
li x14, 0x0
|
|
li x15, 0x0
|
|
li x16, 0x0
|
|
li x17, 0x0
|
|
li x18, 0x0
|
|
li x19, 0x0
|
|
li x20, 0x0
|
|
li x21, 0x0
|
|
li x22, 0x0
|
|
li x23, 0x0
|
|
li x24, 0x0
|
|
li x25, 0x0
|
|
li x26, 0x0
|
|
li x27, 0x0
|
|
li x28, 0x0
|
|
li x29, 0x0
|
|
li x30, 0x0
|
|
li x31, 0x0
|
|
|
|
# ret wont work here since we cleared x1
|
|
j continue
|