RISC-V operating system
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
rovo/kernel/crt0.S

27 lines
756 B

1 year ago
# 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