From d592abd8ccc4026c51e196777031eb65c4acc4de Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sun, 7 Jul 2024 14:34:39 +0300 Subject: misc fixes + Align kernel to 2MiB boundary in u-boot + Optimize alignment functions a little bit, should still have to check on real hardware but 'feels' more clean + Add early boot debugging + Put extra cores we aren't ready to account for to sleep if/when they boot. + Make BASE_PAGE_SIZE constant on riscv64/32, helps the compiler with some alignment checks among other things. --- src/main.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index b51c519..f3c5e17 100644 --- a/src/main.c +++ b/src/main.c @@ -61,8 +61,6 @@ __noreturn void kernel(void *fdt, uintptr_t load_addr, struct vmem *d) /* we should be in kernelspace, so use the virtual address of our FDT. */ fdt = __va(fdt); - /* dbg uses direct mapping at this point */ - init_dbg(fdt); /* start up debugging in kernel IO */ setup_io_dbg(d); @@ -105,6 +103,10 @@ __noreturn void main(unsigned long hart, void *fdt, uintptr_t load_addr) * have to get the function signature right */ (void)hart; + /* dbg uses direct mapping at this point, useful for early init asserts + * and so on */ + init_dbg(fdt); + /** @todo some kind of lottery? */ pm_t ram_base = __fdt_ram_base(fdt); pm_t ram_size = __fdt_ram_size(fdt); @@ -114,6 +116,11 @@ __noreturn void main(unsigned long hart, void *fdt, uintptr_t load_addr) init_mem(fdt); + /* we don't have any debug output just yet but still */ + /* also this is I guess more of an architecture limitation, should the + * whole of main() just be moved to arch? */ + assert(is_aligned(load_addr, order_size(MM_O1))); + struct vmem *d = init_mapping(); to_kernelspace(fdt, load_addr, d, ram_base); unreachable(); -- cgit v1.3