[coreboot] Patch set updated for coreboot: 710fe3b Initialize CBMEM early.

Stefan Reinauer (stefan.reinauer@coreboot.org) gerrit at coreboot.org
Thu Mar 8 21:47:25 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/711

-gerrit

commit 710fe3bd556cc9de1e7067a4ca22e19b97475b1b
Author: Vadim Bendebury <vbendeb at chromium.org>
Date:   Tue Sep 20 17:07:14 2011 -0700

    Initialize CBMEM early.
    
    We want to be able to share data between different phases of firmware
    (rom stage/ram stage/payload). Coreboot CBMEM seems an appropriate
    location for this data, but normally it is not initialized
    until coreboot reaches the ram stage.
    
    This change initializes the CBMEM while still in rom stage in
    case CONFIG_EARLY_CBMEM_INIT is set.
    
    Note that there is a discrepancy in how coreboot determines the
    size of DRAM at rom and ram stages, get_top_of_ram() is used at
    rom stage and is not defined for all platforms. Those platforms
    will have to define this function should they enable the
    CONFIG_EARLY_CBMEM_INIT flag.
    
    Change-Id: I81691d45e28de59496fb227f2cca4e8c15ece717
    Signed-off-by: Vadim Bendebury <vbendeb at chromium.org>
---
 src/include/cbmem.h |    4 +++-
 src/lib/cbmem.c     |   39 +++++++++++++++++++++++----------------
 2 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/src/include/cbmem.h b/src/include/cbmem.h
index 9806854..a681c36 100644
--- a/src/include/cbmem.h
+++ b/src/include/cbmem.h
@@ -22,7 +22,9 @@
 
 /* Reserve 128k for ACPI and other tables */
 #define HIGH_MEMORY_DEF_SIZE	( 128 * 1024 )
+#ifndef __PRE_RAM__
 extern uint64_t high_tables_base, high_tables_size;
+#endif
 
 #if CONFIG_HAVE_ACPI_RESUME
 #define HIGH_MEMORY_SIZE	((CONFIG_RAMTOP - CONFIG_RAMBASE) + HIGH_MEMORY_DEF_SIZE)
@@ -41,7 +43,7 @@ extern uint64_t high_tables_base, high_tables_size;
 #define CBMEM_ID_SMBIOS         0x534d4254
 #define CBMEM_ID_NONE		0x00000000
 
-void cbmem_initialize(void);
+int cbmem_initialize(void);
 
 void cbmem_init(u64 baseaddr, u64 size);
 int cbmem_reinit(u64 baseaddr);
diff --git a/src/lib/cbmem.c b/src/lib/cbmem.c
index 202f521..f5c3d3a 100644
--- a/src/lib/cbmem.c
+++ b/src/lib/cbmem.c
@@ -183,30 +183,38 @@ void *cbmem_find(u32 id)
 	return (void *)NULL;
 }
 
-#ifndef __PRE_RAM__
-#if CONFIG_HAVE_ACPI_RESUME
+#if CONFIG_HAVE_ACPI_RESUME && !defined(__PRE_RAM__)
 extern u8 acpi_slp_type;
 #endif
 
-void cbmem_initialize(void)
+#if CONFIG_EARLY_CBMEM_INIT || !defined(__PRE_RAM__)
+/* Returns True if it was not intialized before. */
+int cbmem_initialize(void)
 {
-#if CONFIG_HAVE_ACPI_RESUME
-	printk(BIOS_DEBUG, "%s: acpi_slp_type=%d\n", __func__, acpi_slp_type);
-	if (acpi_slp_type == 3 || acpi_slp_type == 2) {
-		if (!cbmem_reinit(high_tables_base)) {
-			printk(BIOS_DEBUG, "cbmem_reinit failed\n");
-			/* Something went wrong, our high memory area got wiped */
+	int rv = 0;
+
+#ifdef __PRE_RAM__
+	extern unsigned long get_top_of_ram(void);
+	uint64_t high_tables_base = get_top_of_ram() - HIGH_MEMORY_SIZE;
+	uint64_t high_tables_size = HIGH_MEMORY_SIZE;
+#endif
+
+	/* We expect the romstage to always initialize it. */
+	if (!cbmem_reinit(high_tables_base)) {
+#if CONFIG_HAVE_ACPI_RESUME && !defined(__PRE_RAM__)
+		/* Something went wrong, our high memory area got wiped */
+		if (acpi_slp_type == 3 || acpi_slp_type == 2)
 			acpi_slp_type = 0;
-			cbmem_init(high_tables_base, high_tables_size);
-		}
-	} else {
+#endif
 		cbmem_init(high_tables_base, high_tables_size);
+		rv = 1;
 	}
-#else
-	cbmem_init(high_tables_base, high_tables_size);
-#endif
+#ifndef __PRE_RAM__
 	cbmem_arch_init();
+#endif
+	return rv;
 }
+#endif
 
 #ifndef __PRE_RAM__
 void cbmem_list(void)
@@ -240,5 +248,4 @@ void cbmem_list(void)
 }
 #endif
 
-#endif
 




More information about the coreboot mailing list