From 4a2a3e7b96459668a5d130f3f8ea0fc05b06027c Mon Sep 17 00:00:00 2001 From: Felix Held Date: Fri, 14 Feb 2025 20:32:05 +0100 Subject: [PATCH] acpi/acpigen: implement acpigen_write_if_lnotequal_* Implement functions to write the AML bytes corresponding to 'If (LNotEqual (...))' which is equivalent to 'If (LNot (LEqual (...)))' for the value types combinations 2 OPs, OP and value, and namestring and value. TEST=Calling 'acpigen_write_if_lnotequal_op_int' results in the AML code sequence being written which decompiles to ASL as expected. Change-Id: I6c664bc4d30a49ae990eeb9f0e0776cac37efc57 Signed-off-by: Felix Held Reviewed-on: https://review.coreboot.org/c/coreboot/+/86464 Tested-by: build bot (Jenkins) Reviewed-by: Matt DeVillier --- src/acpi/acpigen.c | 57 ++++++++++++++++++++++++++++++++++++++ src/include/acpi/acpigen.h | 3 ++ 2 files changed, 60 insertions(+) diff --git a/src/acpi/acpigen.c b/src/acpi/acpigen.c index 308cf5ac85..eaf95e018f 100644 --- a/src/acpi/acpigen.c +++ b/src/acpi/acpigen.c @@ -1596,6 +1596,25 @@ void acpigen_write_if_lequal_op_op(uint8_t op1, uint8_t op2) acpigen_emit_byte(op2); } +/* + * Generates ACPI code for checking if operand1 and operand2 are not equal. + * Both operand1 and operand2 are ACPI ops. + * + * If (Lnotequal (op1, op2)) + * + * This is equivalent to + * + * If (Lnot (Lequal (op1, op2))) + */ +void acpigen_write_if_lnotequal_op_op(uint8_t op1, uint8_t op2) +{ + acpigen_write_if(); + acpigen_emit_byte(LNOT_OP); + acpigen_emit_byte(LEQUAL_OP); + acpigen_emit_byte(op1); + acpigen_emit_byte(op2); +} + /* * Generates ACPI code for checking if operand1 is greater than operand2. * Both operand1 and operand2 are ACPI ops. @@ -1624,6 +1643,25 @@ void acpigen_write_if_lequal_op_int(uint8_t op, uint64_t val) acpigen_write_integer(val); } +/* + * Generates ACPI code for checking if operand1 and operand2 are not equal, where, + * operand1 is ACPI op and operand2 is an integer. + * + * If (Lnotequal (op, val)) + * + * This is equivalent to + * + * If (Lnot (Lequal (op, val))) + */ +void acpigen_write_if_lnotequal_op_int(uint8_t op, uint64_t val) +{ + acpigen_write_if(); + acpigen_emit_byte(LNOT_OP); + acpigen_emit_byte(LEQUAL_OP); + acpigen_emit_byte(op); + acpigen_write_integer(val); +} + /* * Generates ACPI code for checking if operand is greater than the value, where, * operand is ACPI op and val is an integer. @@ -1652,6 +1690,25 @@ void acpigen_write_if_lequal_namestr_int(const char *namestr, uint64_t val) acpigen_write_integer(val); } +/* + * Generates ACPI code for checking if operand1 and operand2 are not equal, where, + * operand1 is namestring and operand2 is an integer. + * + * If (Lnotequal ("namestr", val)) + * + * * This is equivalent to + * + * If (Lnot (Lequal ("namestr", val))) + */ +void acpigen_write_if_lnotequal_namestr_int(const char *namestr, uint64_t val) +{ + acpigen_write_if(); + acpigen_emit_byte(LNOT_OP); + acpigen_emit_byte(LEQUAL_OP); + acpigen_emit_namestring(namestr); + acpigen_write_integer(val); +} + /* * Generates ACPI code for checking if operand1 and operand2 are equal, where, * operand1 is namestring and operand2 is an integer. diff --git a/src/include/acpi/acpigen.h b/src/include/acpi/acpigen.h index 8129263475..56b4f780f7 100644 --- a/src/include/acpi/acpigen.h +++ b/src/include/acpi/acpigen.h @@ -506,10 +506,13 @@ void acpigen_write_debug_sprintf(const char *fmt, ...) __printf(1, 2); void acpigen_write_if(void); void acpigen_write_if_and(uint8_t arg1, uint8_t arg2); void acpigen_write_if_lequal_op_op(uint8_t op, uint8_t val); +void acpigen_write_if_lnotequal_op_op(uint8_t op, uint8_t val); void acpigen_write_if_lgreater_op_op(uint8_t op1, uint8_t op2); void acpigen_write_if_lequal_op_int(uint8_t op, uint64_t val); +void acpigen_write_if_lnotequal_op_int(uint8_t op, uint64_t val); void acpigen_write_if_lgreater_op_int(uint8_t op, uint64_t val); void acpigen_write_if_lequal_namestr_int(const char *namestr, uint64_t val); +void acpigen_write_if_lnotequal_namestr_int(const char *namestr, uint64_t val); void acpigen_write_if_lgreater_namestr_int(const char *namestr, uint64_t val); __always_inline void acpigen_write_if_end(void) {