// SPDX-License-Identifier: GPL-2.0 /* * Common EFI memory map functions. */ #define pr_fmt(fmt) … #include <linux/init.h> #include <linux/kernel.h> #include <linux/efi.h> #include <linux/io.h> #include <asm/early_ioremap.h> #include <asm/efi.h> #include <linux/memblock.h> #include <linux/slab.h> static phys_addr_t __init __efi_memmap_alloc_early(unsigned long size) { … } static phys_addr_t __init __efi_memmap_alloc_late(unsigned long size) { … } static void __init __efi_memmap_free(u64 phys, unsigned long size, unsigned long flags) { … } /** * efi_memmap_alloc - Allocate memory for the EFI memory map * @num_entries: Number of entries in the allocated map. * @data: efi memmap installation parameters * * Depending on whether mm_init() has already been invoked or not, * either memblock or "normal" page allocation is used. * * Returns zero on success, a negative error code on failure. */ int __init efi_memmap_alloc(unsigned int num_entries, struct efi_memory_map_data *data) { … } /** * efi_memmap_install - Install a new EFI memory map in efi.memmap * @data: efi memmap installation parameters * * Unlike efi_memmap_init_*(), this function does not allow the caller * to switch from early to late mappings. It simply uses the existing * mapping function and installs the new memmap. * * Returns zero on success, a negative error code on failure. */ int __init efi_memmap_install(struct efi_memory_map_data *data) { … } /** * efi_memmap_split_count - Count number of additional EFI memmap entries * @md: EFI memory descriptor to split * @range: Address range (start, end) to split around * * Returns the number of additional EFI memmap entries required to * accommodate @range. */ int __init efi_memmap_split_count(efi_memory_desc_t *md, struct range *range) { … } /** * efi_memmap_insert - Insert a memory region in an EFI memmap * @old_memmap: The existing EFI memory map structure * @buf: Address of buffer to store new map * @mem: Memory map entry to insert * * It is suggested that you call efi_memmap_split_count() first * to see how large @buf needs to be. */ void __init efi_memmap_insert(struct efi_memory_map *old_memmap, void *buf, struct efi_mem_range *mem) { … }