summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brown2019-07-19 18:42:12 +0200
committerMichael Brown2019-07-19 18:43:02 +0200
commit6dde0f60bfab458208a763532c9e776b32deebb3 (patch)
treebfdc8572efda017b9312d7907abecc59c1f3279d
parent[fdt] Add ability to parse a MAC address from a flattened device tree (diff)
downloadipxe-6dde0f60bfab458208a763532c9e776b32deebb3.tar.gz
ipxe-6dde0f60bfab458208a763532c9e776b32deebb3.tar.xz
ipxe-6dde0f60bfab458208a763532c9e776b32deebb3.zip
[efi] Register a device tree if provided by the platform firmware
Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r--src/config/config_fdt.c3
-rw-r--r--src/config/defaults/efi.h1
-rw-r--r--src/interface/efi/efi_fdt.c70
3 files changed, 74 insertions, 0 deletions
diff --git a/src/config/config_fdt.c b/src/config/config_fdt.c
index 85d62ace..e8d42593 100644
--- a/src/config/config_fdt.c
+++ b/src/config/config_fdt.c
@@ -36,3 +36,6 @@ PROVIDE_REQUIRING_SYMBOL();
/*
* Drag in devicetree sources
*/
+#ifdef FDT_EFI
+REQUIRE_OBJECT ( efi_fdt );
+#endif
diff --git a/src/config/defaults/efi.h b/src/config/defaults/efi.h
index 74effa42..53a7a7b4 100644
--- a/src/config/defaults/efi.h
+++ b/src/config/defaults/efi.h
@@ -22,6 +22,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#define TIME_EFI
#define REBOOT_EFI
#define ACPI_EFI
+#define FDT_EFI
#define DOWNLOAD_PROTO_FILE /* Local filesystem access */
diff --git a/src/interface/efi/efi_fdt.c b/src/interface/efi/efi_fdt.c
new file mode 100644
index 00000000..cd3f109d
--- /dev/null
+++ b/src/interface/efi/efi_fdt.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2019 Michael Brown <mbrown@fensystems.co.uk>.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ * You can also choose to distribute this program under the terms of
+ * the Unmodified Binary Distribution Licence (as given in the file
+ * COPYING.UBDL), provided that you have satisfied its requirements.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
+
+#include <string.h>
+#include <ipxe/fdt.h>
+#include <ipxe/efi/efi.h>
+#include <ipxe/init.h>
+
+/** @file
+ *
+ * EFI Flattened Device Tree
+ *
+ */
+
+#define DEVICE_TREE_TABLE_GUID \
+ { 0xb1b621d5, 0xf19c, 0x41a5, \
+ { 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0 } }
+
+/** EFI Flattened Device Tree configuration table */
+static struct fdt_header *efi_fdt;
+EFI_USE_TABLE ( DEVICE_TREE_TABLE, &efi_fdt, 0 );
+
+/**
+ * Initialise EFI Flattened Device Tree
+ *
+ */
+static void efi_fdt_init ( void ) {
+ int rc;
+
+ /* Do nothing if no configuration table is present */
+ if ( ! efi_fdt ) {
+ DBGC ( &efi_fdt, "EFIFDT has no configuration table\n" );
+ return;
+ }
+ DBGC ( &efi_fdt, "EFIFDT configuration table at %p\n", efi_fdt );
+
+ /* Register device tree */
+ if ( ( rc = register_fdt ( efi_fdt ) ) != 0 ) {
+ DBGC ( &efi_fdt, "EFIFDT could not register: %s\n",
+ strerror ( rc ) );
+ return;
+ }
+}
+
+/** EFI Flattened Device Tree initialisation function */
+struct init_fn efi_fdt_init_fn __init_fn ( INIT_EARLY ) = {
+ .initialise = efi_fdt_init,
+};