Lines Matching +full:existing +full:- +full:parts
1 // SPDX-License-Identifier: GPL-2.0
50 * efi_memmap_alloc - Allocate memory for the EFI memory map
63 WARN_ON(data->phys_map || data->size); in efi_memmap_alloc()
65 data->size = num_entries * efi.memmap.desc_size; in efi_memmap_alloc()
66 data->desc_version = efi.memmap.desc_version; in efi_memmap_alloc()
67 data->desc_size = efi.memmap.desc_size; in efi_memmap_alloc()
68 data->flags &= ~(EFI_MEMMAP_SLAB | EFI_MEMMAP_MEMBLOCK); in efi_memmap_alloc()
69 data->flags |= efi.memmap.flags & EFI_MEMMAP_LATE; in efi_memmap_alloc()
72 data->flags |= EFI_MEMMAP_SLAB; in efi_memmap_alloc()
73 data->phys_map = __efi_memmap_alloc_late(data->size); in efi_memmap_alloc()
75 data->flags |= EFI_MEMMAP_MEMBLOCK; in efi_memmap_alloc()
76 data->phys_map = __efi_memmap_alloc_early(data->size); in efi_memmap_alloc()
79 if (!data->phys_map) in efi_memmap_alloc()
80 return -ENOMEM; in efi_memmap_alloc()
85 * efi_memmap_install - Install a new EFI memory map in efi.memmap
89 * to switch from early to late mappings. It simply uses the existing
115 * efi_memmap_split_count - Count number of additional EFI memmap entries
128 start = md->phys_addr; in efi_memmap_split_count()
129 end = start + (md->num_pages << EFI_PAGE_SHIFT) - 1; in efi_memmap_split_count()
132 m_start = range->start; in efi_memmap_split_count()
133 m_end = range->end; in efi_memmap_split_count()
136 /* split into 2 parts */ in efi_memmap_split_count()
142 /* split into 3 parts */ in efi_memmap_split_count()
145 /* split into 2 parts */ in efi_memmap_split_count()
154 * efi_memmap_insert - Insert a memory region in an EFI memmap
155 * @old_memmap: The existing EFI memory map structure
171 m_start = mem->range.start; in efi_memmap_insert()
172 m_end = mem->range.end; in efi_memmap_insert()
173 m_attr = mem->attribute; in efi_memmap_insert()
186 for (old = old_memmap->map, new = buf; in efi_memmap_insert()
187 old < old_memmap->map_end; in efi_memmap_insert()
188 old += old_memmap->desc_size, new += old_memmap->desc_size) { in efi_memmap_insert()
191 memcpy(new, old, old_memmap->desc_size); in efi_memmap_insert()
193 start = md->phys_addr; in efi_memmap_insert()
194 end = md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT) - 1; in efi_memmap_insert()
197 md->attribute |= m_attr; in efi_memmap_insert()
202 md->attribute |= m_attr; in efi_memmap_insert()
203 md->num_pages = (m_end - md->phys_addr + 1) >> in efi_memmap_insert()
206 new += old_memmap->desc_size; in efi_memmap_insert()
207 memcpy(new, old, old_memmap->desc_size); in efi_memmap_insert()
209 md->phys_addr = m_end + 1; in efi_memmap_insert()
210 md->num_pages = (end - md->phys_addr + 1) >> in efi_memmap_insert()
216 md->num_pages = (m_start - md->phys_addr) >> in efi_memmap_insert()
219 new += old_memmap->desc_size; in efi_memmap_insert()
220 memcpy(new, old, old_memmap->desc_size); in efi_memmap_insert()
222 md->attribute |= m_attr; in efi_memmap_insert()
223 md->phys_addr = m_start; in efi_memmap_insert()
224 md->num_pages = (m_end - m_start + 1) >> in efi_memmap_insert()
227 new += old_memmap->desc_size; in efi_memmap_insert()
228 memcpy(new, old, old_memmap->desc_size); in efi_memmap_insert()
230 md->phys_addr = m_end + 1; in efi_memmap_insert()
231 md->num_pages = (end - m_end) >> in efi_memmap_insert()
238 md->num_pages = (m_start - md->phys_addr) >> in efi_memmap_insert()
241 new += old_memmap->desc_size; in efi_memmap_insert()
242 memcpy(new, old, old_memmap->desc_size); in efi_memmap_insert()
244 md->phys_addr = m_start; in efi_memmap_insert()
245 md->num_pages = (end - md->phys_addr + 1) >> in efi_memmap_insert()
247 md->attribute |= m_attr; in efi_memmap_insert()