1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Core ACPI (Advanced Configuration and Power Interface) support
5 * Copyright 2019 Google LLC
7 * Modified from coreboot file acpigen.h
10 #ifndef __ACPI_ACPIGEN_H
11 #define __ACPI_ACPIGEN_H
13 #include <linux/types.h>
17 /* Top 4 bits of the value used to indicate a three-byte length value */
18 #define ACPI_PKG_LEN_3_BYTES 0x80
21 * acpigen_get_current() - Get the current ACPI code output pointer
23 * @ctx: ACPI context pointer
24 * @return output pointer
26 u8 *acpigen_get_current(struct acpi_ctx *ctx);
29 * acpigen_emit_byte() - Emit a byte to the ACPI code
31 * @ctx: ACPI context pointer
32 * @data: Value to output
34 void acpigen_emit_byte(struct acpi_ctx *ctx, uint data);
37 * acpigen_emit_word() - Emit a 16-bit word to the ACPI code
39 * @ctx: ACPI context pointer
40 * @data: Value to output
42 void acpigen_emit_word(struct acpi_ctx *ctx, uint data);
45 * acpigen_emit_dword() - Emit a 32-bit 'double word' to the ACPI code
47 * @ctx: ACPI context pointer
48 * @data: Value to output
50 void acpigen_emit_dword(struct acpi_ctx *ctx, uint data);
53 * acpigen_emit_stream() - Emit a stream of bytes
55 * @ctx: ACPI context pointer
56 * @data: Data to output
57 * @size: Size of data in bytes
59 void acpigen_emit_stream(struct acpi_ctx *ctx, const char *data, int size);
62 * acpigen_emit_string() - Emit a string
64 * Emit a string with a null terminator
66 * @ctx: ACPI context pointer
67 * @str: String to output, or NULL for an empty string
69 void acpigen_emit_string(struct acpi_ctx *ctx, const char *str);
72 * acpigen_write_len_f() - Write a 'forward' length placeholder
74 * This adds space for a length value in the ACPI stream and pushes the current
75 * position (before the length) on the stack. After calling this you can write
76 * some data and then call acpigen_pop_len() to update the length value.
80 * acpigen_write_len_f() ------\
81 * acpigen_write...() |
82 * acpigen_write...() |
83 * acpigen_write_len_f() --\ |
84 * acpigen_write...() | |
85 * acpigen_write...() | |
86 * acpigen_pop_len() ------/ |
87 * acpigen_write...() |
88 * acpigen_pop_len() ----------/
90 * See ACPI 6.3 section 20.2.4 Package Length Encoding
92 * This implementation always uses a 3-byte packet length for simplicity. It
93 * could be adjusted to support other lengths.
95 * @ctx: ACPI context pointer
97 void acpigen_write_len_f(struct acpi_ctx *ctx);
100 * acpigen_pop_len() - Update the previously stacked length placeholder
102 * Call this after the data for the block has been written. It updates the
103 * top length value in the stack and pops it off.
105 * @ctx: ACPI context pointer
107 void acpigen_pop_len(struct acpi_ctx *ctx);