/** * 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(unsignedint num_entries, struct efi_memory_map_data *data)
{ /* Expect allocation parameters are zero initialized */
WARN_ON(data->phys_map || data->size);
/** * 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)
{ unsignedlong size = efi.memmap.desc_size * efi.memmap.nr_map; unsignedlong flags = efi.memmap.flags;
u64 phys = efi.memmap.phys_map; int ret;
efi_memmap_unmap();
if (efi_enabled(EFI_PARAVIRT)) return 0;
ret = __efi_memmap_init(data); if (ret) return ret;
__efi_memmap_free(phys, size, flags); return 0;
}
/** * 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)
{
u64 m_start, m_end;
u64 start, end; int count = 0;
/* modifying range */
m_start = range->start;
m_end = range->end;
if (m_start <= start) { /* split into 2 parts */ if (start < m_end && m_end < end)
count++;
}
if (start < m_start && m_start < end) { /* split into 3 parts */ if (m_end < end)
count += 2; /* split into 2 parts */ if (end <= m_end)
count++;
}
return count;
}
/** * 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)
{
u64 m_start, m_end, m_attr;
efi_memory_desc_t *md;
u64 start, end; void *old, *new;
/* * The EFI memory map deals with regions in EFI_PAGE_SIZE * units. Ensure that the region described by 'mem' is aligned * correctly.
*/ if (!IS_ALIGNED(m_start, EFI_PAGE_SIZE) ||
!IS_ALIGNED(m_end + 1, EFI_PAGE_SIZE)) {
WARN_ON(1); return;
}
for (old = old_memmap->map, new = buf;
old < old_memmap->map_end;
old += old_memmap->desc_size, new += old_memmap->desc_size) {
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.