[coreboot-gerrit] New patch to review for coreboot: 4574079 riscv: use new-style CBFS header lookup

Patrick Georgi (pgeorgi@google.com) gerrit at coreboot.org
Fri Apr 17 22:59:14 CEST 2015


Patrick Georgi (pgeorgi at google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/9795

-gerrit

commit 45740797ae91af079dc5a889f57e38b272e0f479
Author: Patrick Georgi <patrick at georgi-clan.de>
Date:   Fri Apr 17 22:40:53 2015 +0200

    riscv: use new-style CBFS header lookup
    
    We recently restructured where the CBFS header is stored
    and how it is looked up, with less magic. The RISC-V port
    didn't get the memo, so have it follow the pack now.
    
    Change-Id: Ic27e3e7f9acd55027e357f2c4beddf960ea02c4d
    Signed-off-by: Patrick Georgi <patrick at georgi-clan.de>
---
 src/arch/riscv/bootblock.S | 19 -------------------
 src/arch/riscv/rom_media.c | 12 ++++++------
 2 files changed, 6 insertions(+), 25 deletions(-)

diff --git a/src/arch/riscv/bootblock.S b/src/arch/riscv/bootblock.S
index 1461a9c..8ddc8ec 100644
--- a/src/arch/riscv/bootblock.S
+++ b/src/arch/riscv/bootblock.S
@@ -58,25 +58,6 @@ _start:
 .stack_size:
 	.quad 0xf00
 
-.globl _cbfs_master_header
-_cbfs_master_header:
-	.balignl 16,0xdeadbeef
-	.align 8
-	// this assembler SUCKS
-	.long  0x4F524243
-	.long 0xdeadbeef
-	.long 0xdeadbeef
-	.long 0xdeadbeef
-	.long 0xdeadbeef
-	.long 0xdeadbeef
-	.long 0xdeadbeef
-	/* The CBFS master header is inserted by cbfstool at the first
-	 * aligned offset after the above anchor string is found.
-	 * Hence, we leave some space for it.
-	 * Assumes 64-byte alignment.
-	 */
-	.space 128
-
 reset:
 init_stack_loop:
 
diff --git a/src/arch/riscv/rom_media.c b/src/arch/riscv/rom_media.c
index 8e858cb..e00e0fb 100644
--- a/src/arch/riscv/rom_media.c
+++ b/src/arch/riscv/rom_media.c
@@ -60,12 +60,12 @@ static int rom_media_close(struct cbfs_media *media) {
 }
 
 static int init_rom_media_cbfs(struct cbfs_media *media) {
-	//extern unsigned long _cbfs_master_header;
-	// On X86, we always keep a reference of pointer to CBFS header in
-	// 0xfffffffc, and the pointer is still a memory-mapped address.
-	// Since the CBFS core always use ROM offset, we need to figure out
-	// header->romsize even before media is initialized.
-	struct cbfs_header *header = (struct cbfs_header*) CONFIG_CBFS_HEADER_ROM_OFFSET; //&_cbfs_master_header;
+	/* this assumes that the CBFS resides at 0x0,
+	 * which is true for the default configuration
+	 */
+	int32_t *cbfs_header_ptr = (int32_t*)(uintptr_t)(CONFIG_CBFS_SIZE - 4);
+	uint64_t cbfs_header_offset = CONFIG_CBFS_SIZE + *cbfs_header_ptr;
+	struct cbfs_header *header = (struct cbfs_header*) cbfs_header_offset;
 	if (CBFS_HEADER_MAGIC != ntohl(header->magic)) {
 		printk(BIOS_ERR, "Invalid CBFS master header at %p\n", header);
 		printk(BIOS_ERR, "Expected %08lx and got %08lx\n", (unsigned long) CBFS_HEADER_MAGIC, (unsigned long) ntohl(header->magic));



More information about the coreboot-gerrit mailing list