rovo/kernel/crt0.S

27 lines
756 B
ArmAsm
Raw Permalink Normal View History

2023-06-08 13:14:16 +02:00
# C runtime, modified from
# https://twilco.github.io/riscv-from-scratch/2019/04/27/riscv-from-scratch-2.html#stop--hammertime-runtime
# in the init section which is "allocatable" and "executable"
.section .init, "ax"
# entry point for the kernel
.global _start
_start:
.cfi_startproc
.cfi_undefined ra
# initialize the global pointer register
.option push
.option norelax
la gp, __global_pointer$
.option pop
# initialize the stack pointer and frame pointer registers
# FIXME: when putting the stack at the end of RAM with system memory >2G
# it fails to link with the error: relocation truncated to fit:
# R_RISCV_HI20 against '__stack_top'
la sp, __stack_top
add s0, sp, zero
# jump to main
jal zero, main
.cfi_endproc
.end