iPXE
efi_fdt.c
Go to the documentation of this file.
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 ) = {
70 };
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void(* initialise)(void)
Definition: init.h:15
struct init_fn efi_fdt_init_fn __init_fn(INIT_EARLY)
EFI Flattened Device Tree initialisation function.
Device tree header.
Definition: fdt.h:17
#define INIT_EARLY
Early initialisation.
Definition: init.h:28
static void efi_fdt_init(void)
Initialise EFI Flattened Device Tree.
Definition: efi_fdt.c:49
#define DBGC(...)
Definition: compiler.h:505
An initialisation function.
Definition: init.h:14
EFI_USE_TABLE(DEVICE_TREE_TABLE, &efi_fdt, 0)
static struct fdt_header * efi_fdt
EFI Flattened Device Tree configuration table.
Definition: efi_fdt.c:42
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
EFI API.
Flattened Device Tree.
String functions.
int register_fdt(const struct fdt_header *hdr)
Register device tree.
Definition: fdt.c:410