From 9b2c2f6b293aa7688ad56425b8622bca0ebc376d Mon Sep 17 00:00:00 2001 From: Max Wash Date: Sat, 21 Feb 2026 11:24:36 +0000 Subject: [PATCH] x86_64: start the kernel bootstrap heap above 16MiB this will keep the memory area below 16MiB free for DMA memory allocations. --- arch/x86_64/init.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/arch/x86_64/init.c b/arch/x86_64/init.c index 70b0e6b..05cd9fd 100644 --- a/arch/x86_64/init.c +++ b/arch/x86_64/init.c @@ -18,7 +18,20 @@ #include #include -#define PTR32(x) ((void *)((uintptr_t)(x))) +#define PTR32(x) ((void *)((uintptr_t)(x))) + +/* the physical address of the start of the memblock heap. + * this is an arbirary value; the heap can start anywhere in memory. + * any reserved areas of memory (the kernel, bsp, bios data, etc) are + * automatically taken into account. + * HOWEVER, this value will dictate how much physical memory is required for + * the kernel to boot successfully. + * the value of 16MiB (0x1000000) means that all heap allocations will be + * above 16MiB, leaving the area below free for DMA operations. + * this value CAN be reduced all the way to zero to minimise the amount of + * memory required to boot, but this may leave you with no DMA memory available. + */ +#define MEMBLOCK_HEAP_START 0x1000000 static ml_cpu_block g_bootstrap_cpu = {0}; @@ -33,7 +46,7 @@ static void bootstrap_cpu_init(void) static void early_vm_init(uintptr_t reserve_end) { - uintptr_t alloc_start = VM_KERNEL_VOFFSET; + uintptr_t alloc_start = VM_KERNEL_VOFFSET + MEMBLOCK_HEAP_START; /* boot code mapped 2 GiB of memory from VM_KERNEL_VOFFSET */ uintptr_t alloc_end = VM_KERNEL_VOFFSET + 0x7fffffff;