mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 08:56:40 +00:00
Kernel/riscv64: Add Linux boot header
This allows us to boot via U-Boot's booti command.
This commit is contained in:
parent
d99d66e358
commit
ec5cfc031e
|
@ -7,6 +7,28 @@
|
||||||
// In a specially-named text section so that the linker script can put it first in .text.
|
// In a specially-named text section so that the linker script can put it first in .text.
|
||||||
.section ".text.first"
|
.section ".text.first"
|
||||||
|
|
||||||
|
// Make the kernel bootable using U-Boot's booti command by adding a linux header (https://www.kernel.org/doc/html/latest/arch/riscv/boot-image-header.html).
|
||||||
|
// Booting via booti causes U-Boot to pass us the boot hart ID and a flattened devicetree (https://www.kernel.org/doc/html/latest/arch/riscv/boot.html).
|
||||||
|
linux_header:
|
||||||
|
.option push
|
||||||
|
.option norvc
|
||||||
|
j start // u32 code0
|
||||||
|
j start // u32 code1
|
||||||
|
.option pop
|
||||||
|
|
||||||
|
// This offset is needed, as otherwise U-Boot will try to load us at the same address where OpenSBI is loaded.
|
||||||
|
// The value is the same that Linux uses.
|
||||||
|
.dword 0x400000 // u64 text_offset
|
||||||
|
|
||||||
|
.dword end_of_kernel_image - linux_header // u64 image_size
|
||||||
|
.dword 0 // u64 flags
|
||||||
|
.word 2 // u32 version
|
||||||
|
.word 0 // u32 res1
|
||||||
|
.dword 0 // u64 res2
|
||||||
|
.ascii "RISCV\0\0\0" // u64 magic (deprecated)
|
||||||
|
.ascii "RSC\x5" // u32 magic2
|
||||||
|
.word 0 // u32 res3
|
||||||
|
|
||||||
.global start
|
.global start
|
||||||
.type start, @function
|
.type start, @function
|
||||||
start:
|
start:
|
||||||
|
|
Loading…
Reference in a new issue