Lines Matching +full:existing +full:- +full:parts

1 // SPDX-License-Identifier: GPL-2.0
49 * efi_memmap_alloc - Allocate memory for the EFI memory map
62 WARN_ON(data->phys_map || data->size); in efi_memmap_alloc()
64 data->size = num_entries * efi.memmap.desc_size; in efi_memmap_alloc()
65 data->desc_version = efi.memmap.desc_version; in efi_memmap_alloc()
66 data->desc_size = efi.memmap.desc_size; in efi_memmap_alloc()
67 data->flags &= ~(EFI_MEMMAP_SLAB | EFI_MEMMAP_MEMBLOCK); in efi_memmap_alloc()
68 data->flags |= efi.memmap.flags & EFI_MEMMAP_LATE; in efi_memmap_alloc()
71 data->flags |= EFI_MEMMAP_SLAB; in efi_memmap_alloc()
72 data->phys_map = __efi_memmap_alloc_late(data->size); in efi_memmap_alloc()
74 data->flags |= EFI_MEMMAP_MEMBLOCK; in efi_memmap_alloc()
75 data->phys_map = __efi_memmap_alloc_early(data->size); in efi_memmap_alloc()
78 if (!data->phys_map) in efi_memmap_alloc()
79 return -ENOMEM; in efi_memmap_alloc()
84 * efi_memmap_install - Install a new EFI memory map in efi.memmap
88 * to switch from early to late mappings. It simply uses the existing
104 * efi_memmap_split_count - Count number of additional EFI memmap entries
117 start = md->phys_addr; in efi_memmap_split_count()
118 end = start + (md->num_pages << EFI_PAGE_SHIFT) - 1; in efi_memmap_split_count()
121 m_start = range->start; in efi_memmap_split_count()
122 m_end = range->end; in efi_memmap_split_count()
125 /* split into 2 parts */ in efi_memmap_split_count()
131 /* split into 3 parts */ in efi_memmap_split_count()
134 /* split into 2 parts */ in efi_memmap_split_count()
143 * efi_memmap_insert - Insert a memory region in an EFI memmap
144 * @old_memmap: The existing EFI memory map structure
160 m_start = mem->range.start; in efi_memmap_insert()
161 m_end = mem->range.end; in efi_memmap_insert()
162 m_attr = mem->attribute; in efi_memmap_insert()
175 for (old = old_memmap->map, new = buf; in efi_memmap_insert()
176 old < old_memmap->map_end; in efi_memmap_insert()
177 old += old_memmap->desc_size, new += old_memmap->desc_size) { in efi_memmap_insert()
180 memcpy(new, old, old_memmap->desc_size); in efi_memmap_insert()
182 start = md->phys_addr; in efi_memmap_insert()
183 end = md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT) - 1; in efi_memmap_insert()
186 md->attribute |= m_attr; in efi_memmap_insert()
191 md->attribute |= m_attr; in efi_memmap_insert()
192 md->num_pages = (m_end - md->phys_addr + 1) >> in efi_memmap_insert()
195 new += old_memmap->desc_size; in efi_memmap_insert()
196 memcpy(new, old, old_memmap->desc_size); in efi_memmap_insert()
198 md->phys_addr = m_end + 1; in efi_memmap_insert()
199 md->num_pages = (end - md->phys_addr + 1) >> in efi_memmap_insert()
205 md->num_pages = (m_start - md->phys_addr) >> in efi_memmap_insert()
208 new += old_memmap->desc_size; in efi_memmap_insert()
209 memcpy(new, old, old_memmap->desc_size); in efi_memmap_insert()
211 md->attribute |= m_attr; in efi_memmap_insert()
212 md->phys_addr = m_start; in efi_memmap_insert()
213 md->num_pages = (m_end - m_start + 1) >> in efi_memmap_insert()
216 new += old_memmap->desc_size; in efi_memmap_insert()
217 memcpy(new, old, old_memmap->desc_size); in efi_memmap_insert()
219 md->phys_addr = m_end + 1; in efi_memmap_insert()
220 md->num_pages = (end - m_end) >> in efi_memmap_insert()
227 md->num_pages = (m_start - md->phys_addr) >> in efi_memmap_insert()
230 new += old_memmap->desc_size; in efi_memmap_insert()
231 memcpy(new, old, old_memmap->desc_size); in efi_memmap_insert()
233 md->phys_addr = m_start; in efi_memmap_insert()
234 md->num_pages = (end - md->phys_addr + 1) >> in efi_memmap_insert()
236 md->attribute |= m_attr; in efi_memmap_insert()