summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorHeinrich Schuchardt <xypron.glpk@gmx.de>2020-12-13 10:30:24 +0100
committerHeinrich Schuchardt <xypron.glpk@gmx.de>2021-01-13 02:38:01 +0100
commit94686f60a2b9fd87842f473a5cdca316668765c3 (patch)
tree905db732cbefd6c43c31e29d1ed08adc2eeed350 /cmd
parent48618e9b8b2a09486983a60efc7402f5d136f992 (diff)
efi_loader: implement EFI_DT_FIXUP_PROTOCOL
A boot manager like GRUB can use the protocol to * apply U-Boot's fix-ups to the a device-tree * let U-Boot make memory reservations according to the device-tree * install the device-tree as a configuration table Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/bootefi.c80
-rw-r--r--cmd/efidebug.c5
2 files changed, 5 insertions, 80 deletions
diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 8fa4a1c287..fe70eec625 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -212,86 +212,6 @@ done:
}
/**
- * efi_reserve_memory() - add reserved memory to memory map
- *
- * @addr: start address of the reserved memory range
- * @size: size of the reserved memory range
- * @nomap: indicates that the memory range shall not be accessed by the
- * UEFI payload
- */
-static void efi_reserve_memory(u64 addr, u64 size, bool nomap)
-{
- int type;
- efi_uintn_t ret;
-
- /* Convert from sandbox address space. */
- addr = (uintptr_t)map_sysmem(addr, 0);
-
- if (nomap)
- type = EFI_RESERVED_MEMORY_TYPE;
- else
- type = EFI_BOOT_SERVICES_DATA;
-
- ret = efi_add_memory_map(addr, size, type);
- if (ret != EFI_SUCCESS)
- log_err("Reserved memory mapping failed addr %llx size %llx\n",
- addr, size);
-}
-
-/**
- * efi_carve_out_dt_rsv() - Carve out DT reserved memory ranges
- *
- * The mem_rsv entries of the FDT are added to the memory map. Any failures are
- * ignored because this is not critical and we would rather continue to try to
- * boot.
- *
- * @fdt: Pointer to device tree
- */
-static void efi_carve_out_dt_rsv(void *fdt)
-{
- int nr_rsv, i;
- u64 addr, size;
- int nodeoffset, subnode;
-
- nr_rsv = fdt_num_mem_rsv(fdt);
-
- /* Look for an existing entry and add it to the efi mem map. */
- for (i = 0; i < nr_rsv; i++) {
- if (fdt_get_mem_rsv(fdt, i, &addr, &size) != 0)
- continue;
- efi_reserve_memory(addr, size, false);
- }
-
- /* process reserved-memory */
- nodeoffset = fdt_subnode_offset(fdt, 0, "reserved-memory");
- if (nodeoffset >= 0) {
- subnode = fdt_first_subnode(fdt, nodeoffset);
- while (subnode >= 0) {
- fdt_addr_t fdt_addr;
- fdt_size_t fdt_size;
-
- /* check if this subnode has a reg property */
- fdt_addr = fdtdec_get_addr_size_auto_parent(
- fdt, nodeoffset, subnode,
- "reg", 0, &fdt_size, false);
- /*
- * The /reserved-memory node may have children with
- * a size instead of a reg property.
- */
- if (fdt_addr != FDT_ADDR_T_NONE &&
- fdtdec_get_is_enabled(fdt, subnode)) {
- bool nomap;
-
- nomap = !!fdt_getprop(fdt, subnode, "no-map",
- NULL);
- efi_reserve_memory(fdt_addr, fdt_size, nomap);
- }
- subnode = fdt_next_subnode(fdt, subnode);
- }
- }
-}
-
-/**
* get_config_table() - get configuration table
*
* @guid: GUID of the configuration table
diff --git a/cmd/efidebug.c b/cmd/efidebug.c
index 5fb7b1e3c6..6de81cab00 100644
--- a/cmd/efidebug.c
+++ b/cmd/efidebug.c
@@ -8,6 +8,7 @@
#include <charset.h>
#include <common.h>
#include <command.h>
+#include <efi_dt_fixup.h>
#include <efi_loader.h>
#include <efi_rng.h>
#include <exports.h>
@@ -495,6 +496,10 @@ static const struct {
"PXE Base Code",
EFI_PXE_BASE_CODE_PROTOCOL_GUID,
},
+ {
+ "Device-Tree Fixup",
+ EFI_DT_FIXUP_PROTOCOL_GUID,
+ },
/* Configuration table GUIDs */
{
"ACPI table",