Patrick Georgi has submitted this change. ( https://review.coreboot.org/c/coreboot/+/56003 )
Change subject: acpi: Add function to simplify If (CondRefOf (..)) sequences ......................................................................
acpi: Add function to simplify If (CondRefOf (..)) sequences
The new function is called acpigen_write_if_cond_refof(), and it must be paired with a following acpigen_write_if_end() call.
Change-Id: I6e192a569f550ecb77ad264275d52f219eacaca1 Signed-off-by: Tim Wawrzynczak twawrzynczak@chromium.org Reviewed-on: https://review.coreboot.org/c/coreboot/+/56003 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Patrick Georgi pgeorgi@google.com --- M src/acpi/acpigen.c M src/include/acpi/acpigen.h 2 files changed, 17 insertions(+), 0 deletions(-)
Approvals: build bot (Jenkins): Verified Patrick Georgi: Looks good to me, approved
diff --git a/src/acpi/acpigen.c b/src/acpi/acpigen.c index 9818dc2..8320b6c 100644 --- a/src/acpi/acpigen.c +++ b/src/acpi/acpigen.c @@ -1501,6 +1501,21 @@ acpigen_write_integer(val); }
+/* + * Generates ACPI code to check at runtime if an object named `namestring` + * exists, and leaves the If scope open to continue execute code when this + * is true. NOTE: Requires matching acpigen_write_if_end(). + * + * If (CondRefOf (NAME)) + */ +void acpigen_write_if_cond_ref_of(const char *namestring) +{ + acpigen_write_if(); + acpigen_emit_ext_op(COND_REFOF_OP); + acpigen_emit_namestring(namestring); + acpigen_emit_byte(ZERO_OP); /* ignore COND_REFOF_OP destination */ +} + /* Closes previously opened if statement and generates ACPI code for else statement. */ void acpigen_write_else(void) { diff --git a/src/include/acpi/acpigen.h b/src/include/acpi/acpigen.h index 2d0bb77..09ec4bc 100644 --- a/src/include/acpi/acpigen.h +++ b/src/include/acpi/acpigen.h @@ -415,6 +415,8 @@ { acpigen_pop_len(); } +/* Emits If (CondRefOf(NAME)) */ +void acpigen_write_if_cond_ref_of(const char *namestring); void acpigen_write_else(void); void acpigen_write_shiftleft_op_int(uint8_t src_result, uint64_t count); void acpigen_write_to_buffer(uint8_t src, uint8_t dst);