Permalink
Browse files

Treat additional region types as available memory

In order for the ia64 loader to find the memory map area occupied by the
kernel (a.k.a. ram_end), it needs to consider additioanl region types
which also denote available memory (after the call to ExitBootServices).
These are: EfiLoaderCode, EfiLoaderData, EfiBootServicesCode and
EfiBootServicesData. Without this the memory map is incomplete and
contains a big hole that covers the entire area of the loaded image. The
loader then cannot find ram_end and the boot fails. The memory map also
needs to be compacted so that adjacent regions of the same type are not
too small for a successful boot.
  • Loading branch information...
jermar committed Jan 1, 2019
1 parent 68f1254 commit e8d3165e8856d2a56f76fadb0a4095213144932f
Showing with 13 additions and 0 deletions.
  1. +13 −0 boot/arch/ia64/src/main.c
@@ -93,9 +93,22 @@ static void read_efi_memmap(void)
(items < MEMMAP_ITEMS);
cur += md_size) {
efi_v1_memdesc_t *md = (efi_v1_memdesc_t *) cur;
memmap_item_t *o = NULL;

if (items)
o = &memmap[items - 1];

switch ((efi_memory_type_t) md->type) {
case EFI_LOADER_CODE:
case EFI_LOADER_DATA:
case EFI_BOOT_SERVICES_CODE:
case EFI_BOOT_SERVICES_DATA:
case EFI_CONVENTIONAL_MEMORY:
if (o && o->type == MEMMAP_FREE_MEM &&
o->base + o->size == md->phys_start) {
o->size += md->pages * EFI_PAGE_SIZE;
continue;
}
memmap[items].type = MEMMAP_FREE_MEM;
break;
case EFI_MEMORY_MAPPED_IO:

0 comments on commit e8d3165

Please sign in to comment.