diff mbox series

[12/40] acpi: Add a table start

Message ID 20211201160315.2203099-13-sjg@chromium.org
State Accepted
Commit fb746fdec6d58eacd7d9323eda7ccbde9419a41e
Delegated to: Tom Rini
Headers show
Series RFC: rpi: Enable ACPI booting on ARM with Raspberry Pi 4 | expand

Commit Message

Simon Glass Dec. 1, 2021, 4:02 p.m. UTC
It is useful to record the start of an ACPI table so that offsets from
that point can be easily calculated.

Add this to the context and set it before calling the writer method.

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

 drivers/core/acpi.c | 5 ++---
 include/dm/acpi.h   | 4 ++++
 2 files changed, 6 insertions(+), 3 deletions(-)

Comments

Simon Glass Jan. 23, 2022, 9:53 p.m. UTC | #1
It is useful to record the start of an ACPI table so that offsets from
that point can be easily calculated.

Add this to the context and set it before calling the writer method.

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

 drivers/core/acpi.c | 5 ++---
 include/dm/acpi.h   | 4 ++++
 2 files changed, 6 insertions(+), 3 deletions(-)

Applied to u-boot-dm, thanks!
diff mbox series

Patch

diff --git a/drivers/core/acpi.c b/drivers/core/acpi.c
index 2176d8b8365..35a317fd2b0 100644
--- a/drivers/core/acpi.c
+++ b/drivers/core/acpi.c
@@ -266,19 +266,18 @@  int acpi_recurse_method(struct acpi_ctx *ctx, struct udevice *parent,
 
 	func = acpi_get_method(parent, method);
 	if (func) {
-		void *start = ctx->current;
-
 		log_debug("- method %d, %s %p\n", method, parent->name, func);
 		ret = device_of_to_plat(parent);
 		if (ret)
 			return log_msg_ret("ofdata", ret);
+		ctx->tab_start = ctx->current;
 		ret = func(parent, ctx);
 		if (ret)
 			return log_msg_ret("func", ret);
 
 		/* Add the item to the internal list */
 		if (type != TYPE_NONE) {
-			ret = acpi_add_item(ctx, parent, type, start);
+			ret = acpi_add_item(ctx, parent, type, ctx->tab_start);
 			if (ret)
 				return log_msg_ret("add", ret);
 		}
diff --git a/include/dm/acpi.h b/include/dm/acpi.h
index 7f1f2ef2cb6..22f62bc0f2a 100644
--- a/include/dm/acpi.h
+++ b/include/dm/acpi.h
@@ -43,6 +43,9 @@  enum acpi_dump_option {
  *
  * @base: Base address of ACPI tables
  * @current: Current address for writing
+ * @tab_start: Address of start of the table being written. This is set up
+ * before the writer or driver method is called. It must not be changed by the
+ * method
  * @rsdp: Pointer to the Root System Description Pointer, typically used when
  *	adding a new table. The RSDP holds pointers to the RSDT and XSDT.
  * @rsdt: Pointer to the Root System Description Table
@@ -56,6 +59,7 @@  enum acpi_dump_option {
 struct acpi_ctx {
 	void *base;
 	void *current;
+	void *tab_start;
 	struct acpi_rsdp *rsdp;
 	struct acpi_rsdt *rsdt;
 	struct acpi_xsdt *xsdt;