diff mbox series

[27/40] x86: acpi: Update acpi_fill_csrt() to use acpi_ctx

Message ID 20211201160315.2203099-28-sjg@chromium.org
State Accepted
Commit 78031ad43168d13de5c9ecf72877e8d5d35f749a
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:03 p.m. UTC
Update this function to the newer style, so we can avoid passing and
returning an address through this function.

Also move this function out of the x86 code so it can be used by other
archs.

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

 arch/x86/cpu/tangier/acpi.c       |  9 ++++++---
 arch/x86/include/asm/acpi_table.h |  1 -
 include/acpi/acpi_table.h         | 12 ++++++++++++
 lib/acpi/csrt.c                   | 13 ++++++-------
 4 files changed, 24 insertions(+), 11 deletions(-)

Comments

Simon Glass Jan. 23, 2022, 9:53 p.m. UTC | #1
Update this function to the newer style, so we can avoid passing and
returning an address through this function.

Also move this function out of the x86 code so it can be used by other
archs.

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

 arch/x86/cpu/tangier/acpi.c       |  9 ++++++---
 arch/x86/include/asm/acpi_table.h |  1 -
 include/acpi/acpi_table.h         | 12 ++++++++++++
 lib/acpi/csrt.c                   | 13 ++++++-------
 4 files changed, 24 insertions(+), 11 deletions(-)

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

Patch

diff --git a/arch/x86/cpu/tangier/acpi.c b/arch/x86/cpu/tangier/acpi.c
index 11873565366..12f92896124 100644
--- a/arch/x86/cpu/tangier/acpi.c
+++ b/arch/x86/cpu/tangier/acpi.c
@@ -109,11 +109,14 @@  static u32 acpi_fill_csrt_dma(struct acpi_csrt_group *grp)
 	return grp->length;
 }
 
-u32 acpi_fill_csrt(u32 current)
+int acpi_fill_csrt(struct acpi_ctx *ctx)
 {
-	current += acpi_fill_csrt_dma((struct acpi_csrt_group *)current);
+	int size;
 
-	return current;
+	size = acpi_fill_csrt_dma(ctx->current);
+	acpi_inc(ctx, size);
+
+	return 0;
 }
 
 int acpi_create_gnvs(struct acpi_global_nvs *gnvs)
diff --git a/arch/x86/include/asm/acpi_table.h b/arch/x86/include/asm/acpi_table.h
index a22f8d90f82..9a93b2658ac 100644
--- a/arch/x86/include/asm/acpi_table.h
+++ b/arch/x86/include/asm/acpi_table.h
@@ -35,7 +35,6 @@  u32 acpi_fill_madt(u32 current);
 int acpi_create_mcfg_mmconfig(struct acpi_mcfg_mmconfig *mmconfig, u32 base,
 			      u16 seg_nr, u8 start, u8 end);
 u32 acpi_fill_mcfg(u32 current);
-u32 acpi_fill_csrt(u32 current);
 
 /**
  * acpi_write_hpet() - Write out a HPET table
diff --git a/include/acpi/acpi_table.h b/include/acpi/acpi_table.h
index 87674e2cc0d..80646a44b2b 100644
--- a/include/acpi/acpi_table.h
+++ b/include/acpi/acpi_table.h
@@ -696,6 +696,18 @@  void acpi_write_rsdp(struct acpi_rsdp *rsdp, struct acpi_rsdt *rsdt,
  */
 void acpi_fill_header(struct acpi_table_header *header, char *signature);
 
+/**
+ * acpi_fill_csrt() - Fill out the body of the CSRT
+ *
+ * This should write the contents of the Core System Resource Table (CSRT)
+ * to the context. The header (struct acpi_table_header) has already been
+ * written.
+ *
+ * @ctx: ACPI context to write to
+ * @return 0 if OK, -ve on error
+ */
+int acpi_fill_csrt(struct acpi_ctx *ctx);
+
 #endif /* !__ACPI__*/
 
 #include <asm/acpi_table.h>
diff --git a/lib/acpi/csrt.c b/lib/acpi/csrt.c
index 76069318416..2ba86f22952 100644
--- a/lib/acpi/csrt.c
+++ b/lib/acpi/csrt.c
@@ -13,7 +13,7 @@ 
 #include <acpi/acpi_table.h>
 #include <dm/acpi.h>
 
-__weak u32 acpi_fill_csrt(u32 current)
+__weak int acpi_fill_csrt(struct acpi_ctx *ctx)
 {
 	return 0;
 }
@@ -22,7 +22,7 @@  int acpi_write_csrt(struct acpi_ctx *ctx, const struct acpi_writer *entry)
 {
 	struct acpi_table_header *header;
 	struct acpi_csrt *csrt;
-	uint ptr;
+	int ret;
 
 	csrt = ctx->current;
 	header = &csrt->header;
@@ -31,19 +31,18 @@  int acpi_write_csrt(struct acpi_ctx *ctx, const struct acpi_writer *entry)
 
 	/* Fill out header fields */
 	acpi_fill_header(header, "CSRT");
-	header->length = sizeof(struct acpi_csrt);
 	header->revision = 0;
+	acpi_inc(ctx, sizeof(*header));
 
-	ptr = acpi_fill_csrt(map_to_sysmem(csrt));
-	if (!ptr)
-		return log_msg_ret("fill", -ENOENT);
+	ret = acpi_fill_csrt(ctx);
+	if (ret)
+		return log_msg_ret("fill", ret);
 
 	/* (Re)calculate length and checksum */
 	header->length = (ulong)ctx->current - (ulong)csrt;
 	header->checksum = table_compute_checksum(csrt, header->length);
 
 	acpi_add_table(ctx, csrt);
-	acpi_inc(ctx, csrt->header.length);
 
 	return 0;
 }