handle dtb size

This commit is contained in:
quackerd 2024-10-21 07:21:56 -04:00
parent b8e1f93fe5
commit b5d93b9b73
2 changed files with 22 additions and 8 deletions

View File

@ -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

View File

@ -16,8 +16,6 @@
#include <sys/contrib/libfdt/libfdt.h>
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();