iPXE
efi_fdt.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2019 Michael Brown <mbrown@fensystems.co.uk>.
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License as
00006  * published by the Free Software Foundation; either version 2 of the
00007  * License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017  * 02110-1301, USA.
00018  *
00019  * You can also choose to distribute this program under the terms of
00020  * the Unmodified Binary Distribution Licence (as given in the file
00021  * COPYING.UBDL), provided that you have satisfied its requirements.
00022  */
00023 
00024 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00025 
00026 #include <string.h>
00027 #include <ipxe/fdt.h>
00028 #include <ipxe/efi/efi.h>
00029 #include <ipxe/init.h>
00030 
00031 /** @file
00032  *
00033  * EFI Flattened Device Tree
00034  *
00035  */
00036 
00037 #define DEVICE_TREE_TABLE_GUID                                          \
00038         { 0xb1b621d5, 0xf19c, 0x41a5,                                   \
00039           { 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0 } }
00040 
00041 /** EFI Flattened Device Tree configuration table */
00042 static struct fdt_header *efi_fdt;
00043 EFI_USE_TABLE ( DEVICE_TREE_TABLE, &efi_fdt, 0 );
00044 
00045 /**
00046  * Initialise EFI Flattened Device Tree
00047  *
00048  */
00049 static void efi_fdt_init ( void ) {
00050         int rc;
00051 
00052         /* Do nothing if no configuration table is present */
00053         if ( ! efi_fdt ) {
00054                 DBGC ( &efi_fdt, "EFIFDT has no configuration table\n" );
00055                 return;
00056         }
00057         DBGC ( &efi_fdt, "EFIFDT configuration table at %p\n", efi_fdt );
00058 
00059         /* Register device tree */
00060         if ( ( rc = register_fdt ( efi_fdt ) ) != 0 ) {
00061                 DBGC ( &efi_fdt, "EFIFDT could not register: %s\n",
00062                        strerror ( rc ) );
00063                 return;
00064         }
00065 }
00066 
00067 /** EFI Flattened Device Tree initialisation function */
00068 struct init_fn efi_fdt_init_fn __init_fn ( INIT_EARLY ) = {
00069         .initialise = efi_fdt_init,
00070 };