Aaron Durbin has uploaded this change for review.

View Change

acpi: add more AML generation functions

Add the following functions to acpi AML generation code:

acpigen_write_to_integer_from_namestring()
acpigen_write_create_byte_field()
acpigen_write_create_word_field()
acpigen_write_create_dword_field()
acpigen_write_create_qword_field()

BUG=b:163583825

Change-Id: Ida151aff68f90012b16df2383fb96ddb87c3fb9c
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
---
M src/acpi/acpigen.c
M src/include/acpi/acpigen.h
2 files changed, 40 insertions(+), 0 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/41/44641/1
diff --git a/src/acpi/acpigen.c b/src/acpi/acpigen.c
index f218706..a82a66e 100644
--- a/src/acpi/acpigen.c
+++ b/src/acpi/acpigen.c
@@ -1353,6 +1353,13 @@
acpigen_emit_byte(dst);
}

+void acpigen_write_to_integer_from_namestring(const char *source, uint8_t dst_op)
+{
+ acpigen_emit_byte(TO_INTEGER_OP);
+ acpigen_emit_namestring(source);
+ acpigen_emit_byte(dst_op);
+}
+
void acpigen_write_byte_buffer(uint8_t *arr, size_t size)
{
size_t i;
@@ -1971,3 +1978,31 @@
acpigen_emit_namestring(namestr);
acpigen_write_integer(value);
}
+
+static void _create_field(uint8_t aml_op, uint8_t srcop, size_t byte_offset, const char *name)
+{
+ acpigen_emit_byte(aml_op);
+ acpigen_emit_byte(srcop);
+ acpigen_write_integer(byte_offset);
+ acpigen_emit_namestring(name);
+}
+
+void acpigen_write_create_byte_field(uint8_t op, size_t byte_offset, const char *name)
+{
+ _create_field(CREATE_BYTE_OP, op, byte_offset, name);
+}
+
+void acpigen_write_create_word_field(uint8_t op, size_t byte_offset, const char *name)
+{
+ _create_field(CREATE_WORD_OP, op, byte_offset, name);
+}
+
+void acpigen_write_create_dword_field(uint8_t op, size_t byte_offset, const char *name)
+{
+ _create_field(CREATE_DWORD_OP, op, byte_offset, name);
+}
+
+void acpigen_write_create_qword_field(uint8_t op, size_t byte_offset, const char *name)
+{
+ _create_field(CREATE_QWORD_OP, op, byte_offset, name);
+}
diff --git a/src/include/acpi/acpigen.h b/src/include/acpi/acpigen.h
index 4525b6b..e44926f 100644
--- a/src/include/acpi/acpigen.h
+++ b/src/include/acpi/acpigen.h
@@ -368,6 +368,7 @@
void acpigen_write_else(void);
void acpigen_write_to_buffer(uint8_t src, uint8_t dst);
void acpigen_write_to_integer(uint8_t src, uint8_t dst);
+void acpigen_write_to_integer_from_namestring(const char *source, uint8_t dst_op);
void acpigen_write_byte_buffer(uint8_t *arr, size_t size);
void acpigen_write_return_byte_buffer(uint8_t *arr, size_t size);
void acpigen_write_return_singleton_buffer(uint8_t arg);
@@ -380,6 +381,10 @@
void acpigen_write_ADR_pci_device(const struct device *dev);
struct soundwire_address;
void acpigen_write_ADR_soundwire_device(const struct soundwire_address *address);
+void acpigen_write_create_byte_field(uint8_t op, size_t byte_offset, const char *name);
+void acpigen_write_create_word_field(uint8_t op, size_t byte_offset, const char *name);
+void acpigen_write_create_dword_field(uint8_t op, size_t byte_offset, const char *name);
+void acpigen_write_create_qword_field(uint8_t op, size_t byte_offset, const char *name);
/*
* Generate ACPI AML code for _DSM method.
* This function takes as input uuid for the device, set of callbacks and

To view, visit change 44641. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Ida151aff68f90012b16df2383fb96ddb87c3fb9c
Gerrit-Change-Number: 44641
Gerrit-PatchSet: 1
Gerrit-Owner: Aaron Durbin <adurbin@chromium.org>
Gerrit-MessageType: newchange