From ee99fed2a52ac8bdd72d5fa1f4d798c7ef41248c Mon Sep 17 00:00:00 2001 From: Ada Christine Date: Fri, 23 Apr 2021 01:27:23 +0000 Subject: using struct memory_range and a modifed allocation function --- loader/memory_efi.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'loader/memory_efi.c') diff --git a/loader/memory_efi.c b/loader/memory_efi.c index 3dae44f..83c83a8 100644 --- a/loader/memory_efi.c +++ b/loader/memory_efi.c @@ -1,5 +1,30 @@ #include "loader_efi.h" +#include +#include + +struct memory_range system_allocate(size_t size) +{ + EFI_STATUS status; + struct memory_range buffer; + + buffer.type = SYSTEM_MEMORY; + buffer.size = size; + + status = e_bs->AllocatePages(AllocateAnyPages, + SystemMemoryType, + page_count(buffer.size, 1), + &buffer.base); + + if (EFI_ERROR(status)) + { + e_last_error = status; + buffer.type = UNUSABLE_MEMORY; + } + + return buffer; +} + void *efi_allocate(size_t size) { EFI_STATUS status; -- cgit v1.3.1-1-g115d