[PATCH RFC 05/14] efi: stub: add additional types of memory
Caleb Connolly
caleb.connolly at linaro.org
Sun Nov 24 21:27:01 CET 2024
U-Boot itself might be mapped as LOADER_CODE, there's also no reason not
to make additional pages accessible to the OS. This fixes an issue where
U-Boot can't run EFI apps because it gets relocated somewhere outside of
its own memory map.
Signed-off-by: Caleb Connolly <caleb.connolly at linaro.org>
---
lib/efi/efi_info.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/lib/efi/efi_info.c b/lib/efi/efi_info.c
index 3fa594b34b42..3754c913b54d 100644
--- a/lib/efi/efi_info.c
+++ b/lib/efi/efi_info.c
@@ -120,8 +120,28 @@ int of_populate_from_efi(struct device_node *root)
return ret;
}
+static bool efi_mem_type_is_usable(u32 type)
+{
+ switch (type) {
+ case EFI_CONVENTIONAL_MEMORY:
+ case EFI_LOADER_DATA:
+ case EFI_LOADER_CODE:
+ case EFI_BOOT_SERVICES_CODE:
+ return true;
+ case EFI_RESERVED_MEMORY_TYPE:
+ case EFI_UNUSABLE_MEMORY:
+ case EFI_UNACCEPTED_MEMORY_TYPE:
+ case EFI_RUNTIME_SERVICES_DATA:
+ case EFI_MMAP_IO:
+ case EFI_MMAP_IO_PORT:
+ case EFI_PERSISTENT_MEMORY_TYPE:
+ default:
+ return false;
+ }
+}
+
int dram_init_banksize_from_efi(void)
{
struct efi_mem_desc *desc, *end;
struct efi_entry_memmap *map;
@@ -142,10 +162,9 @@ int dram_init_banksize_from_efi(void)
/*
* We only use conventional memory and ignore
* anything less than 1MB.
*/
- if (desc->type != EFI_CONVENTIONAL_MEMORY ||
- (desc->num_pages << EFI_PAGE_SHIFT) < 1 << 20)
+ if (!efi_mem_type_is_usable(desc->type) || (desc->num_pages << EFI_PAGE_SHIFT) < 1 << 20)
continue;
gd->bd->bi_dram[num_banks].start = desc->physical_start;
gd->bd->bi_dram[num_banks].size = desc->num_pages <<
EFI_PAGE_SHIFT;
--
2.47.0
More information about the U-Boot
mailing list