From 4ab2ce3fb0e6b8085742c734a8f5437db5979046 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Tue, 3 Dec 2024 07:47:56 +0100 Subject: Simplify how we fetch the load address MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Similarly to 58fcecc381be ("Simplify the constant on the size of the stack"), the base and offset load addresses where taken from the Linux kernel, which has to account for way more stuff than this poor kernel. Hence, let's be more explicit about the base address and the offset where the kernel will be located, so it's actually more clear both on the linker, and on the kernel's header. Signed-off-by: Miquel Sabaté Solà --- include/fbos/mm.h | 9 +++++---- kernel/head.S | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/fbos/mm.h b/include/fbos/mm.h index 017e28a..f8c54d9 100644 --- a/include/fbos/mm.h +++ b/include/fbos/mm.h @@ -12,10 +12,11 @@ /* * The code will be linked to start at the first page, which will have a given - * offset. + * offset from the base address where a kernel can be allocated on a RISC-V + * machine. */ - -#define PAGE_OFFSET 0x80200000 -#define LOAD_OFFSET PAGE_OFFSET +#define LOAD_BASE_ADDR 0x80000000 +#define LOAD_BASE_OFFSET 0x00200000 +#define LOAD_OFFSET (LOAD_BASE_ADDR + LOAD_BASE_OFFSET) #endif /* __FBOS_MM_H */ diff --git a/kernel/head.S b/kernel/head.S index ac69967..74f83d8 100644 --- a/kernel/head.S +++ b/kernel/head.S @@ -27,9 +27,9 @@ _start: // Ensure alignment for the next double word. .balign 8 - // Load offset. Note that this matches the PAGE_OFFSET as defined in + // Load offset. Note that this matches the LOAD_BASE_OFFSET as defined in // `include/mm.h`. - .dword 0x200000 + .dword LOAD_BASE_OFFSET // Size of the image. This is *mandatory* as per bootloader request. .dword _end - _start -- cgit v1.2.3