Add more functions to handle some miscellaneous ACPI opcodes.
Signed-off-by: Simon Glass
---
Changes in v2: None
Changes in v1: None
include/acpi/acpigen.h | 114 +
lib/acpi/acpigen.c | 83 ++
test/dm/acpigen.c | 75 +++
3 files changed, 272 insertions(+)
diff --git a/include/acpi/acpigen.h b/include/acpi/acpigen.h
index 16b33ebe66..c595bb9efa 100644
--- a/include/acpi/acpigen.h
+++ b/include/acpi/acpigen.h
@@ -26,9 +26,26 @@ enum {
QWORD_PREFIX= 0x0e,
BUFFER_OP = 0x11,
PACKAGE_OP = 0x12,
+ METHOD_OP = 0x14,
+ SLEEP_OP= 0x22,
DUAL_NAME_PREFIX= 0x2e,
MULTI_NAME_PREFIX = 0x2f,
+ DEBUG_OP= 0x31,
+ EXT_OP_PREFIX = 0x5b,
ROOT_PREFIX = 0x5c,
+ LOCAL0_OP = 0x60,
+ LOCAL1_OP = 0x61,
+ LOCAL2_OP = 0x62,
+ LOCAL3_OP = 0x63,
+ LOCAL4_OP = 0x64,
+ LOCAL5_OP = 0x65,
+ LOCAL6_OP = 0x66,
+ LOCAL7_OP = 0x67,
+ STORE_OP= 0x70,
+ AND_OP = 0x7b,
+ OR_OP = 0x7d,
+ NOT_OP = 0x80,
+ RETURN_OP = 0xa4,
};
/**
@@ -196,4 +213,101 @@ void acpigen_write_name(struct acpi_ctx *ctx, const char
*namepath);
*/
int acpigen_write_uuid(struct acpi_ctx *ctx, const char *uuid);
+/**
+ * acpigen_emit_ext_op() - Emit an extended op with the EXT_OP_PREFIX prefix
+ *
+ * @ctx: ACPI context pointer
+ * @op: Operation code (e.g. SLEEP_OP)
+ */
+void acpigen_emit_ext_op(struct acpi_ctx *ctx, uint op);
+
+/**
+ * acpigen_write_method() - Write a method header
+ *
+ * @ctx: ACPI context pointer
+ * @name: Method name (4 characters)
+ * @nargs: Number of method arguments (0 if none)
+ */
+void acpigen_write_method(struct acpi_ctx *ctx, const char *name, int nargs);
+
+/**
+ * acpigen_write_method_serialized() - Write a method header
+ *
+ * This sets the 'serialized' flag so that the method is thread-safe
+ *
+ * @ctx: ACPI context pointer
+ * @name: Method name (4 characters)
+ * @nargs: Number of method arguments (0 if none)
+ */
+void acpigen_write_method_serialized(struct acpi_ctx *ctx, const char *name,
+int nargs);
+
+/**
+ * acpigen_write_sta() - Write a _STA method
+ *
+ * @ctx: ACPI context pointer
+ * @status: Status value to return
+ */
+void acpigen_write_sta(struct acpi_ctx *ctx, uint status);
+
+/**
+ * acpigen_write_sleep() - Write a sleep operation
+ *
+ * @ctx: ACPI context pointer
+ * @sleep_ms: Number of milliseconds to sleep for
+ */
+void acpigen_write_sleep(struct acpi_ctx *ctx, u64 sleep_ms);
+
+/**
+ * acpigen_write_store() - Write a store operation
+ *
+ * @ctx: ACPI context pointer
+ */
+void acpigen_write_store(struct acpi_ctx *ctx);
+
+/**
+ * acpigen_write_debug_string() - Write a debug string
+ *
+ * This writes a debug operation with an associated string
+ *
+ * @ctx: ACPI context pointer
+ * @str: String to write
+ */
+void acpigen_write_debug_string(struct acpi_ctx *ctx, const char *str);
+
+/**
+ * acpigen_write_or() - Write a bitwise OR operation
+ *
+ * res = arg1 | arg2
+ *
+ * @ctx: ACPI context pointer
+ * @arg1: ACPI opcode for operand 1 (e.g. LOCAL0_OP)
+ * @arg2: ACPI opcode for operand 2 (e.g. LOCAL1_OP)
+ * @res: ACPI opcode for result (e.g. LOCAL2_OP)
+ */
+void acpigen_write_or(struct acpi_ctx *ctx, u8 arg1, u8 arg2, u8 res);
+
+/**
+ * acpigen_write_and() - Write a bitwise AND operation
+ *
+ * res = arg1 & arg2
+ *
+ * @ctx: ACPI context pointer
+ * @arg1: ACPI opcode for operand 1 (e.g. LOCAL0_OP)
+ * @arg2: ACPI opcode for operand 2 (e.g. LOCAL1_OP)
+ * @res: ACPI opcode for result (e.g. LOCAL2_OP)
+ */
+void acpigen_write_and(struct acpi_ctx *ctx, u8 arg1, u8 arg2, u8 res);
+
+/**
+ * acpigen_write_or() - Write a bitwise NOT operation
+ *
+ * res = ~arg1
+ *
+ * @ctx: ACPI context pointer
+ * @arg: ACPI opcode for operand (e.g. LOCAL0_OP)
+ * @res: ACPI opcode for result (e.g. LOCAL2_OP)
+ */
+void acpigen_write_not(struct acpi_ctx *ctx, u8 arg, u8 res);
+
#endif
diff --git a/lib/acpi/acpigen.c b/lib/acpi/acpigen.c
index 7321a98c0f..57b295aa4e 100644
--- a/lib/acpi/acpigen.c
+++ b/lib/acpi/acpigen.c
@@ -74,6 +74,12 @@ void acpigen_pop_len(struct acpi_ctx *ctx)
p[2] = (len >> 12 & 0xff);
}
+void acpigen_emit_ext_op(struct acpi_ctx *ctx, uint op)
+{
+ acpigen_emit_byte(ctx, EXT_OP_PREFIX);
+ acpigen_emit_byte(ctx, op);
+}
+
char *acpigen_write_package(struct acpi_ctx *ctx, int nr_el)
{
char *p;
@@ -253,6 +259,37 @@ void acpigen_write_name(struct acpi_ctx *ctx, const char
*namepath)
acpigen_emit_namestring(ctx, namepath);
}
+static void acpigen_write_me