From b5d93b9b73398f325eef8ae0b6fc2c75ac0b7f93 Mon Sep 17 00:00:00 2001 From: quackerd Date: Mon, 21 Oct 2024 07:21:56 -0400 Subject: [PATCH] handle dtb size --- sys/arm64/locore.S | 13 ++++++++----- sys/arm64/mbentry.c | 17 ++++++++++++++--- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/sys/arm64/locore.S b/sys/arm64/locore.S index 26ad7a9..6c9dcc3 100644 --- a/sys/arm64/locore.S +++ b/sys/arm64/locore.S @@ -25,9 +25,10 @@ _bootstack: .globl _start _start: .extern _evt - // save x0, x1 to x13, x14 + // save x0, x1, x2 to x13, x14, x15 mov x13, x0 mov x14, x1 + mov x15, x2 // setup EVT for all levels (before MMU) ldr x0,=LOWMEM(_evt) @@ -162,11 +163,13 @@ _high_addr: // re-setup el1 EVT with high addr ldr x0, =_evt msr VBAR_EL1, x0 -.extern MachineBoot_Entry - ldr x15, =MachineBoot_Entry - mov x0, x13 // restore magic & dtb load addr + mov x0, x13 // restore magic & dtb load addr + size mov x1, x14 - blr x15 + mov x2, x15 + +.extern MachineBoot_Entry + ldr x9, =MachineBoot_Entry + blr x9 b _halt .global _halt diff --git a/sys/arm64/mbentry.c b/sys/arm64/mbentry.c index c171542..006af35 100644 --- a/sys/arm64/mbentry.c +++ b/sys/arm64/mbentry.c @@ -16,8 +16,6 @@ #include -void MachineBoot_Entry(unsigned long magic, unsigned long addr); - #define PAGE_ALIGN __attribute__((aligned(PGSIZE))) #define DATA_SECTION __attribute__((section(".data"))) @@ -41,12 +39,25 @@ machineboot_init_mem_regions() memRegionIdx = 1; } +bool +machineboot_parse_dtb(const void * dtb, unsigned long len) +{ + return fdt_check_full(dtb, len) == 0; +} + void -MachineBoot_Entry(unsigned long magic, unsigned long dtb_addr) +MachineBoot_Entry(unsigned long magic, paddr_t dtb_paddr, unsigned long dtb_len) { if (magic != 0x10CA5201) { Halt(); } + + const void * dtb = (const void *)DMPA2VA(dtb_paddr); + + if (!machineboot_parse_dtb(dtb, dtb_len)){ + Halt(); + } + // initialize metal mode mtl_init();