summaryrefslogtreecommitdiffstats
path: root/include/acpi/acpigen.h
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-07-07 13:11:51 -0600
committerBin Meng <bmeng.cn@gmail.com>2020-07-17 14:32:24 +0800
commit03967ce2e5e4332edd1e023360707a1086f42242 (patch)
treeb2b38e054b8a3a2bc35b81851d8186be1a9879e2 /include/acpi/acpigen.h
parent7e148f2ed365c89f50701ed45acd6e36138de447 (diff)
downloadu-boot-03967ce2e5e4332edd1e023360707a1086f42242.tar.gz
u-boot-03967ce2e5e4332edd1e023360707a1086f42242.tar.xz
u-boot-03967ce2e5e4332edd1e023360707a1086f42242.zip
acpigen: Support writing a package
A package collects together several elements. Add an easy way of writing a package header and updating its length later. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'include/acpi/acpigen.h')
-rw-r--r--include/acpi/acpigen.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/include/acpi/acpigen.h b/include/acpi/acpigen.h
index 18409b613c..c1a6bc263c 100644
--- a/include/acpi/acpigen.h
+++ b/include/acpi/acpigen.h
@@ -17,6 +17,11 @@ struct acpi_ctx;
/* Top 4 bits of the value used to indicate a three-byte length value */
#define ACPI_PKG_LEN_3_BYTES 0x80
+/* ACPI Op/Prefix codes */
+enum {
+ PACKAGE_OP = 0x12,
+};
+
/**
* acpigen_get_current() - Get the current ACPI code output pointer
*
@@ -106,4 +111,31 @@ void acpigen_write_len_f(struct acpi_ctx *ctx);
*/
void acpigen_pop_len(struct acpi_ctx *ctx);
+/**
+ * acpigen_write_package() - Start writing a package
+ *
+ * A package collects together a number of elements in the ACPI code. To write
+ * a package use:
+ *
+ * acpigen_write_package(ctx, 3);
+ * ...write things
+ * acpigen_pop_len()
+ *
+ * If you don't know the number of elements in advance, acpigen_write_package()
+ * returns a pointer to the value so you can update it later:
+ *
+ * char *num_elements = acpigen_write_package(ctx, 0);
+ * ...write things
+ * *num_elements += 1;
+ * ...write things
+ * *num_elements += 1;
+ * acpigen_pop_len()
+ *
+ * @ctx: ACPI context pointer
+ * @nr_el: Number of elements (0 if not known)
+ * @returns pointer to the number of elements, which can be updated by the
+ * caller if needed
+ */
+char *acpigen_write_package(struct acpi_ctx *ctx, int nr_el);
+
#endif