summaryrefslogtreecommitdiff
path: root/loader/memory_efi.c
diff options
context:
space:
mode:
Diffstat (limited to 'loader/memory_efi.c')
-rw-r--r--loader/memory_efi.c25
1 files changed, 25 insertions, 0 deletions
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 <loader/data.h>
+#include <kernel/memory/paging.h>
+
+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;