All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: "Tom Rini" <trini@konsulko.com>,
	"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
	"Bin Meng" <bmeng.cn@gmail.com>,
	"Marek Behún" <marek.behun@nic.cz>,
	"Simon Glass" <sjg@chromium.org>,
	"Asherah Connor" <ashe@kivikakk.ee>,
	"Pali Rohár" <pali@kernel.org>
Subject: [PATCH 15/40] x86: Use the ACPI table writer
Date: Wed,  1 Dec 2021 09:02:49 -0700	[thread overview]
Message-ID: <20211201160315.2203099-16-sjg@chromium.org> (raw)
In-Reply-To: <20211201160315.2203099-1-sjg@chromium.org>

Use the new ACPI writer to write the ACPI tables. At present this is all
done in one monolithic function. Future work will split this out.

Unfortunately the QFW write_acpi_tables() function conflicts with the
'writer' version, so disable that for sandbox.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/x86/lib/acpi_table.c | 21 ++++-----------------
 drivers/misc/qfw.c        |  2 +-
 lib/acpi/acpi_writer.c    |  4 +++-
 test/dm/acpi.c            |  6 +++---
 4 files changed, 11 insertions(+), 22 deletions(-)

diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c
index f57323b5c3f..321faaeb185 100644
--- a/arch/x86/lib/acpi_table.c
+++ b/arch/x86/lib/acpi_table.c
@@ -503,10 +503,10 @@ static int acpi_create_ssdt(struct acpi_ctx *ctx,
 /*
  * QEMU's version of write_acpi_tables is defined in drivers/misc/qfw.c
  */
-ulong write_acpi_tables(ulong start_addr)
+static int write_acpi_tables_x86(struct acpi_ctx *ctx,
+				 const struct acpi_writer *entry)
 {
 	const int thl = sizeof(struct acpi_table_header);
-	struct acpi_ctx *ctx;
 	struct acpi_facs *facs;
 	struct acpi_table_header *dsdt;
 	struct acpi_fadt *fadt;
@@ -516,22 +516,11 @@ ulong write_acpi_tables(ulong start_addr)
 	struct acpi_madt *madt;
 	struct acpi_csrt *csrt;
 	struct acpi_spcr *spcr;
-	void *start;
 	int aml_len;
 	ulong addr;
 	int ret;
 	int i;
 
-	ctx = malloc(sizeof(*ctx));
-	if (!ctx)
-		return log_msg_ret("mem", -ENOMEM);
-
-	start = map_sysmem(start_addr, 0);
-
-	debug("ACPI: Writing ACPI tables at %lx\n", start_addr);
-
-	acpi_reset_items();
-	acpi_setup_ctx(ctx, start);
 	acpi_setup_base_tables(ctx);
 
 	debug("ACPI:    * FACS\n");
@@ -674,14 +663,12 @@ ulong write_acpi_tables(ulong start_addr)
 
 	acpi_write_dev_tables(ctx);
 
-	addr = map_to_sysmem(ctx->current);
-	debug("current = %lx\n", addr);
-
 	acpi_rsdp_addr = (unsigned long)ctx->rsdp;
 	debug("ACPI: done\n");
 
-	return addr;
+	return 0;
 }
+ACPI_WRITER(x86, NULL, write_acpi_tables_x86, 0);
 
 ulong acpi_get_rsdp_addr(void)
 {
diff --git a/drivers/misc/qfw.c b/drivers/misc/qfw.c
index a298e5cf727..677841aac5e 100644
--- a/drivers/misc/qfw.c
+++ b/drivers/misc/qfw.c
@@ -19,7 +19,7 @@
 #include <asm/tables.h>
 #endif
 
-#ifdef CONFIG_GENERATE_ACPI_TABLE
+#if defined(CONFIG_GENERATE_ACPI_TABLE) && !defined(CONFIG_SANDBOX)
 /*
  * This function allocates memory for ACPI tables
  *
diff --git a/lib/acpi/acpi_writer.c b/lib/acpi/acpi_writer.c
index 7779bf38aab..53fc753aeeb 100644
--- a/lib/acpi/acpi_writer.c
+++ b/lib/acpi/acpi_writer.c
@@ -40,6 +40,7 @@ int acpi_write_one(struct acpi_ctx *ctx, const struct acpi_writer *entry)
 	return 0;
 }
 
+#ifndef CONFIG_QEMU
 static int acpi_write_all(struct acpi_ctx *ctx)
 {
 	const struct acpi_writer *writer =
@@ -60,7 +61,7 @@ static int acpi_write_all(struct acpi_ctx *ctx)
 /*
  * QEMU's version of write_acpi_tables is defined in drivers/misc/qfw.c
  */
-ulong new_write_acpi_tables(ulong start_addr)
+ulong write_acpi_tables(ulong start_addr)
 {
 	struct acpi_ctx *ctx;
 	ulong addr;
@@ -86,6 +87,7 @@ ulong new_write_acpi_tables(ulong start_addr)
 
 	return addr;
 }
+#endif /* QEMU */
 
 void acpi_setup_ctx(struct acpi_ctx *ctx, ulong start)
 {
diff --git a/test/dm/acpi.c b/test/dm/acpi.c
index a1d70b58597..49b71bec3c0 100644
--- a/test/dm/acpi.c
+++ b/test/dm/acpi.c
@@ -322,8 +322,8 @@ static int dm_test_acpi_basic(struct unit_test_state *uts)
 }
 DM_TEST(dm_test_acpi_basic, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
 
-/* Test acpi_setup_base_tables */
-static int dm_test_acpi_setup_base_tables(struct unit_test_state *uts)
+/* Test setup_ctx_and_base_tables */
+static int dm_test_setup_ctx_and_base_tables(struct unit_test_state *uts)
 {
 	struct acpi_rsdp *rsdp;
 	struct acpi_rsdt *rsdt;
@@ -369,7 +369,7 @@ static int dm_test_acpi_setup_base_tables(struct unit_test_state *uts)
 
 	return 0;
 }
-DM_TEST(dm_test_acpi_setup_base_tables,
+DM_TEST(dm_test_setup_ctx_and_base_tables,
 	UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
 
 /* Test 'acpi list' command */
-- 
2.34.0.rc2.393.gf8c9666880-goog


  parent reply	other threads:[~2021-12-01 16:08 UTC|newest]

Thread overview: 95+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-01 16:02 [PATCH 00/40] RFC: rpi: Enable ACPI booting on ARM with Raspberry Pi 4 Simon Glass
2021-12-01 16:02 ` [PATCH 01/40] Makefile: Allow LTO to be disabled for a build Simon Glass
2021-12-01 16:02 ` [PATCH 02/40] x86: Allow any arch to generate ACPI tables Simon Glass
2021-12-01 16:02 ` [PATCH 03/40] x86: Move the acpi table to generic global_data Simon Glass
2021-12-01 16:02 ` [PATCH 04/40] arm: Allow supporting ACPI-table generation Simon Glass
2021-12-01 16:49   ` Mark Kettenis
2021-12-01 17:10     ` Tom Rini
2021-12-01 17:45       ` François Ozog
2021-12-01 18:02         ` Simon Glass
2022-01-23 21:54         ` Simon Glass
2021-12-01 16:02 ` [PATCH 05/40] x86: Tidy up use of CONFIG_ACPIGEN Simon Glass
2021-12-01 16:02 ` [PATCH 06/40] sandbox: Allow building with GENERATE_ACPI_TABLE Simon Glass
2021-12-01 18:14   ` Heinrich Schuchardt
2021-12-01 19:32     ` Simon Glass
2022-01-23 21:54     ` Simon Glass
2021-12-01 16:02 ` [PATCH 07/40] efi: Correct call to write_acpi_tables() Simon Glass
2021-12-01 17:59   ` Heinrich Schuchardt
2021-12-01 19:32     ` Simon Glass
2021-12-01 19:57       ` Heinrich Schuchardt
2021-12-01 21:12         ` Simon Glass
2021-12-02  5:00           ` Heinrich Schuchardt
2021-12-02 13:42             ` Simon Glass
2022-01-23 21:54             ` Simon Glass
2021-12-01 16:02 ` [PATCH 08/40] efi: Correct address handling with ACPI tables Simon Glass
2021-12-01 18:12   ` Heinrich Schuchardt
2021-12-01 19:32     ` Simon Glass
2022-01-23 21:53     ` Simon Glass
2021-12-01 16:02 ` [PATCH 09/40] acpi: Use finer-grained control of ACPI-table generation Simon Glass
2021-12-01 16:02 ` [PATCH 10/40] acpi: Allow include files within the board directory Simon Glass
2021-12-01 16:02 ` [PATCH 11/40] acpi: Move acpi_fill_header() to the generic header Simon Glass
2021-12-01 16:02 ` [PATCH 12/40] acpi: Add a table start Simon Glass
2021-12-01 16:02 ` [PATCH 13/40] acpi: Add a linker list for ACPI tables Simon Glass
2021-12-01 16:02 ` [PATCH 14/40] x86: acpi: Split out context creation from base tables Simon Glass
2021-12-01 16:02 ` Simon Glass [this message]
2021-12-01 16:02 ` [PATCH 16/40] x86: Move base tables to a writer function Simon Glass
2021-12-01 16:02 ` [PATCH 17/40] x86: Move FACS table " Simon Glass
2021-12-01 16:02 ` [PATCH 18/40] x86: Move DSDT " Simon Glass
2021-12-01 16:02 ` [PATCH 19/40] x86: Move GNVS " Simon Glass
2021-12-01 16:02 ` [PATCH 20/40] x86: Move FADT " Simon Glass
2021-12-01 16:02 ` [PATCH 21/40] x86: Move FACP table into separate functions Simon Glass
2021-12-01 16:02 ` [PATCH 22/40] x86: Move SSDT table to a writer function Simon Glass
2021-12-01 16:02 ` [PATCH 23/40] x86: Move TPM2 " Simon Glass
2021-12-01 16:02 ` [PATCH 24/40] x86: Move MADT " Simon Glass
2021-12-01 16:02 ` [PATCH 25/40] x86: Move TCPA " Simon Glass
2021-12-01 16:03 ` [PATCH 26/40] x86: Move CSRT " Simon Glass
2021-12-01 16:03 ` [PATCH 27/40] x86: acpi: Update acpi_fill_csrt() to use acpi_ctx Simon Glass
2021-12-01 16:03 ` [PATCH 28/40] x86: Move device-specific ACPI tables to a writer function Simon Glass
2021-12-01 16:03 ` [PATCH 29/40] x86: Move acpi_get_rsdp_addr() ACPI tables to the writer Simon Glass
2021-12-01 16:03 ` [PATCH 30/40] acpi: Collect tables in the acpi_item list Simon Glass
2021-12-01 16:03 ` [PATCH 31/40] acpi: Tidy up the item list Simon Glass
2021-12-01 16:03 ` [PATCH 32/40] acpi: Tidy up the table list Simon Glass
2021-12-01 16:03 ` [PATCH 33/40] doc: Add usage information for the acpi command Simon Glass
2021-12-01 16:03 ` [PATCH 34/40] acpi: Add some tables needed by ARM devices Simon Glass
2021-12-01 16:03 ` [PATCH 35/40] acpi: Add myself as maintainer Simon Glass
2021-12-01 16:03 ` [PATCH 36/40] WIP: Add debugging for ACPI emission Simon Glass
2021-12-01 16:03 ` [PATCH 37/40] RFC: Allow passing ACPI tables to bootefi Simon Glass
2021-12-01 16:03 ` [PATCH 38/40] WIP: Add ASL files from tianocore Simon Glass
2021-12-01 16:03 ` [PATCH 39/40] WIP: Bring in some header " Simon Glass
2021-12-01 16:03 ` [PATCH 40/40] RFC: rpi: Enable booting with ACPI tables Simon Glass
2021-12-01 16:24   ` Andy Shevchenko
2021-12-01 19:30     ` Simon Glass
2021-12-01 17:09 ` [PATCH 00/40] RFC: rpi: Enable ACPI booting on ARM with Raspberry Pi 4 Andy Shevchenko
2021-12-01 17:50   ` François Ozog
2021-12-01 18:23     ` Tom Rini
2021-12-15  3:28 ` Simon Glass
2022-01-22 22:48   ` Simon Glass
2022-01-23 21:53 ` [PATCH 35/40] acpi: Add myself as maintainer Simon Glass
2022-01-23 21:53 ` [PATCH 33/40] doc: Add usage information for the acpi command Simon Glass
2022-01-23 21:53 ` [PATCH 34/40] acpi: Add some tables needed by ARM devices Simon Glass
2022-01-23 21:53 ` [PATCH 32/40] acpi: Tidy up the table list Simon Glass
2022-01-23 21:53 ` [PATCH 31/40] acpi: Tidy up the item list Simon Glass
2022-01-23 21:53 ` [PATCH 29/40] x86: Move acpi_get_rsdp_addr() ACPI tables to the writer Simon Glass
2022-01-23 21:53 ` [PATCH 30/40] acpi: Collect tables in the acpi_item list Simon Glass
2022-01-23 21:53 ` [PATCH 28/40] x86: Move device-specific ACPI tables to a writer function Simon Glass
2022-01-23 21:53 ` [PATCH 27/40] x86: acpi: Update acpi_fill_csrt() to use acpi_ctx Simon Glass
2022-01-23 21:53 ` [PATCH 26/40] x86: Move CSRT table to a writer function Simon Glass
2022-01-23 21:53 ` [PATCH 24/40] x86: Move MADT " Simon Glass
2022-01-23 21:53 ` [PATCH 25/40] x86: Move TCPA " Simon Glass
2022-01-23 21:53 ` [PATCH 22/40] x86: Move SSDT " Simon Glass
2022-01-23 21:53 ` [PATCH 23/40] x86: Move TPM2 " Simon Glass
2022-01-23 21:53 ` [PATCH 21/40] x86: Move FACP table into separate functions Simon Glass
2022-01-23 21:53 ` [PATCH 20/40] x86: Move FADT table to a writer function Simon Glass
2022-01-23 21:53 ` [PATCH 19/40] x86: Move GNVS " Simon Glass
2022-01-23 21:53 ` [PATCH 17/40] x86: Move FACS " Simon Glass
2022-01-23 21:53 ` [PATCH 18/40] x86: Move DSDT " Simon Glass
2022-01-23 21:53 ` [PATCH 16/40] x86: Move base tables " Simon Glass
2022-01-23 21:53 ` [PATCH 15/40] x86: Use the ACPI table writer Simon Glass
2022-01-23 21:53 ` [PATCH 13/40] acpi: Add a linker list for ACPI tables Simon Glass
2022-01-23 21:53 ` [PATCH 14/40] x86: acpi: Split out context creation from base tables Simon Glass
2022-01-23 21:53 ` [PATCH 12/40] acpi: Add a table start Simon Glass
2022-01-23 21:53 ` [PATCH 10/40] acpi: Allow include files within the board directory Simon Glass
2022-01-23 21:53 ` [PATCH 11/40] acpi: Move acpi_fill_header() to the generic header Simon Glass
2022-01-23 21:54 ` [PATCH 05/40] x86: Tidy up use of CONFIG_ACPIGEN Simon Glass
2022-01-23 21:54 ` [PATCH 02/40] x86: Allow any arch to generate ACPI tables Simon Glass
2022-01-23 21:54 ` [PATCH 03/40] x86: Move the acpi table to generic global_data Simon Glass

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=20211201160315.2203099-16-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=ashe@kivikakk.ee \
    --cc=bmeng.cn@gmail.com \
    --cc=marek.behun@nic.cz \
    --cc=pali@kernel.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.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.