Lines Matching +full:data +full:- +full:size

1 // SPDX-License-Identifier: GPL-2.0
16 static phys_addr_t __init __efi_memmap_alloc_early(unsigned long size) in __efi_memmap_alloc_early() argument
18 return memblock_phys_alloc(size, SMP_CACHE_BYTES); in __efi_memmap_alloc_early()
21 static phys_addr_t __init __efi_memmap_alloc_late(unsigned long size) in __efi_memmap_alloc_late() argument
23 unsigned int order = get_order(size); in __efi_memmap_alloc_late()
32 void __init __efi_memmap_free(u64 phys, unsigned long size, unsigned long flags) in __efi_memmap_free() argument
36 memblock_free_late(phys, size); in __efi_memmap_free()
38 memblock_free(phys, size); in __efi_memmap_free()
41 unsigned int order = get_order(size); in __efi_memmap_free()
55 * efi_memmap_alloc - Allocate memory for the EFI memory map
57 * @data: efi memmap installation parameters
66 struct efi_memory_map_data *data) in efi_memmap_alloc() argument
69 WARN_ON(data->phys_map || data->size); in efi_memmap_alloc()
71 data->size = num_entries * efi.memmap.desc_size; in efi_memmap_alloc()
72 data->desc_version = efi.memmap.desc_version; in efi_memmap_alloc()
73 data->desc_size = efi.memmap.desc_size; in efi_memmap_alloc()
74 data->flags &= ~(EFI_MEMMAP_SLAB | EFI_MEMMAP_MEMBLOCK); in efi_memmap_alloc()
75 data->flags |= efi.memmap.flags & EFI_MEMMAP_LATE; in efi_memmap_alloc()
78 data->flags |= EFI_MEMMAP_SLAB; in efi_memmap_alloc()
79 data->phys_map = __efi_memmap_alloc_late(data->size); in efi_memmap_alloc()
81 data->flags |= EFI_MEMMAP_MEMBLOCK; in efi_memmap_alloc()
82 data->phys_map = __efi_memmap_alloc_early(data->size); in efi_memmap_alloc()
85 if (!data->phys_map) in efi_memmap_alloc()
86 return -ENOMEM; in efi_memmap_alloc()
91 * __efi_memmap_init - Common code for mapping the EFI memory map
92 * @data: EFI memory map data
98 * During bootup EFI_MEMMAP_LATE in data->flags should be clear since we
105 static int __init __efi_memmap_init(struct efi_memory_map_data *data) in __efi_memmap_init() argument
113 phys_map = data->phys_map; in __efi_memmap_init()
115 if (data->flags & EFI_MEMMAP_LATE) in __efi_memmap_init()
116 map.map = memremap(phys_map, data->size, MEMREMAP_WB); in __efi_memmap_init()
118 map.map = early_memremap(phys_map, data->size); in __efi_memmap_init()
122 return -ENOMEM; in __efi_memmap_init()
125 /* NOP if data->flags & (EFI_MEMMAP_MEMBLOCK | EFI_MEMMAP_SLAB) == 0 */ in __efi_memmap_init()
128 map.phys_map = data->phys_map; in __efi_memmap_init()
129 map.nr_map = data->size / data->desc_size; in __efi_memmap_init()
130 map.map_end = map.map + data->size; in __efi_memmap_init()
132 map.desc_version = data->desc_version; in __efi_memmap_init()
133 map.desc_size = data->desc_size; in __efi_memmap_init()
134 map.flags = data->flags; in __efi_memmap_init()
144 * efi_memmap_init_early - Map the EFI memory map data structure
145 * @data: EFI memory map data
150 int __init efi_memmap_init_early(struct efi_memory_map_data *data) in efi_memmap_init_early() argument
155 data->flags = 0; in efi_memmap_init_early()
156 return __efi_memmap_init(data); in efi_memmap_init_early()
165 unsigned long size; in efi_memmap_unmap() local
167 size = efi.memmap.desc_size * efi.memmap.nr_map; in efi_memmap_unmap()
168 early_memunmap(efi.memmap.map, size); in efi_memmap_unmap()
178 * efi_memmap_init_late - Map efi.memmap with memremap()
180 * @size: Size in bytes of the new EFI memory map
200 int __init efi_memmap_init_late(phys_addr_t addr, unsigned long size) in efi_memmap_init_late() argument
202 struct efi_memory_map_data data = { in efi_memmap_init_late() local
204 .size = size, in efi_memmap_init_late()
219 data.desc_version = efi.memmap.desc_version; in efi_memmap_init_late()
220 data.desc_size = efi.memmap.desc_size; in efi_memmap_init_late()
222 return __efi_memmap_init(&data); in efi_memmap_init_late()
226 * efi_memmap_install - Install a new EFI memory map in efi.memmap
227 * @ctx: map allocation parameters (address, size, flags)
235 int __init efi_memmap_install(struct efi_memory_map_data *data) in efi_memmap_install() argument
239 return __efi_memmap_init(data); in efi_memmap_install()
243 * efi_memmap_split_count - Count number of additional EFI memmap entries
256 start = md->phys_addr; in efi_memmap_split_count()
257 end = start + (md->num_pages << EFI_PAGE_SHIFT) - 1; in efi_memmap_split_count()
260 m_start = range->start; in efi_memmap_split_count()
261 m_end = range->end; in efi_memmap_split_count()
282 * efi_memmap_insert - Insert a memory region in an EFI memmap
299 m_start = mem->range.start; in efi_memmap_insert()
300 m_end = mem->range.end; in efi_memmap_insert()
301 m_attr = mem->attribute; in efi_memmap_insert()
314 for (old = old_memmap->map, new = buf; in efi_memmap_insert()
315 old < old_memmap->map_end; in efi_memmap_insert()
316 old += old_memmap->desc_size, new += old_memmap->desc_size) { in efi_memmap_insert()
319 memcpy(new, old, old_memmap->desc_size); in efi_memmap_insert()
321 start = md->phys_addr; in efi_memmap_insert()
322 end = md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT) - 1; in efi_memmap_insert()
325 md->attribute |= m_attr; in efi_memmap_insert()
330 md->attribute |= m_attr; in efi_memmap_insert()
331 md->num_pages = (m_end - md->phys_addr + 1) >> in efi_memmap_insert()
334 new += old_memmap->desc_size; in efi_memmap_insert()
335 memcpy(new, old, old_memmap->desc_size); in efi_memmap_insert()
337 md->phys_addr = m_end + 1; in efi_memmap_insert()
338 md->num_pages = (end - md->phys_addr + 1) >> in efi_memmap_insert()
344 md->num_pages = (m_start - md->phys_addr) >> in efi_memmap_insert()
347 new += old_memmap->desc_size; in efi_memmap_insert()
348 memcpy(new, old, old_memmap->desc_size); in efi_memmap_insert()
350 md->attribute |= m_attr; in efi_memmap_insert()
351 md->phys_addr = m_start; in efi_memmap_insert()
352 md->num_pages = (m_end - m_start + 1) >> in efi_memmap_insert()
355 new += old_memmap->desc_size; in efi_memmap_insert()
356 memcpy(new, old, old_memmap->desc_size); in efi_memmap_insert()
358 md->phys_addr = m_end + 1; in efi_memmap_insert()
359 md->num_pages = (end - m_end) >> in efi_memmap_insert()
366 md->num_pages = (m_start - md->phys_addr) >> in efi_memmap_insert()
369 new += old_memmap->desc_size; in efi_memmap_insert()
370 memcpy(new, old, old_memmap->desc_size); in efi_memmap_insert()
372 md->phys_addr = m_start; in efi_memmap_insert()
373 md->num_pages = (end - md->phys_addr + 1) >> in efi_memmap_insert()
375 md->attribute |= m_attr; in efi_memmap_insert()