Memory heap and allocator

This commit is contained in:
2026-02-26 20:24:56 +00:00
parent c2dd9d1e89
commit 770526efae
7 changed files with 603 additions and 1 deletions

13
main.c
View File

@@ -207,6 +207,17 @@ static void loader_shutdown(void)
uefi_call_wrapper(RT->ResetSystem, 4, EfiResetShutdown, EFI_SUCCESS, 0, NULL);
}
static EFI_STATUS loader_alloc_pages(UINTN pages, EFI_PHYSICAL_ADDRESS *addr)
{
return uefi_call_wrapper(BS->AllocatePages, 4,
AllocateAnyPages, EfiLoaderData, pages, addr);
}
static EFI_STATUS loader_free_pages(EFI_PHYSICAL_ADDRESS addr, UINTN pages)
{
return uefi_call_wrapper(BS->FreePages, 2, addr, pages);
}
EFI_STATUS
EFIAPI
efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
@@ -241,6 +252,8 @@ efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
Boot.set_attribute = loader_set_attribute;
Boot.read_key = loader_read_key;
Boot.shutdown = loader_shutdown;
Boot.alloc_pages = loader_alloc_pages;
Boot.free_pages = loader_free_pages;
EntryFn = (KernelEntryFn)(UINTN)KernelEntry;
EntryFn(&Boot);