[PATCH v3 12/30] x86: Allow putting some tables in the bloblist

Simon Glass sjg at chromium.org
Wed Nov 4 17:57:25 CET 2020


At present all tables are placed starting at address f0000 in memory, and
can be up to 64KB in size. If the tables are very large, this may not
provide enough space.

Also if the tables point to other tables (such as console log or a ramoops
area) then we must allocate other memory anyway.

The bloblist is a nice place to put these tables since it is contiguous,
which makes it easy to reserve this memory for linux using the 820 tables.

Add an option to put some of the tables in the bloblist. For SMBIOS and
ACPI, create suitable pointers from the f0000 region to the new location
of the tables.

Signed-off-by: Simon Glass <sjg at chromium.org>
Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
---

Changes in v3:
- Move the bloblist types into this patch
- Avoid build error when gd->acpi_ctx is not available

 arch/x86/lib/tables.c     | 47 ++++++++++++++++++++++++++++++++++++---
 include/acpi/acpi_table.h | 10 +++++++++
 include/bloblist.h        |  2 ++
 lib/Kconfig               |  9 ++++++++
 lib/acpi/acpi_table.c     |  4 ++--
 5 files changed, 67 insertions(+), 5 deletions(-)

diff --git a/arch/x86/lib/tables.c b/arch/x86/lib/tables.c
index f7b71c5cd13..8dc07868c1f 100644
--- a/arch/x86/lib/tables.c
+++ b/arch/x86/lib/tables.c
@@ -4,6 +4,7 @@
  */
 
 #include <common.h>
+#include <bloblist.h>
 #include <log.h>
 #include <malloc.h>
 #include <smbios.h>
@@ -26,10 +27,16 @@ typedef ulong (*table_write)(ulong addr);
  *
  * @name: Name of table (for debugging)
  * @write: Function to call to write this table
+ * @tag: Bloblist tag if using CONFIG_BLOBLIST_TABLES
+ * @size: Maximum table size
+ * @align: Table alignment in bytes
  */
 struct table_info {
 	const char *name;
 	table_write write;
+	enum bloblist_tag_t tag;
+	int size;
+	int align;
 };
 
 static struct table_info table_list[] = {
@@ -43,10 +50,10 @@ static struct table_info table_list[] = {
 	{ "mp", write_mp_table, },
 #endif
 #ifdef CONFIG_GENERATE_ACPI_TABLE
-	{ "acpi", write_acpi_tables, },
+	{ "acpi", write_acpi_tables, BLOBLISTT_ACPI_TABLES, 0x10000, 0x1000},
 #endif
 #ifdef CONFIG_GENERATE_SMBIOS_TABLE
-	{ "smbios", write_smbios_table, },
+	{ "smbios", write_smbios_table, BLOBLISTT_SMBIOS_TABLES, 0x1000, 0x100},
 #endif
 };
 
@@ -66,16 +73,25 @@ void table_fill_string(char *dest, const char *src, size_t n, char pad)
 
 int write_tables(void)
 {
-	u32 rom_table_start = ROM_TABLE_ADDR;
+	u32 rom_table_start;
 	u32 rom_table_end;
 	u32 high_table, table_size;
 	struct memory_area cfg_tables[ARRAY_SIZE(table_list) + 1];
 	int i;
 
+	rom_table_start = ROM_TABLE_ADDR;
+
 	debug("Writing tables to %x:\n", rom_table_start);
 	for (i = 0; i < ARRAY_SIZE(table_list); i++) {
 		const struct table_info *table = &table_list[i];
+		int size = table->size ? : CONFIG_ROM_TABLE_SIZE;
 
+		if (IS_ENABLED(CONFIG_BLOBLIST_TABLES) && table->tag) {
+			rom_table_start = (ulong)bloblist_add(table->tag, size,
+							      table->align);
+			if (!rom_table_start)
+				return log_msg_ret("bloblist", -ENOBUFS);
+		}
 		rom_table_end = table->write(rom_table_start);
 		rom_table_end = ALIGN(rom_table_end, ROM_TABLE_ALIGN);
 
@@ -96,6 +112,11 @@ int write_tables(void)
 
 		debug("- wrote '%s' to %x, end %x\n", table->name,
 		      rom_table_start, rom_table_end);
+		if (rom_table_end - rom_table_start > size) {
+			log_err("Out of space for configuration tables: need %x, have %x\n",
+				rom_table_end - rom_table_start, size);
+			return log_msg_ret("bloblist", -ENOSPC);
+		}
 		rom_table_start = rom_table_end;
 	}
 
@@ -105,6 +126,26 @@ int write_tables(void)
 		write_coreboot_table(CB_TABLE_ADDR, cfg_tables);
 	}
 
+	if (IS_ENABLED(CONFIG_BLOBLIST_TABLES)) {
+		void *ptr = (void *)CONFIG_ROM_TABLE_ADDR;
+
+		/* Write an RSDP pointing to the tables */
+		if (IS_ENABLED(CONFIG_GENERATE_ACPI_TABLE)) {
+			struct acpi_ctx *ctx = gd_acpi_ctx();
+
+			acpi_write_rsdp(ptr, ctx->rsdt, ctx->xsdt);
+			ptr += ALIGN(sizeof(struct acpi_rsdp), 16);
+		}
+		if (IS_ENABLED(CONFIG_GENERATE_SMBIOS_TABLE)) {
+			void *smbios;
+
+			smbios = bloblist_find(BLOBLISTT_SMBIOS_TABLES, 0);
+			if (!smbios)
+				return log_msg_ret("smbios", -ENOENT);
+			memcpy(ptr, smbios, sizeof(struct smbios_entry));
+		}
+	}
+
 	debug("- done writing tables\n");
 
 	return 0;
diff --git a/include/acpi/acpi_table.h b/include/acpi/acpi_table.h
index abbca6530db..a28eb71f4d7 100644
--- a/include/acpi/acpi_table.h
+++ b/include/acpi/acpi_table.h
@@ -688,6 +688,16 @@ int acpi_add_table(struct acpi_ctx *ctx, void *table);
  */
 void acpi_setup_base_tables(struct acpi_ctx *ctx, void *start);
 
+/**
+ * acpi_write_rsdp() - Write out an RSDP indicating where the ACPI tables are
+ *
+ * @rsdp: Address to write RSDP
+ * @rsdt: Address of RSDT
+ * @xsdt: Address of XSDT
+ */
+void acpi_write_rsdp(struct acpi_rsdp *rsdp, struct acpi_rsdt *rsdt,
+		     struct acpi_xsdt *xsdt);
+
 #endif /* !__ACPI__*/
 
 #include <asm/acpi_table.h>
diff --git a/include/bloblist.h b/include/bloblist.h
index 2b4b6696897..8cdce61187a 100644
--- a/include/bloblist.h
+++ b/include/bloblist.h
@@ -36,6 +36,8 @@ enum bloblist_tag_t {
 	BLOBLISTT_INTEL_VBT,		/* Intel Video-BIOS table */
 	BLOBLISTT_TPM2_TCG_LOG,		/* TPM v2 log space */
 	BLOBLISTT_TCPA_LOG,		/* TPM log space */
+	BLOBLISTT_ACPI_TABLES,		/* ACPI tables for x86 */
+	BLOBLISTT_SMBIOS_TABLES,	/* SMBIOS tables for x86 */
 
 	BLOBLISTT_COUNT
 };
diff --git a/lib/Kconfig b/lib/Kconfig
index dc4143fc128..9d40ddd5098 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -637,6 +637,15 @@ config FDT_FIXUP_PARTITIONS
 menu "System tables"
 	depends on (!EFI && !SYS_COREBOOT) || (ARM && EFI_LOADER)
 
+config BLOBLIST_TABLES
+	bool "Put tables in a bloblist"
+	depends on X86
+	help
+	  Normally tables are placed at address 0xf0000 and can be up to 64KB
+	  long. With this option, tables are instead placed in the bloblist
+	  with a pointer from 0xf0000. The size can then be larger and the
+	  tables can be placed high in memory.
+
 config GENERATE_SMBIOS_TABLE
 	bool "Generate an SMBIOS (System Management BIOS) table"
 	default y
diff --git a/lib/acpi/acpi_table.c b/lib/acpi/acpi_table.c
index 908d8903893..a0f0961be5b 100644
--- a/lib/acpi/acpi_table.c
+++ b/lib/acpi/acpi_table.c
@@ -183,8 +183,8 @@ int acpi_add_table(struct acpi_ctx *ctx, void *table)
 	return 0;
 }
 
-static void acpi_write_rsdp(struct acpi_rsdp *rsdp, struct acpi_rsdt *rsdt,
-			    struct acpi_xsdt *xsdt)
+void acpi_write_rsdp(struct acpi_rsdp *rsdp, struct acpi_rsdt *rsdt,
+		     struct acpi_xsdt *xsdt)
 {
 	memset(rsdp, 0, sizeof(struct acpi_rsdp));
 
-- 
2.29.1.341.ge80a0c044ae-goog



More information about the U-Boot mailing list