[v2,2/4] efi_loader: use hardware device tree by default
diff mbox series

Message ID 20191208001742.60076-3-xypron.glpk@gmx.de
State Superseded, archived
Delegated to: Heinrich Schuchardt
Headers show
Series
  • efi_loader: prepare for FIT images
Related show

Commit Message

Heinrich Schuchardt Dec. 8, 2019, 12:17 a.m. UTC
If the bootefi command is called without passing the address of a device
tree, the internal device tree is used. For devices with a hardware device
tree it is preferable to used the hardware device tree in this case.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 cmd/bootefi.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

--
2.24.0

Patch
diff mbox series

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 2b190a3edd..a3e2a05126 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -200,14 +200,16 @@  static void *get_config_table(const efi_guid_t *guid)
  *
  * If fdt_addr is available, the device tree located at that memory address will
  * will be installed as configuration table, otherwise the device tree located
- * at the address indicated by environment variable fdtcontroladdr will be used.
+ * at the address indicated by environment variable fdt_addr or as fallback
+ * fdtcontroladdr will be used.
  *
  * On architectures using ACPI tables device trees shall not be installed as
  * configuration table.
  *
  * @fdt_addr:	address of device tree or EFI_FDT_USE_INTERNAL to use the
- *		internal device tree as indicated by environment variable
- *		fdtcontroladdr
+ *		the hardware device tree as indicated by environment variable
+ *		fdt_addr or as fallback the internal device tree as indicated by
+ *		the environment variable fdtcontroladdr
  * Return:	status code
  */
 static efi_status_t efi_install_fdt(uintptr_t fdt_addr)
@@ -232,15 +234,19 @@  static efi_status_t efi_install_fdt(uintptr_t fdt_addr)
 		/* Look for device tree that is already installed */
 		if (get_config_table(&efi_guid_fdt))
 			return EFI_SUCCESS;
-		/* Use our own device tree as default */
-		fdt_opt = env_get("fdtcontroladdr");
+		/* Check if there is a hardware device tree */
+		fdt_opt = env_get("fdt_addr");
+		/* Use our own device tree as fallback */
 		if (!fdt_opt) {
-			printf("ERROR: need device tree\n");
-			return EFI_NOT_FOUND;
+			fdt_opt = env_get("fdtcontroladdr");
+			if (!fdt_opt) {
+				printf("ERROR: need device tree\n");
+				return EFI_NOT_FOUND;
+			}
 		}
 		fdt_addr = simple_strtoul(fdt_opt, NULL, 16);
 		if (!fdt_addr) {
-			printf("ERROR: invalid $fdtcontroladdr\n");
+			printf("ERROR: invalid $fdt_addr or $fdtcontroladdr\n");
 			return EFI_LOAD_ERROR;
 		}
 	}