Sfoglia il codice sorgente

[efi] Register a device tree if provided by the platform firmware

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 5 anni fa
parent
commit
6dde0f60bf
3 ha cambiato i file con 74 aggiunte e 0 eliminazioni
  1. 3
    0
      src/config/config_fdt.c
  2. 1
    0
      src/config/defaults/efi.h
  3. 70
    0
      src/interface/efi/efi_fdt.c

+ 3
- 0
src/config/config_fdt.c Vedi File

@@ -36,3 +36,6 @@ PROVIDE_REQUIRING_SYMBOL();
36 36
 /*
37 37
  * Drag in devicetree sources
38 38
  */
39
+#ifdef FDT_EFI
40
+REQUIRE_OBJECT ( efi_fdt );
41
+#endif

+ 1
- 0
src/config/defaults/efi.h Vedi File

@@ -22,6 +22,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
22 22
 #define TIME_EFI
23 23
 #define REBOOT_EFI
24 24
 #define ACPI_EFI
25
+#define FDT_EFI
25 26
 
26 27
 #define DOWNLOAD_PROTO_FILE	/* Local filesystem access */
27 28
 

+ 70
- 0
src/interface/efi/efi_fdt.c Vedi File

@@ -0,0 +1,70 @@
1
+/*
2
+ * Copyright (C) 2019 Michael Brown <mbrown@fensystems.co.uk>.
3
+ *
4
+ * This program is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU General Public License as
6
+ * published by the Free Software Foundation; either version 2 of the
7
+ * License, or (at your option) any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful, but
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
+ * General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with this program; if not, write to the Free Software
16
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17
+ * 02110-1301, USA.
18
+ *
19
+ * You can also choose to distribute this program under the terms of
20
+ * the Unmodified Binary Distribution Licence (as given in the file
21
+ * COPYING.UBDL), provided that you have satisfied its requirements.
22
+ */
23
+
24
+FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
25
+
26
+#include <string.h>
27
+#include <ipxe/fdt.h>
28
+#include <ipxe/efi/efi.h>
29
+#include <ipxe/init.h>
30
+
31
+/** @file
32
+ *
33
+ * EFI Flattened Device Tree
34
+ *
35
+ */
36
+
37
+#define DEVICE_TREE_TABLE_GUID						\
38
+	{ 0xb1b621d5, 0xf19c, 0x41a5,					\
39
+	  { 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0 } }
40
+
41
+/** EFI Flattened Device Tree configuration table */
42
+static struct fdt_header *efi_fdt;
43
+EFI_USE_TABLE ( DEVICE_TREE_TABLE, &efi_fdt, 0 );
44
+
45
+/**
46
+ * Initialise EFI Flattened Device Tree
47
+ *
48
+ */
49
+static void efi_fdt_init ( void ) {
50
+	int rc;
51
+
52
+	/* Do nothing if no configuration table is present */
53
+	if ( ! efi_fdt ) {
54
+		DBGC ( &efi_fdt, "EFIFDT has no configuration table\n" );
55
+		return;
56
+	}
57
+	DBGC ( &efi_fdt, "EFIFDT configuration table at %p\n", efi_fdt );
58
+
59
+	/* Register device tree */
60
+	if ( ( rc = register_fdt ( efi_fdt ) ) != 0 ) {
61
+		DBGC ( &efi_fdt, "EFIFDT could not register: %s\n",
62
+		       strerror ( rc ) );
63
+		return;
64
+	}
65
+}
66
+
67
+/** EFI Flattened Device Tree initialisation function */
68
+struct init_fn efi_fdt_init_fn __init_fn ( INIT_EARLY ) = {
69
+	.initialise = efi_fdt_init,
70
+};

Loading…
Annulla
Salva