summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-04-26 18:19:47 +0300
committerBin Meng <bmeng.cn@gmail.com>2020-04-30 12:16:12 +0300
commit86e1778ded011051774e20faaefe4b12a838b1a0 (patch)
treecdf0e908e1f9d3e2ec50187b6f42271984176e8b /lib
parent93f7f82782cb3d2bd55215ce984887efc6cddfed (diff)
downloadu-boot-86e1778ded011051774e20faaefe4b12a838b1a0.tar.xz
acpi: Convert part of acpi_table to use acpi_ctx
The current code uses an address but a pointer would result in fewer casts. Also it repeats the alignment code in a lot of places so this would be better done in a helper function. Update write_acpi_tables() to make use of the new acpi_ctx structure, adding a few helpers to clean things up. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/acpi/acpi_table.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/lib/acpi/acpi_table.c b/lib/acpi/acpi_table.c
index 372f19b16d..07d9bbb0af 100644
--- a/lib/acpi/acpi_table.c
+++ b/lib/acpi/acpi_table.c
@@ -6,10 +6,11 @@
*/
#include <common.h>
-#include <acpi/acpi_table.h>
#include <dm.h>
#include <cpu.h>
#include <version.h>
+#include <acpi/acpi_table.h>
+#include <dm/acpi.h>
int acpi_create_dmar(struct acpi_dmar *dmar, enum dmar_flags flags)
{
@@ -98,3 +99,24 @@ void acpi_fill_header(struct acpi_table_header *header, char *signature)
header->oem_revision = U_BOOT_BUILD_DATE;
memcpy(header->aslc_id, ASLC_ID, 4);
}
+
+void acpi_align(struct acpi_ctx *ctx)
+{
+ ctx->current = (void *)ALIGN((ulong)ctx->current, 16);
+}
+
+void acpi_align64(struct acpi_ctx *ctx)
+{
+ ctx->current = (void *)ALIGN((ulong)ctx->current, 64);
+}
+
+void acpi_inc(struct acpi_ctx *ctx, uint amount)
+{
+ ctx->current += amount;
+}
+
+void acpi_inc_align(struct acpi_ctx *ctx, uint amount)
+{
+ ctx->current += amount;
+ acpi_align(ctx);
+}