diff options
author | Alexander Graf <agraf@suse.de> | 2016-03-04 01:10:04 +0100 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2016-03-15 21:30:10 -0400 |
commit | 5d00995c361c5a01b0684927d2686fdb540ab467 (patch) | |
tree | 3522c68b25ae145c7148a22f3f8f3f86e8a2aae4 /include/efi_loader.h | |
parent | b9939336d09ddc01e9e9d4e6a654f54f28decb12 (diff) |
efi_loader: Implement memory allocation and map
The EFI loader needs to maintain views of memory - general system memory
windows as well as used locations inside those and potential runtime service
MMIO windows.
To manage all of these, add a few helpers that maintain an internal
representation of the map the similar to how the EFI API later on reports
it to the application.
For allocations, the scheme is very simple. We basically allow allocations
to replace chunks of previously done maps, so that a new LOADER_DATA
allocation for example can remove a piece of the RAM map. When no specific
address is given, we just take the highest possible address in the lowest
RAM map that fits the allocation size.
Signed-off-by: Alexander Graf <agraf@suse.de>
Tested-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/efi_loader.h')
-rw-r--r-- | include/efi_loader.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/efi_loader.h b/include/efi_loader.h index be3c28abcd5..11be685f0e1 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -110,6 +110,25 @@ efi_status_t efi_exit_func(efi_status_t ret); /* Call this to relocate the runtime section to an address space */ void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map); +/* Generic EFI memory allocator, call this to get memory */ +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_status_t efi_free_pages(uint64_t memory, unsigned long pages); +/* Returns the EFI memory map */ +efi_status_t efi_get_memory_map(unsigned long *memory_map_size, + struct efi_mem_desc *memory_map, + unsigned long *map_key, + unsigned long *descriptor_size, + uint32_t *descriptor_version); +/* Adds a range into the EFI memory map */ +uint64_t efi_add_memory_map(uint64_t start, uint64_t pages, int memory_type, + bool overlap_only_ram); +/* Called by board init to initialize the EFI memory map */ +int efi_memory_init(void); + /* * Use these to indicate that your code / data should go into the EFI runtime * section and thus still be available when the OS is running |