-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmemory.h
More file actions
42 lines (38 loc) · 892 Bytes
/
memory.h
File metadata and controls
42 lines (38 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <efi.h>
#include <efilib.h>
void *uefi_malloc(UINTN poolSize)
{
EFI_STATUS status;
void *handle;
Print(L"allocating memory pool\n");
status = uefi_call_wrapper(BS->AllocatePool, 3, EfiLoaderData, poolSize, &handle);
if (status == EFI_OUT_OF_RESOURCES)
{
Print(L"out of resources for pool\n");
return 0;
}
else if (status == EFI_INVALID_PARAMETER)
{
Print(L"invalid pool type\n");
return 0;
}
else
{
Print(L"memory pool successfully allocated\n");
return handle;
}
}
void uefi_free(void *pool)
{
EFI_STATUS status;
Print(L"freeing memory pool\n");
status = uefi_call_wrapper(BS->FreePool, 1, pool);
if (status == EFI_INVALID_PARAMETER)
{
Print(L"invalid pool pointer\n");
}
else
{
Print(L"memory pool successfully freed\n");
}
}