]>
Commit | Line | Data |
---|---|---|
61cc9339 SG |
1 | // SPDX-License-Identifier: GPL-2.0 |
2 | /* | |
3 | * Generation of ACPI (Advanced Configuration and Power Interface) tables | |
4 | * | |
5 | * Copyright 2019 Google LLC | |
6 | * Mostly taken from coreboot | |
7 | */ | |
8 | ||
9 | #define LOG_CATEGORY LOGC_ACPI | |
10 | ||
11 | #include <common.h> | |
12 | #include <dm.h> | |
13 | #include <acpi/acpigen.h> | |
14 | #include <dm/acpi.h> | |
15 | ||
16 | u8 *acpigen_get_current(struct acpi_ctx *ctx) | |
17 | { | |
18 | return ctx->current; | |
19 | } | |
20 | ||
21 | void acpigen_emit_byte(struct acpi_ctx *ctx, uint data) | |
22 | { | |
23 | *(u8 *)ctx->current++ = data; | |
24 | } | |
25 | ||
26 | void acpigen_emit_word(struct acpi_ctx *ctx, uint data) | |
27 | { | |
28 | acpigen_emit_byte(ctx, data & 0xff); | |
29 | acpigen_emit_byte(ctx, (data >> 8) & 0xff); | |
30 | } | |
31 | ||
32 | void acpigen_emit_dword(struct acpi_ctx *ctx, uint data) | |
33 | { | |
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); | |
39 | } | |
7fb8da4c SG |
40 | |
41 | void acpigen_emit_stream(struct acpi_ctx *ctx, const char *data, int size) | |
42 | { | |
43 | int i; | |
44 | ||
45 | for (i = 0; i < size; i++) | |
46 | acpigen_emit_byte(ctx, data[i]); | |
47 | } | |
48 | ||
49 | void acpigen_emit_string(struct acpi_ctx *ctx, const char *str) | |
50 | { | |
51 | acpigen_emit_stream(ctx, str, str ? strlen(str) : 0); | |
52 | acpigen_emit_byte(ctx, '\0'); | |
53 | } |