1 // SPDX-License-Identifier: GPL-2.0
3 * Generation of ACPI (Advanced Configuration and Power Interface) tables
5 * Copyright 2019 Google LLC
6 * Mostly taken from coreboot
9 #define LOG_CATEGORY LOGC_ACPI
13 #include <acpi/acpigen.h>
16 u8 *acpigen_get_current(struct acpi_ctx *ctx)
21 void acpigen_emit_byte(struct acpi_ctx *ctx, uint data)
23 *(u8 *)ctx->current++ = data;
26 void acpigen_emit_word(struct acpi_ctx *ctx, uint data)
28 acpigen_emit_byte(ctx, data & 0xff);
29 acpigen_emit_byte(ctx, (data >> 8) & 0xff);
32 void acpigen_emit_dword(struct acpi_ctx *ctx, uint data)
34 /* Output the value in little-endian format */
35 acpigen_emit_byte(ctx, data & 0xff);
36 acpigen_emit_byte(ctx, (data >> 8) & 0xff);
37 acpigen_emit_byte(ctx, (data >> 16) & 0xff);
38 acpigen_emit_byte(ctx, (data >> 24) & 0xff);
41 void acpigen_emit_stream(struct acpi_ctx *ctx, const char *data, int size)
45 for (i = 0; i < size; i++)
46 acpigen_emit_byte(ctx, data[i]);
49 void acpigen_emit_string(struct acpi_ctx *ctx, const char *str)
51 acpigen_emit_stream(ctx, str, str ? strlen(str) : 0);
52 acpigen_emit_byte(ctx, '\0');