rumpk/apps/subject_entry.S

50 lines
1.1 KiB
ArmAsm
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

.section .text._start, "ax"
.global _start
_start:
# 🕵 DIAGNOSTIC: BREATHE
li t0, 0x10000000
li t1, 0x23 # '#'
sb t1, 0(t0)
# Clear BSS (64-bit aligned zeroing)
la t0, __bss_start
la t1, __bss_end
1: bge t0, t1, 2f
sd zero, 0(t0)
addi t0, t0, 8
j 1b
2:
fence rw, rw
# 🔧 CRITICAL FIX: Set up stack pointer for userland
# Stack grows down from top of 128MB userland RAM (0x90000000 - 32 bytes for alignment)
li sp, 0x8FFFFFE0
# 🔧 CRITICAL FIX: Set up global pointer for RISC-V ABI
# Global pointer should point to .sdata section for efficient global access
# For userland at 0x88000000, set gp to middle of address space
.option push
.option norelax
la gp, __global_pointer$
.option pop
# 🕵 DIAGNOSTIC: READY TO CALL MAIN
li t0, 0x10000000
li t1, 0x21 # '!'
sb t1, 0(t0)
# Call main(0, NULL)
li a0, 0
li a1, 0
call main
# 🕵 DIAGNOSTIC: RETURNED FROM MAIN
# li t0, 0x10000000
# li t1, 0x24 # '$'
# sb t1, 0(t0)
# Call exit(result)
call exit
1: j 1b