From 24f3dc8a17240c6869e247c99c94a96af94be0ef Mon Sep 17 00:00:00 2001 From: Cliff Huang Date: Sat, 4 Feb 2023 21:11:51 -0800 Subject: src/acpi: add function gen: if_lgreater_ and namestr assignment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. add functions to generate if greater than conditions: acpigen_write_if_lgreater_op_op: if (op1 > op2) acpigen_write_if_lgreater_op_int: if (op > val) acpigen_write_if_lgreater_namestr_int: if (namestr > val) 2. add function to assignal value to a namestr acpigen_write_store_namestr_to_op: namestr = val TEST=Use above functions and check the generated SSDT table after OS boot. Signed-off-by: Cliff Huang Change-Id: Iffe1b23362a7ab58bdc2aa8daf45cd6f086ee818 Reviewed-on: https://review.coreboot.org/c/coreboot/+/72825 Reviewed-by: Eric Lai Reviewed-by: Jérémy Compostella Reviewed-by: Anil Kumar K Tested-by: build bot (Jenkins) --- src/acpi/acpigen.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'src/acpi/acpigen.c') diff --git a/src/acpi/acpigen.c b/src/acpi/acpigen.c index b6a409eb96..63953b86b1 100644 --- a/src/acpi/acpigen.c +++ b/src/acpi/acpigen.c @@ -1369,6 +1369,14 @@ void acpigen_write_store_int_to_namestr(uint64_t src, const char *dst) acpigen_emit_namestring(dst); } +/* Store ("namestr", dst) */ +void acpigen_write_store_namestr_to_op(const char *src, uint8_t dst) +{ + acpigen_write_store(); + acpigen_emit_namestring(src); + acpigen_emit_byte(dst); +} + /* Store (src, dst) */ void acpigen_write_store_int_to_op(uint64_t src, uint8_t dst) { @@ -1527,6 +1535,20 @@ void acpigen_write_if_lequal_op_op(uint8_t op1, uint8_t op2) acpigen_emit_byte(op2); } +/* + * Generates ACPI code for checking if operand1 is greater than operand2. + * Both operand1 and operand2 are ACPI ops. + * + * If (Lgreater (op1 op2)) + */ +void acpigen_write_if_lgreater_op_op(uint8_t op1, uint8_t op2) +{ + acpigen_write_if(); + acpigen_emit_byte(LGREATER_OP); + acpigen_emit_byte(op1); + acpigen_emit_byte(op2); +} + /* * Generates ACPI code for checking if operand1 and operand2 are equal, where, * operand1 is ACPI op and operand2 is an integer. @@ -1541,6 +1563,20 @@ void acpigen_write_if_lequal_op_int(uint8_t op, uint64_t val) 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. + * + * If (Lgreater (op, val)) + */ +void acpigen_write_if_lgreater_op_int(uint8_t op, uint64_t val) +{ + acpigen_write_if(); + acpigen_emit_byte(LGREATER_OP); + acpigen_emit_byte(op); + acpigen_write_integer(val); +} + /* * Generates ACPI code for checking if operand1 and operand2 are equal, where, * operand1 is namestring and operand2 is an integer. @@ -1555,6 +1591,20 @@ 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 equal, where, + * operand1 is namestring and operand2 is an integer. + * + * If (Lgreater ("namestr", val)) + */ +void acpigen_write_if_lgreater_namestr_int(const char *namestr, uint64_t val) +{ + acpigen_write_if(); + acpigen_emit_byte(LGREATER_OP); + acpigen_emit_namestring(namestr); + 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 -- cgit v1.2.3