diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2023-05-11 22:55:31 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2023-05-11 22:55:31 +0300 |
| commit | 27ffa747f36aee9c1d5bbc61395a078238366070 (patch) | |
| tree | f37c544aaca6bebd1cc146d1eb002483c7cfd474 /arch/riscv64/init/start.S | |
| parent | 3109effe7297232e17c1792e63c3a9c7d129a4eb (diff) | |
| download | kmi-27ffa747f36aee9c1d5bbc61395a078238366070.tar.gz kmi-27ffa747f36aee9c1d5bbc61395a078238366070.zip | |
arbitrary load address and RAM base detection
+ Both kind of go hand in hand, made sense to do both at the same time.
Some parts feel slightly hacky, the loader works by placing everything
on the stack and avoiding global values. Still, seems to work?
Diffstat (limited to 'arch/riscv64/init/start.S')
| -rw-r--r-- | arch/riscv64/init/start.S | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/arch/riscv64/init/start.S b/arch/riscv64/init/start.S index b54f685..759c409 100644 --- a/arch/riscv64/init/start.S +++ b/arch/riscv64/init/start.S @@ -5,8 +5,10 @@ .global _start /* Entry point to the kernel loader. */ _start: -/* load static stack */ -li sp, PM_STACK_TOP +/* get load address */ +auipc a1, 0 +/* keep using bootloader stack for now */ +//li sp, PM_STACK_TOP /* make sure there's no garbage in tp, important for id assignment */ li tp, 0 call init @@ -14,6 +16,12 @@ call init .section .text .global jump_to_kernel jump_to_kernel: -mv a2, a0 // store kernel addr -mv a0, a1 // move fdt pointer to first argument +li sp, VM_STACK_TOP // load virtual stack address +li fp, 0 +li gp, 0 jr a2 // jump to kernel + +/* there should be a kernel payload after this address */ +.section .top +.global __kernel +__kernel: |
