From d9b427cab53849c503306af1ebebed30c35fb81f Mon Sep 17 00:00:00 2001 From: Kimplul Date: Fri, 2 Sep 2022 14:01:46 +0300 Subject: reserve more space for fw + Doesn't seem to be specified anywhere, but I'll stick with 2MB for now, working on the assumption that the FW is at the start of the physical RAM. Possible TODOs: generate apos.its automatically from init.elf, allocate root_branch statically? --- arch/riscv64/init/init.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'arch/riscv64/init') diff --git a/arch/riscv64/init/init.c b/arch/riscv64/init/init.c index 2c71ea4..c91d192 100644 --- a/arch/riscv64/init/init.c +++ b/arch/riscv64/init/init.c @@ -33,9 +33,14 @@ static void init_bootmem() { size_t flags = VM_V | VM_X | VM_R | VM_W; - extern char *__init_start; - root_branch = (struct vmem *)align_down( - (uintptr_t)&__init_start - SZ_4K, SZ_4K); + extern char *__init_end; + extern char *__kernel_size; + uintptr_t top = (uintptr_t)&__init_end + (uintptr_t)&__kernel_size; + + /* this could be risky, as we might overwrite some bits of initrd or fdt + * if they're allocated too close to the kernel payload. + * @todo Allocate root_branch statically? */ + root_branch = (struct vmem *)align_up(top, SZ_4K); /* direct mapping (temp) */ for (size_t i = 0; i < CSTACK_PAGE; ++i) -- cgit v1.3