summaryrefslogtreecommitdiff
path: root/kjarna/efi/memory.c
diff options
context:
space:
mode:
authorAda Christine <adachristine18@gmail.com>2024-03-03 08:44:42 +0000
committerAda Christine <adachristine18@gmail.com>2024-03-03 08:44:42 +0000
commitf61da8be06fdfebc598cba783e78117319231140 (patch)
tree0ef21f89e98a985ab5d985aaac1e032c868e8b81 /kjarna/efi/memory.c
parent9681d6a6cbde12b00beab62683b8db98f680ba2b (diff)
build changes
Diffstat (limited to 'kjarna/efi/memory.c')
-rw-r--r--kjarna/efi/memory.c83
1 files changed, 0 insertions, 83 deletions
diff --git a/kjarna/efi/memory.c b/kjarna/efi/memory.c
deleted file mode 100644
index 7fbb4a8..0000000
--- a/kjarna/efi/memory.c
+++ /dev/null
@@ -1,83 +0,0 @@
-#include <libc/string.h>
-
-#include <efi/services.h>
-#include <efi/error.h>
-
-#include <stddef.h>
-
-#include "kjarna_efi.h"
-
-void *efi_alloc_pool(size_t size)
-{
- void *buffer;
-
- efi_errno = gBS->AllocatePool(
- EfiLoaderData,
- size,
- &buffer);
-
- if (EFI_ERROR(efi_errno))
- {
- return nullptr;
- }
-
- return buffer;
-}
-
-void *efi_calloc_pool(size_t count, size_t size)
-{
- void *buffer = efi_alloc_pool(count * size);
-
- if (buffer != nullptr)
- {
- memset(buffer, 0, count * size);
- }
-
- return buffer;
-}
-
-void efi_free_pool(void *buffer)
-{
- efi_errno = gBS->FreePool(buffer);
-}
-
-#define KjarnaData EFIX_OS_MEMORY_TYPE(1)
-
-void *efi_mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
-{
- (void)prot;
- (void)flags;
- (void)fd;
- (void)offset;
-
- EFI_ALLOCATE_TYPE alloc_type = AllocateAnyPages;
- EFI_MEMORY_TYPE memory_type = KjarnaData;
-
- void *buffer;
-
- if (addr != nullptr)
- {
- alloc_type = AllocateAddress;
- }
-
- efi_errno = gBS->AllocatePages(
- alloc_type,
- memory_type,
- EFI_SIZE_TO_PAGES(length),
- (uintptr_t *)&buffer);
-
- if (EFI_ERROR(efi_errno))
- {
- return nullptr;
- }
-
- return buffer;
-}
-
-int efi_munmap(void *addr, size_t length)
-{
- efi_errno = gBS->FreePages((uintptr_t)addr, EFI_SIZE_TO_PAGES(length));
-
- return !EFI_ERROR(efi_errno) ? 0 : -1;
-}
-