[coreboot] New patch to review for coreboot: 0b24054 Add ability to pass FDT to the payload.

Stefan Reinauer (stefan.reinauer@coreboot.org) gerrit at coreboot.org
Fri Mar 2 23:01:58 CET 2012


Stefan Reinauer (stefan.reinauer at coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/700

-gerrit

commit 0b24054475ba985cf3e6d50410d2fdf3dc3624ac
Author: Vadim Bendebury <vbendeb at chromium.org>
Date:   Thu Aug 11 15:49:52 2011 -0700

    Add ability to pass FDT to the payload.
    
    When configured, try to find the binary FDT in the CBFS and
    include it into the coreboot table as one of the sections.
    
    The default FDT file name 'u-boot.dtb' can be changed through a
    config dialog. In the spirit of coreboot no check is made if the
    FDT indeed fits into the coreboot table, this check might be
    added if deemed necessary.
    
    Change-Id: I50893c9acbea33e50a8e116f48d6383f8f1c0958
    Signed-off-by: Vadim Bendebury <vbendeb at chromium.org>
---
 src/Kconfig                        |   16 ++++++++++++++
 src/arch/x86/boot/coreboot_table.c |   40 +++++++++++++++++++++++++++++++++++-
 src/include/boot/coreboot_tables.h |   25 ++++++++++++++++++++++
 src/include/cbfs_core.h            |    2 +-
 src/include/fdt/libfdt_env.h       |    4 +--
 5 files changed, 82 insertions(+), 5 deletions(-)

diff --git a/src/Kconfig b/src/Kconfig
index c165d93..0dc66a3 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -112,6 +112,22 @@ config INCLUDE_CONFIG_FILE
   help
     Include in CBFS the coreboot config file that was used to compile the ROM image
 
+config ADD_FDT
+	bool "Add FDT to the coreboot table"
+	default n
+	help
+	  Make coreboot look for the Flat Device Tree (FDT) in CBFS and once
+	  found insert the device tree into the coreboot table (potentially
+	  modifying the tree as needed). The FDT is used by the payload.
+
+config FDT_FILE_NAME
+	depends on ADD_FDT
+	string "Name of the CBFS file containing the compiled FDT"
+	default "u-boot.dtb"
+	help
+	  Name of the CBFS file containing the binary representation of the
+	  device tree to be optionally modified and passed to the payload.
+
 endmenu
 
 source src/mainboard/Kconfig
diff --git a/src/arch/x86/boot/coreboot_table.c b/src/arch/x86/boot/coreboot_table.c
index 78ff97d..fc861a4 100644
--- a/src/arch/x86/boot/coreboot_table.c
+++ b/src/arch/x86/boot/coreboot_table.c
@@ -33,6 +33,10 @@
 #include <option_table.h>
 #include <cbfs.h>
 #endif
+#if (CONFIG_ADD_FDT == 1)
+#include <fdt/fdt.h>
+#include <fdt/libfdt_env.h>
+#endif
 
 static struct lb_header *lb_table_init(unsigned long addr)
 {
@@ -174,6 +178,34 @@ static void lb_framebuffer(struct lb_header *header)
 #endif
 }
 
+#ifdef CONFIG_ADD_FDT
+static void lb_fdt(struct lb_header *header)
+{
+	struct lb_fdt *fdt_record;
+	struct fdt_header *fdt_header;
+	u32 magic, fdt_size;
+
+	fdt_header = cbfs_find_file(CONFIG_FDT_FILE_NAME, CBFS_TYPE_FDT);
+	if (!fdt_header) {
+		printk(BIOS_ERR, "Can't find FDT (%s)\n", CONFIG_FDT_FILE_NAME);
+		return;
+	}
+
+	magic = fdt32_to_cpu(fdt_header->magic);
+	if (magic != FDT_MAGIC) {
+		printk(BIOS_ERR, "FDT header corrupted (0x%x)\n", magic);
+		return;
+	}
+
+	fdt_size = fdt32_to_cpu(fdt_header->totalsize);
+	fdt_record = (struct lb_fdt *) lb_new_record(header);
+	fdt_record->tag = LB_TAG_FDT;
+	fdt_record->size = sizeof(*fdt_record) + fdt_size;
+	memcpy(fdt_record + 1, fdt_header, fdt_size);
+	printk(BIOS_SPEW, "FDT of %d bytes added\n", fdt_size);
+}
+#endif
+
 static struct lb_mainboard *lb_mainboard(struct lb_header *header)
 {
 	struct lb_record *rec;
@@ -617,7 +649,13 @@ unsigned long write_coreboot_table(
 	lb_strings(head);
 	/* Record our framebuffer */
 	lb_framebuffer(head);
-
+#ifdef CONFIG_ADD_FDT
+	/*
+	 * Copy FDT from CBFS into the coreboot table possibly augmenting it
+	 * along the way.
+	 */
+	lb_fdt(head);
+#endif
 	/* Remember where my valid memory ranges are */
 	return lb_table_fini(head, 1);
 
diff --git a/src/include/boot/coreboot_tables.h b/src/include/boot/coreboot_tables.h
index 45ba3af..d32aa62 100644
--- a/src/include/boot/coreboot_tables.h
+++ b/src/include/boot/coreboot_tables.h
@@ -195,6 +195,31 @@ struct lb_framebuffer {
 	uint8_t reserved_mask_size;
 };
 
+#define LB_TAG_GPIO	0x0013
+
+struct lb_gpio {
+	uint32_t port;
+	uint32_t polarity;
+	uint32_t value;
+#define GPIO_MAX_NAME_LENGTH 16
+        uint8_t name[GPIO_MAX_NAME_LENGTH];
+};
+
+struct lb_gpios {
+	uint32_t tag;
+	uint32_t size;
+
+	uint32_t count;
+	struct lb_gpio gpios[0];
+};
+
+#define LB_TAG_FDT	0x0014
+struct lb_fdt {
+	uint32_t tag;
+	uint32_t size;		     /* size of the entire entry */
+	/* the actual FDT gets placed here */
+};
+
 /* The following structures are for the cmos definitions table */
 #define LB_TAG_CMOS_OPTION_TABLE 200
 /* cmos header record */
diff --git a/src/include/cbfs_core.h b/src/include/cbfs_core.h
index 70368f8..f9029c0 100644
--- a/src/include/cbfs_core.h
+++ b/src/include/cbfs_core.h
@@ -72,7 +72,7 @@
 #define CBFS_TYPE_MICROCODE  0x53
 #define CBFS_COMPONENT_CMOS_DEFAULT 0xaa
 #define CBFS_COMPONENT_CMOS_LAYOUT 0x01aa
-
+#define CBFS_TYPE_FDT       0xac
 
 /** this is the master cbfs header - it need to be
     located somewhere in the bootblock.  Where it
diff --git a/src/include/fdt/libfdt_env.h b/src/include/fdt/libfdt_env.h
index bf63583..755a5a6 100644
--- a/src/include/fdt/libfdt_env.h
+++ b/src/include/fdt/libfdt_env.h
@@ -21,9 +21,7 @@
 #ifndef _LIBFDT_ENV_H
 #define _LIBFDT_ENV_H
 
-#include "compiler.h"
-
-extern struct fdt_header *working_fdt;  /* Pointer to the working fdt */
+#include <arch/byteorder.h>
 
 #define fdt32_to_cpu(x)		be32_to_cpu(x)
 #define cpu_to_fdt32(x)		cpu_to_be32(x)




More information about the coreboot mailing list