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 <felix-coreboot@felixheld.de>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86464
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Matt DeVillier <matt.devillier@gmail.com>
This commit is contained in:
Felix Held 2025-02-14 20:32:05 +01:00
commit 4a2a3e7b96
2 changed files with 60 additions and 0 deletions

View file

@ -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.

View file

@ -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)
{