:: commit ce37d327efb8cfbeb7d645ce8bec5065e0e65c87

mintsuki <mintsuki@protonmail.com> — 2021-12-02 00:23

parents: 8aac4785c1

pmm: Mark Limine image wholly as bootloader reclaimable in memory map when using UEFI

diff --git a/stage23/mm/pmm.s2.c b/stage23/mm/pmm.s2.c
index 522ea467..2f444937 100644
--- a/stage23/mm/pmm.s2.c
+++ b/stage23/mm/pmm.s2.c
@@ -276,6 +276,9 @@ void init_memmap(void) {
 #endif
 
 #if uefi == 1
+extern symbol ImageBase;
+extern symbol _edata;
+
 void init_memmap(void) {
     EFI_STATUS status;
 
@@ -382,6 +385,12 @@ void init_memmap(void) {
     memcpy(untouched_memmap, memmap, memmap_entries * sizeof(struct e820_entry_t));
     untouched_memmap_entries = memmap_entries;
 
+    // Allocate bootloader itself
+    memmap_alloc_range((uintptr_t)ImageBase, (uintptr_t)_edata - (uintptr_t)ImageBase,
+                       MEMMAP_BOOTLOADER_RECLAIMABLE, false, true, false, true);
+
+    sanitise_entries(memmap, &memmap_entries, false);
+
     return;
 
 fail:
tab: 248 wrap: offon