[coreboot-gerrit] Patch set updated for coreboot: 54468a7 Move high_tables globals from arch

Kyösti Mälkki (kyosti.malkki@gmail.com) gerrit at coreboot.org
Wed Sep 4 15:20:32 CEST 2013


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/3559

-gerrit

commit 54468a70d951ab0322a0ce52c7b165c261eb9b9e
Author: Kyösti Mälkki <kyosti.malkki at gmail.com>
Date:   Wed Sep 4 14:11:08 2013 +0300

    Move high_tables globals from arch
    
    Change-Id: I89c012bce1b86d0710748719a8840ec532ce6939
    Signed-off-by: Kyösti Mälkki <kyosti.malkki at gmail.com>
---
 src/arch/armv7/tables.c    | 13 +------------
 src/arch/x86/boot/tables.c | 12 +++---------
 src/include/cbmem.h        | 10 ++++------
 src/lib/cbmem.c            | 38 +++++++++++++++++++++++++++++++++-----
 src/lib/coreboot_table.c   |  5 -----
 5 files changed, 41 insertions(+), 37 deletions(-)

diff --git a/src/arch/armv7/tables.c b/src/arch/armv7/tables.c
index 0fc7399..de6b6fa 100644
--- a/src/arch/armv7/tables.c
+++ b/src/arch/armv7/tables.c
@@ -29,13 +29,6 @@
 
 #define MAX_COREBOOT_TABLE_SIZE (8 * 1024)
 
-/*
- * TODO: "High" tables are a convention used on x86. Maybe we can
- * clean up that naming at some point.
- */
-uint64_t high_tables_base = 0;
-uint64_t high_tables_size;
-
 void cbmem_arch_init(void)
 {
 }
@@ -44,11 +37,7 @@ struct lb_memory *write_tables(void)
 {
 	unsigned long table_pointer, new_table_pointer;
 
-	if (!high_tables_base) {
-		printk(BIOS_ERR, "ERROR: high_tables_base is not set.\n");
-	}
-
-	printk(BIOS_DEBUG, "high_tables_base: %llx.\n", high_tables_base);
+	cbmem_base_check();
 
 	post_code(0x9d);
 
diff --git a/src/arch/x86/boot/tables.c b/src/arch/x86/boot/tables.c
index 67d7911..ca1b61b 100644
--- a/src/arch/x86/boot/tables.c
+++ b/src/arch/x86/boot/tables.c
@@ -32,8 +32,6 @@
 #include <lib.h>
 #include <smbios.h>
 
-uint64_t high_tables_base = 0;
-uint64_t high_tables_size;
 
 void cbmem_arch_init(void)
 {
@@ -45,6 +43,7 @@ struct lb_memory *write_tables(void)
 {
 	unsigned long low_table_start, low_table_end;
 	unsigned long rom_table_start, rom_table_end;
+	u64 high_tables_base = 0;
 
 	/* Even if high tables are configured, some tables are copied both to
 	 * the low and the high area, so payloads and OSes don't need to know
@@ -53,13 +52,8 @@ struct lb_memory *write_tables(void)
 	unsigned long high_table_pointer;
 
 #if !CONFIG_DYNAMIC_CBMEM
-	if (!high_tables_base) {
-		printk(BIOS_ERR, "ERROR: High Tables Base is not set.\n");
-		// Are there any boards without?
-		// Stepan thinks we should die() here!
-	}
-
-	printk(BIOS_DEBUG, "High Tables Base is %llx.\n", high_tables_base);
+	cbmem_base_check();
+	high_tables_base = (u32)get_cbmem_toc();
 #endif
 
 	rom_table_start = 0xf0000;
diff --git a/src/include/cbmem.h b/src/include/cbmem.h
index 8ba1d21..3eeb6a1 100644
--- a/src/include/cbmem.h
+++ b/src/include/cbmem.h
@@ -125,19 +125,14 @@ int cbmem_entry_remove(const struct cbmem_entry *entry);
 void *cbmem_entry_start(const struct cbmem_entry *entry);
 u64 cbmem_entry_size(const struct cbmem_entry *entry);
 
-#ifndef __PRE_RAM__
-/* Add the cbmem memory used to the memory tables. */
-struct lb_memory;
-void cbmem_add_lb_mem(struct lb_memory *mem);
-#endif /* __PRE_RAM__ */
 
 #else /* !CONFIG_DYNAMIC_CBMEM */
 
 #ifndef __PRE_RAM__
-extern uint64_t high_tables_base, high_tables_size;
 void set_top_of_ram(uint64_t ramtop);
 void backup_top_of_ram(uint64_t ramtop);
 void set_cbmem_table(uint64_t base, uint64_t size);
+int cbmem_base_check(void);
 #endif
 
 int cbmem_reinit(u64 baseaddr);
@@ -162,6 +157,9 @@ void *cbmem_find(u32 id);
 
 #ifndef __PRE_RAM__
 /* Ramstage only functions. */
+/* Add the cbmem memory used to the memory tables. */
+struct lb_memory;
+void cbmem_add_lb_mem(struct lb_memory *mem);
 void cbmem_list(void);
 void cbmem_arch_init(void);
 void cbmem_print_entry(int n, u32 id, u64 start, u64 size);
diff --git a/src/lib/cbmem.c b/src/lib/cbmem.c
index eb18725..963ca4d 100644
--- a/src/lib/cbmem.c
+++ b/src/lib/cbmem.c
@@ -21,6 +21,7 @@
 #include <string.h>
 #include <bootstate.h>
 #include <cbmem.h>
+#include <boot/coreboot_tables.h>
 #include <console/console.h>
 #include <cpu/x86/car.h>
 #if CONFIG_HAVE_ACPI_RESUME && !defined(__PRE_RAM__)
@@ -41,13 +42,20 @@ struct cbmem_entry {
 	u64 size;
 } __attribute__((packed));
 
+#ifndef __PRE_RAM__
+static uint64_t bss_cbmem_base = 0;
+static uint64_t bss_cbmem_size = 0;
+#endif
+
 static void cbmem_locate_table(uint64_t *base, uint64_t *size)
 {
 #ifdef __PRE_RAM__
 	get_cbmem_table(base, size);
 #else
-	*base = high_tables_base;
-	*size = high_tables_size;
+	if (!(bss_cbmem_base && bss_cbmem_size))
+		get_cbmem_table(&bss_cbmem_base, &bss_cbmem_size);
+	*base = bss_cbmem_base;
+	*size = bss_cbmem_size;
 #endif
 }
 
@@ -61,12 +69,12 @@ struct cbmem_entry *get_cbmem_toc(void)
 #if !defined(__PRE_RAM__)
 void set_cbmem_table(uint64_t base, uint64_t size)
 {
-	if (base == high_tables_base && size == high_tables_size)
+	if (base == bss_cbmem_base && size == bss_cbmem_size)
 		return;
 
 	printk(BIOS_DEBUG, "CBMEM region %llx-%llx\n", base, base+size-1);
-	high_tables_base = base;
-	high_tables_size = size;
+	bss_cbmem_base = base;
+	bss_cbmem_size = size;
 }
 #endif
 
@@ -244,6 +252,26 @@ BOOT_STATE_INIT_ENTRIES(cbmem_bscb) = {
 	                      init_cbmem_post_device, NULL),
 };
 
+int cbmem_base_check(void)
+{
+	uint64_t base, size;
+	cbmem_locate_table(&base, &size);
+	if (!base) {
+		printk(BIOS_ERR, "ERROR: CBMEM Base is not set.\n");
+		// Are there any boards without?
+		// Stepan thinks we should die() here!
+	}
+	printk(BIOS_DEBUG, "CBMEM Base is %llx.\n", base);
+	return !!base;
+}
+
+void cbmem_add_lb_mem(struct lb_memory *mem)
+{
+	uint64_t base, size;
+	cbmem_locate_table(&base, &size);
+	lb_add_memory_range(mem, LB_MEM_TABLE, base, size);
+}
+
 void cbmem_list(void)
 {
 	struct cbmem_entry *cbmem_toc;
diff --git a/src/lib/coreboot_table.c b/src/lib/coreboot_table.c
index 3fad4c7..e5729ba 100644
--- a/src/lib/coreboot_table.c
+++ b/src/lib/coreboot_table.c
@@ -539,12 +539,7 @@ unsigned long write_coreboot_table(
 		lb_add_memory_range(mem, LB_MEM_TABLE,
 			rom_table_start, rom_table_end - rom_table_start);
 
-#if CONFIG_DYNAMIC_CBMEM
 	cbmem_add_lb_mem(mem);
-#else /* CONFIG_DYNAMIC_CBMEM */
-	lb_add_memory_range(mem, LB_MEM_TABLE,
-		high_tables_base, high_tables_size);
-#endif /* CONFIG_DYNAMIC_CBMEM */
 
 	/* No other memory areas can be added after the memory table has been
 	 * committed as the entries won't show up in the serialize mem table. */



More information about the coreboot-gerrit mailing list