diff options
-rw-r--r-- | include/efi_loader.h | 2 | ||||
-rw-r--r-- | lib/efi_loader/efi_memory.c | 11 |
2 files changed, 10 insertions, 3 deletions
diff --git a/include/efi_loader.h b/include/efi_loader.h index 3dad24e84f..94397af483 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -117,7 +117,7 @@ void *efi_alloc(uint64_t len, int memory_type); /* More specific EFI memory allocator, called by EFI payloads */ efi_status_t efi_allocate_pages(int type, int memory_type, unsigned long pages, uint64_t *memory); -/* EFI memory free function. Not implemented today */ +/* EFI memory free function. */ efi_status_t efi_free_pages(uint64_t memory, unsigned long pages); /* EFI memory allocator for small allocations */ efi_status_t efi_allocate_pool(int pool_type, unsigned long size, diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index de28db6e44..d3a2ffdac6 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -336,8 +336,15 @@ void *efi_alloc(uint64_t len, int memory_type) efi_status_t efi_free_pages(uint64_t memory, unsigned long pages) { - /* We don't free, let's cross our fingers we have plenty RAM */ - return EFI_SUCCESS; + uint64_t r = 0; + + r = efi_add_memory_map(memory, pages, EFI_CONVENTIONAL_MEMORY, false); + /* Merging of adjacent free regions is missing */ + + if (r == memory) + return EFI_SUCCESS; + + return EFI_NOT_FOUND; } efi_status_t efi_allocate_pool(int pool_type, unsigned long size, |