All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [PATCH 14/32] x86: Allow putting some tables in the bloblist
Date: Sun, 27 Sep 2020 22:25:53 -0600	[thread overview]
Message-ID: <20200928042611.1696178-13-sjg@chromium.org> (raw)
In-Reply-To: <20200928042611.1696178-1-sjg@chromium.org>

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@chromium.org>
---

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

diff --git a/arch/x86/lib/tables.c b/arch/x86/lib/tables.c
index 62be6746282..db5c45ed3a6 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>
@@ -34,10 +35,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[] = {
@@ -51,10 +58,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
 };
 
@@ -74,16 +81,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);
 
@@ -104,6 +120,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;
 	}
 
@@ -113,6 +134,25 @@ int write_tables(void)
 		write_coreboot_table(CB_TABLE_ADDR, cfg_tables);
 	}
 
+	if (IS_ENABLED(CONFIG_BLOBLIST_TABLES)) {
+		struct acpi_ctx *ctx = gd->acpi_ctx;
+		void *ptr = (void *)CONFIG_ROM_TABLE_ADDR;
+
+		/* Write an RSDP pointing to the tables */
+		if (IS_ENABLED(CONFIG_GENERATE_ACPI_TABLE)) {
+			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/lib/Kconfig b/lib/Kconfig
index 8efb154f734..43fb2ef2ae9 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -624,6 +624,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.28.0.681.g6f77f65b4e-goog

  parent reply	other threads:[~2020-09-28  4:25 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-28  4:25 [PATCH 00/32] x86: Allow Coral to boot into Chrome OS Simon Glass
2020-09-28  4:25 ` [PATCH 01/32] Add an assembly guard around linux/bitops.h Simon Glass
2020-10-16  9:55   ` Bin Meng
2020-09-28  4:25 ` [PATCH 02/32] x86: apl: Add core init for the SoC Simon Glass
2020-10-16  9:55   ` Bin Meng
2020-09-28  4:25 ` [PATCH 03/32] x86: Add a layout for Chrome OS verified boot Simon Glass
2020-10-14 13:07   ` Simon Glass
2020-10-15  9:13     ` Bin Meng
2020-10-16  9:55   ` Bin Meng
2020-09-28  4:25 ` [PATCH 04/32] x86: Add support for private files Simon Glass
2020-10-16  9:55   ` Bin Meng
2020-09-28  4:25 ` [PATCH 05/32] x86: Allow writing tables to fail Simon Glass
2020-09-28  6:23   ` Heinrich Schuchardt
2020-10-16  9:55   ` Bin Meng
2020-09-28  4:25 ` [PATCH 06/32] x86: acpi: Store the ACPI context in global_data Simon Glass
2020-10-16  9:55   ` Bin Meng
2020-09-28  4:25 ` [PATCH 07/32] x86: Store the FADT so we can avoid searching for it Simon Glass
2020-10-16  9:55   ` Bin Meng
2020-09-28  4:25 ` [PATCH 08/32] x86: Don't bother clearing global NVS Simon Glass
2020-10-16  9:55   ` Bin Meng
2020-09-28  4:25 ` [PATCH 09/32] x86: coral: Drop the duplicate PCIe settings Simon Glass
2020-10-16  9:55   ` Bin Meng
2020-09-28  4:25 ` [PATCH 10/32] x86: Add SMBIOS info for Coral Simon Glass
2020-10-16  9:55   ` Bin Meng
2020-09-28  4:25 ` [PATCH 11/32] x86: coral: Correct max98357 file Simon Glass
2020-10-16 13:34   ` Bin Meng
2020-09-28  4:25 ` [PATCH 12/32] x86: Move ROM_TABLE_ADDR into the C file Simon Glass
2020-10-16 13:34   ` Bin Meng
2020-09-28  4:25 ` [PATCH 13/32] x86: Use if instead of #ifdef in write_tables() Simon Glass
2020-10-16 13:34   ` Bin Meng
2020-09-28  4:25 ` Simon Glass [this message]
2020-10-16 13:34   ` [PATCH 14/32] x86: Allow putting some tables in the bloblist Bin Meng
2020-09-28  4:25 ` [PATCH 15/32] x86: nhlt: Correct output of bytes and 16-bit data Simon Glass
2020-10-16 13:34   ` Bin Meng
2020-09-28  4:25 ` [PATCH 16/32] x86: nhlt: Fix a few bugs in the table generation Simon Glass
2020-10-16 13:35   ` Bin Meng
2020-09-28  4:25 ` [PATCH 17/32] x86: Show the interrupt pointer with 'irqinfo' Simon Glass
2020-10-16 13:35   ` Bin Meng
2020-09-28  4:25 ` [PATCH 18/32] x86: sound: Correct error handling Simon Glass
2020-10-16 13:35   ` Bin Meng
2020-09-28  4:25 ` [PATCH 19/32] acpi: Correct reset handling in acpi_device_add_power_res() Simon Glass
2020-10-16 13:35   ` Bin Meng
2020-09-28  4:25 ` [PATCH 20/32] x86: acpi: Allow the SSDT to be empty Simon Glass
2020-10-16 13:35   ` Bin Meng
2020-09-28  4:26 ` [PATCH 21/32] x86: acpi: Put the generated code first in DSDT Simon Glass
2020-10-16 14:17   ` Bin Meng
2020-09-28  4:26 ` [PATCH 22/32] acpi: Don't reset the tables with every new generation Simon Glass
2020-10-16 14:17   ` Bin Meng
2020-09-28  4:26 ` [PATCH 23/32] x86: Define the Chrome OS GNVS region Simon Glass
2020-10-16 14:17   ` Bin Meng
2020-09-28  4:26 ` [PATCH 24/32] x86: Use CONFIG_CHROMEOS_VBOOT for verified boot Simon Glass
2020-10-16 14:17   ` Bin Meng
2020-09-28  4:26 ` [PATCH 25/32] x86: Set up Chrome OS to boot into developer mode Simon Glass
2020-10-16 14:17   ` Bin Meng
2020-09-28  4:26 ` [PATCH 26/32] x86: Boot coral into Chrome OS by default Simon Glass
2020-10-16 14:17   ` Bin Meng
2020-09-28  4:26 ` [PATCH 27/32] x86: fsp: Convert fsp_dram to use log_debug() Simon Glass
2020-10-16 14:17   ` Bin Meng
2020-09-28  4:26 ` [PATCH 28/32] x86: Silence some logging statements Simon Glass
2020-10-16 14:17   ` Bin Meng
2020-09-28  4:26 ` [PATCH 29/32] x86: acpi: Include the TPMv1 table only if needed Simon Glass
2020-10-16 14:17   ` Bin Meng
2020-09-28  4:26 ` [PATCH 30/32] x86: acpi: Don't show the UART address by default Simon Glass
2020-10-16 14:17   ` Bin Meng
2020-09-28  4:26 ` [PATCH 31/32] x86: pinctrl: Silence the warning when a pin is not found Simon Glass
2020-10-16 14:17   ` Bin Meng
2020-09-28  4:26 ` [PATCH 32/32] x86: fsp: Adjust calculations for MTRR range and DRAM top Simon Glass
2020-10-16 14:17   ` Bin Meng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200928042611.1696178-13-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.