summaryrefslogtreecommitdiff
path: root/loader/memory_efi.c
diff options
context:
space:
mode:
authorAda Christine <adachristine18@gmail.com>2021-04-23 01:27:23 +0000
committerAda Christine <adachristine18@gmail.com>2021-04-23 01:27:23 +0000
commitee99fed2a52ac8bdd72d5fa1f4d798c7ef41248c (patch)
treec392fe821544f19f659a7569c06f70b6b5dbba20 /loader/memory_efi.c
parentb90e152c02aad225e83a3e6c1b80d1a0e396bb14 (diff)
using struct memory_range and a modifed allocation function
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;