summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/acpi/acpigen.h41
-rw-r--r--include/dm/acpi.h9
2 files changed, 49 insertions, 1 deletions
diff --git a/include/acpi/acpigen.h b/include/acpi/acpigen.h
index 9c1faf7bf2..18409b613c 100644
--- a/include/acpi/acpigen.h
+++ b/include/acpi/acpigen.h
@@ -14,6 +14,9 @@
struct acpi_ctx;
+/* Top 4 bits of the value used to indicate a three-byte length value */
+#define ACPI_PKG_LEN_3_BYTES 0x80
+
/**
* acpigen_get_current() - Get the current ACPI code output pointer
*
@@ -65,4 +68,42 @@ void acpigen_emit_stream(struct acpi_ctx *ctx, const char *data, int size);
*/
void acpigen_emit_string(struct acpi_ctx *ctx, const char *str);
+/**
+ * acpigen_write_len_f() - Write a 'forward' length placeholder
+ *
+ * This adds space for a length value in the ACPI stream and pushes the current
+ * position (before the length) on the stack. After calling this you can write
+ * some data and then call acpigen_pop_len() to update the length value.
+ *
+ * Usage:
+ *
+ * acpigen_write_len_f() ------\
+ * acpigen_write...() |
+ * acpigen_write...() |
+ * acpigen_write_len_f() --\ |
+ * acpigen_write...() | |
+ * acpigen_write...() | |
+ * acpigen_pop_len() ------/ |
+ * acpigen_write...() |
+ * acpigen_pop_len() ----------/
+ *
+ * See ACPI 6.3 section 20.2.4 Package Length Encoding
+ *
+ * This implementation always uses a 3-byte packet length for simplicity. It
+ * could be adjusted to support other lengths.
+ *
+ * @ctx: ACPI context pointer
+ */
+void acpigen_write_len_f(struct acpi_ctx *ctx);
+
+/**
+ * acpigen_pop_len() - Update the previously stacked length placeholder
+ *
+ * Call this after the data for the block has been written. It updates the
+ * top length value in the stack and pops it off.
+ *
+ * @ctx: ACPI context pointer
+ */
+void acpigen_pop_len(struct acpi_ctx *ctx);
+
#endif
diff --git a/include/dm/acpi.h b/include/dm/acpi.h
index 696b1a96a0..dfda88e493 100644
--- a/include/dm/acpi.h
+++ b/include/dm/acpi.h
@@ -16,12 +16,15 @@
#define ACPI_OPS_PTR(_ptr)
#endif
-/* Length of an ACPI name string, excluding nul terminator */
+/* Length of an ACPI name string, excluding null terminator */
#define ACPI_NAME_LEN 4
/* Length of an ACPI name string including nul terminator */
#define ACPI_NAME_MAX (ACPI_NAME_LEN + 1)
+/* Number of nested objects supported */
+#define ACPIGEN_LENSTACK_SIZE 10
+
#if !defined(__ACPI__)
/**
@@ -35,6 +38,8 @@
* adding a new table. The RSDP holds pointers to the RSDT and XSDT.
* @rsdt: Pointer to the Root System Description Table
* @xsdt: Pointer to the Extended System Description Table
+ * @len_stack: Stack of 'length' words to fix up later
+ * @ltop: Points to current top of stack (0 = empty)
*/
struct acpi_ctx {
void *base;
@@ -42,6 +47,8 @@ struct acpi_ctx {
struct acpi_rsdp *rsdp;
struct acpi_rsdt *rsdt;
struct acpi_xsdt *xsdt;
+ char *len_stack[ACPIGEN_LENSTACK_SIZE];
+ int ltop;
};
/**