[coreboot-gerrit] Patch set updated for coreboot: 4083c86 CBMEM: Support DYNAMIC_CBMEM with LATE_CBMEM_INIT

Kyösti Mälkki (kyosti.malkki@gmail.com) gerrit at coreboot.org
Thu Dec 18 20:54:32 CET 2014


Kyösti Mälkki (kyosti.malkki at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/7861

-gerrit

commit 4083c86314c3d26532fb01ace58a8a53a99804b0
Author: Kyösti Mälkki <kyosti.malkki at gmail.com>
Date:   Wed Dec 17 21:04:25 2014 +0200

    CBMEM: Support DYNAMIC_CBMEM with LATE_CBMEM_INIT
    
    We can now create CBMEM with dynamic allocation even if CBMEM
    location is resolved late in ramstage.
    
    Change-Id: I8529ccbcd4a0e567ebe0a46232ac5d16476e81a8
    Signed-off-by: Kyösti Mälkki <kyosti.malkki at gmail.com>
---
 src/Kconfig               |  3 +--
 src/arch/x86/boot/cbmem.c | 17 ++++++++++-------
 src/include/cbmem.h       |  2 +-
 src/lib/cbmem_console.c   |  2 +-
 src/lib/dynamic_cbmem.c   | 29 +++++++++++++++++++++++++++--
 5 files changed, 40 insertions(+), 13 deletions(-)

diff --git a/src/Kconfig b/src/Kconfig
index b94ccd2..374a3db 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -171,7 +171,6 @@ config BROKEN_CAR_MIGRATE
 config DYNAMIC_CBMEM
 	bool
 	default n
-	select EARLY_CBMEM_INIT
 	help
 	  Instead of reserving a static amount of CBMEM space the CBMEM
 	  area grows dynamically.  CBMEM can be used both in romstage (after
@@ -210,7 +209,7 @@ config RELOCATABLE_MODULES
 	 loaded anywhere and all the relocations are handled automatically.
 
 config RELOCATABLE_RAMSTAGE
-	depends on (RELOCATABLE_MODULES && DYNAMIC_CBMEM)
+	depends on (RELOCATABLE_MODULES && DYNAMIC_CBMEM && EARLY_CBMEM_INIT)
 	bool "Build the ramstage to be relocatable in 32-bit address space."
 	default n
 	help
diff --git a/src/arch/x86/boot/cbmem.c b/src/arch/x86/boot/cbmem.c
index 9f00e26..87f46fa 100644
--- a/src/arch/x86/boot/cbmem.c
+++ b/src/arch/x86/boot/cbmem.c
@@ -36,6 +36,9 @@ void get_cbmem_table(uint64_t *base, uint64_t *size)
 		*size = 0;
 	}
 }
+#endif /* !DYNAMIC_CBMEM */
+
+#if IS_ENABLED(CONFIG_LATE_CBMEM_INIT)
 
 #if !defined(__PRE_RAM__)
 void __attribute__((weak)) backup_top_of_ram(uint64_t ramtop)
@@ -43,26 +46,26 @@ void __attribute__((weak)) backup_top_of_ram(uint64_t ramtop)
 	/* Do nothing. Chipset may have implementation to save ramtop in NVRAM. */
 }
 
-/* This is for compatibility with old boards only. Any new chipset and board
- * must implement get_top_of_ram() for both romstage and ramstage to support
- * early features like COLLECT_TIMESTAMPS and CBMEM_CONSOLE.
- */
 void set_top_of_ram(uint64_t ramtop)
 {
 	backup_top_of_ram(ramtop);
+#if !CONFIG_DYNAMIC_CBMEM
 	cbmem_late_set_table(ramtop - HIGH_MEMORY_SIZE, HIGH_MEMORY_SIZE);
+#else
+	cbmem_set_top((void*)ramtop);
+#endif
 }
 #endif /* !__PRE_RAM__ */
 
-#if CONFIG_BROKEN_CAR_MIGRATE || !defined(__PRE_RAM__)
 unsigned long __attribute__((weak)) get_top_of_ram(void)
 {
 	printk(BIOS_WARNING, "WARNING: you need to define get_top_of_ram() for your chipset\n");
 	return 0;
 }
-#endif
 
-#else
+#endif /* LATE_CBMEM_INIT */
+
+#if CONFIG_DYNAMIC_CBMEM
 
 void *cbmem_top(void)
 {
diff --git a/src/include/cbmem.h b/src/include/cbmem.h
index 51ecff0..c709fe2 100644
--- a/src/include/cbmem.h
+++ b/src/include/cbmem.h
@@ -114,7 +114,7 @@ void cbmem_initialize_empty(void);
  * below 4GiB. */
 void *cbmem_top(void);
 
-void cbmem_set_top(uint64_t ramtop);
+void cbmem_set_top(void *ramtop);
 
 /* Add a cbmem entry of a given size and id. These return NULL on failure. The
  * add function performs a find first and do not check against the original
diff --git a/src/lib/cbmem_console.c b/src/lib/cbmem_console.c
index 16609e9..cc96c8d 100644
--- a/src/lib/cbmem_console.c
+++ b/src/lib/cbmem_console.c
@@ -55,7 +55,7 @@ extern struct cbmem_console preram_cbmem_console;
  * during the ROM stage, once CBMEM becomes available at RAM stage.
  */
 
-#if CONFIG_DYNAMIC_CBMEM
+#if IS_ENABLED(CONFIG_EARLY_CBMEM_INIT)
 #define STATIC_CONSOLE_SIZE 1024
 #else
 #define STATIC_CONSOLE_SIZE CONFIG_CONSOLE_CBMEM_BUFFER_SIZE
diff --git a/src/lib/dynamic_cbmem.c b/src/lib/dynamic_cbmem.c
index fbd6148..cec1df9 100644
--- a/src/lib/dynamic_cbmem.c
+++ b/src/lib/dynamic_cbmem.c
@@ -69,11 +69,18 @@ struct cbmem_root {
 } __attribute__((packed));
 
 
+#if !defined(__PRE_RAM__)
+static void *cached_cbmem_top;
+
+void cbmem_set_top(void * ramtop)
+{
+	cached_cbmem_top = ramtop;
+}
+#endif
+
 static inline void *cbmem_top_cached(void)
 {
 #if !defined(__PRE_RAM__)
-	static void *cached_cbmem_top;
-
 	if (cached_cbmem_top == NULL)
 		cached_cbmem_top = cbmem_top();
 
@@ -413,6 +420,8 @@ void *cbmem_entry_start(const struct cbmem_entry *entry)
 
 
 #if !defined(__PRE_RAM__)
+
+#if IS_ENABLED(CONFIG_EARLY_CBMEM_INIT)
 /* selected cbmem can be initialized early in ramstage. Additionally, that
  * means cbmem console can be reinitialized early as well. The post_device
  * function is empty since cbmem was initialized early in ramstage. */
@@ -426,6 +435,22 @@ BOOT_STATE_INIT_ENTRIES(cbmem_bscb) = {
 	                      init_cbmem_pre_device, NULL),
 };
 
+#else
+
+static void init_cbmem_post_device(void *unused)
+{
+	if (acpi_is_wakeup())
+		cbmem_initialize();
+	else
+		cbmem_initialize_empty();
+}
+
+BOOT_STATE_INIT_ENTRIES(cbmem_bscb) = {
+	BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE, BS_ON_ENTRY,
+	                      init_cbmem_post_device, NULL),
+};
+#endif
+
 void cbmem_add_bootmem(void)
 {
 	unsigned long base;



More information about the coreboot-gerrit mailing list