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_phys_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
65 struct efi_memory_map_data *data) in efi_memmap_alloc() argument
68 WARN_ON(data->phys_map || data->size); in efi_memmap_alloc()
70 data->size = num_entries * efi.memmap.desc_size; in efi_memmap_alloc()
71 data->desc_version = efi.memmap.desc_version; in efi_memmap_alloc()
72 data->desc_size = efi.memmap.desc_size; in efi_memmap_alloc()
73 data->flags &= ~(EFI_MEMMAP_SLAB | EFI_MEMMAP_MEMBLOCK); in efi_memmap_alloc()
74 data->flags |= efi.memmap.flags & EFI_MEMMAP_LATE; in efi_memmap_alloc()
77 data->flags |= EFI_MEMMAP_SLAB; in efi_memmap_alloc()
78 data->phys_map = __efi_memmap_alloc_late(data->size); in efi_memmap_alloc()
80 data->flags |= EFI_MEMMAP_MEMBLOCK; in efi_memmap_alloc()
81 data->phys_map = __efi_memmap_alloc_early(data->size); in efi_memmap_alloc()
84 if (!data->phys_map) in efi_memmap_alloc()
85 return -ENOMEM; in efi_memmap_alloc()
90 * __efi_memmap_init - Common code for mapping the EFI memory map
91 * @data: EFI memory map data
97 * During bootup EFI_MEMMAP_LATE in data->flags should be clear since we
104 static int __init __efi_memmap_init(struct efi_memory_map_data *data) in __efi_memmap_init() argument
112 phys_map = data->phys_map; in __efi_memmap_init()
114 if (data->flags & EFI_MEMMAP_LATE) in __efi_memmap_init()
115 map.map = memremap(phys_map, data->size, MEMREMAP_WB); in __efi_memmap_init()
117 map.map = early_memremap(phys_map, data->size); in __efi_memmap_init()
121 return -ENOMEM; in __efi_memmap_init()
124 /* NOP if data->flags & (EFI_MEMMAP_MEMBLOCK | EFI_MEMMAP_SLAB) == 0 */ in __efi_memmap_init()
127 map.phys_map = data->phys_map; in __efi_memmap_init()
128 map.nr_map = data->size / data->desc_size; in __efi_memmap_init()
129 map.map_end = map.map + data->size; in __efi_memmap_init()
131 map.desc_version = data->desc_version; in __efi_memmap_init()
132 map.desc_size = data->desc_size; in __efi_memmap_init()
133 map.flags = data->flags; in __efi_memmap_init()
143 * efi_memmap_init_early - Map the EFI memory map data structure
144 * @data: EFI memory map data
149 int __init efi_memmap_init_early(struct efi_memory_map_data *data) in efi_memmap_init_early() argument
154 data->flags = 0; in efi_memmap_init_early()
155 return __efi_memmap_init(data); in efi_memmap_init_early()
164 unsigned long size; in efi_memmap_unmap() local
166 size = efi.memmap.desc_size * efi.memmap.nr_map; in efi_memmap_unmap()
167 early_memunmap(efi.memmap.map, size); in efi_memmap_unmap()
177 * efi_memmap_init_late - Map efi.memmap with memremap()
179 * @size: Size in bytes of the new EFI memory map
199 int __init efi_memmap_init_late(phys_addr_t addr, unsigned long size) in efi_memmap_init_late() argument
201 struct efi_memory_map_data data = { in efi_memmap_init_late() local
203 .size = size, in efi_memmap_init_late()
218 data.desc_version = efi.memmap.desc_version; in efi_memmap_init_late()
219 data.desc_size = efi.memmap.desc_size; in efi_memmap_init_late()
221 return __efi_memmap_init(&data); in efi_memmap_init_late()
225 * efi_memmap_install - Install a new EFI memory map in efi.memmap
226 * @ctx: map allocation parameters (address, size, flags)
234 int __init efi_memmap_install(struct efi_memory_map_data *data) in efi_memmap_install() argument
238 return __efi_memmap_init(data); in efi_memmap_install()
242 * efi_memmap_split_count - Count number of additional EFI memmap entries
255 start = md->phys_addr; in efi_memmap_split_count()
256 end = start + (md->num_pages << EFI_PAGE_SHIFT) - 1; in efi_memmap_split_count()
259 m_start = range->start; in efi_memmap_split_count()
260 m_end = range->end; in efi_memmap_split_count()
281 * efi_memmap_insert - Insert a memory region in an EFI memmap
298 m_start = mem->range.start; in efi_memmap_insert()
299 m_end = mem->range.end; in efi_memmap_insert()
300 m_attr = mem->attribute; in efi_memmap_insert()
313 for (old = old_memmap->map, new = buf; in efi_memmap_insert()
314 old < old_memmap->map_end; in efi_memmap_insert()
315 old += old_memmap->desc_size, new += old_memmap->desc_size) { in efi_memmap_insert()
318 memcpy(new, old, old_memmap->desc_size); in efi_memmap_insert()
320 start = md->phys_addr; in efi_memmap_insert()
321 end = md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT) - 1; in efi_memmap_insert()
324 md->attribute |= m_attr; in efi_memmap_insert()
329 md->attribute |= m_attr; in efi_memmap_insert()
330 md->num_pages = (m_end - md->phys_addr + 1) >> in efi_memmap_insert()
333 new += old_memmap->desc_size; in efi_memmap_insert()
334 memcpy(new, old, old_memmap->desc_size); in efi_memmap_insert()
336 md->phys_addr = m_end + 1; in efi_memmap_insert()
337 md->num_pages = (end - md->phys_addr + 1) >> in efi_memmap_insert()
343 md->num_pages = (m_start - md->phys_addr) >> in efi_memmap_insert()
346 new += old_memmap->desc_size; in efi_memmap_insert()
347 memcpy(new, old, old_memmap->desc_size); in efi_memmap_insert()
349 md->attribute |= m_attr; in efi_memmap_insert()
350 md->phys_addr = m_start; in efi_memmap_insert()
351 md->num_pages = (m_end - m_start + 1) >> in efi_memmap_insert()
354 new += old_memmap->desc_size; in efi_memmap_insert()
355 memcpy(new, old, old_memmap->desc_size); in efi_memmap_insert()
357 md->phys_addr = m_end + 1; in efi_memmap_insert()
358 md->num_pages = (end - m_end) >> in efi_memmap_insert()
365 md->num_pages = (m_start - md->phys_addr) >> in efi_memmap_insert()
368 new += old_memmap->desc_size; in efi_memmap_insert()
369 memcpy(new, old, old_memmap->desc_size); in efi_memmap_insert()
371 md->phys_addr = m_start; in efi_memmap_insert()
372 md->num_pages = (end - md->phys_addr + 1) >> in efi_memmap_insert()
374 md->attribute |= m_attr; in efi_memmap_insert()