Patrick Georgi has submitted this change. ( https://review.coreboot.org/c/coreboot/+/50910 )
Change subject: acpi/acpigen.h: Add more intuitive AML package closing functions ......................................................................
acpi/acpigen.h: Add more intuitive AML package closing functions
Until now every AML package had to be closed using acpigen_pop_len(). This commit introduces set of package closing functions corresponding with their opening function names. For example acpigen_write_if() opens if-statement package, acpigen_write_if_end() closes it. Now acpigen_write_else() closes previously opened acpigen_write_if(), so acpigen_pop_len() is not required before it.
Signed-off-by: Jakub Czapiga jacz@semihalf.com Change-Id: Icfdc3804cd93bde049cd11dec98758b3a639eafd Reviewed-on: https://review.coreboot.org/c/coreboot/+/50910 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Lance Zhao Reviewed-by: Angel Pons th3fanbus@gmail.com --- M Documentation/acpi/gpio.md M src/acpi/acpigen.c M src/acpi/acpigen_dsm.c M src/drivers/intel/usb4/retimer/retimer.c M src/include/acpi/acpigen.h M src/soc/amd/common/block/graphics/graphics.c M src/soc/amd/picasso/pcie_gpp.c M src/soc/amd/picasso/root_complex.c M src/soc/amd/stoneyridge/acpi.c M src/soc/intel/apollolake/acpi.c M src/soc/intel/common/block/pcie/rtd3/rtd3.c M src/southbridge/intel/common/acpi_pirq_gen.c M src/superio/nuvoton/npcd378/superio.c 13 files changed, 30 insertions(+), 16 deletions(-)
Approvals: build bot (Jenkins): Verified Lance Zhao: Looks good to me, approved Angel Pons: Looks good to me, but someone else must approve
diff --git a/Documentation/acpi/gpio.md b/Documentation/acpi/gpio.md index abde3a0..470a55f 100644 --- a/Documentation/acpi/gpio.md +++ b/Documentation/acpi/gpio.md @@ -159,7 +159,6 @@ */ acpigen_write_if_and(Local5, TX_BIT); acpigen_write_store_args(ONE_OP, LOCAL0_OP); - acpigen_pop_len(); acpigen_write_else(); acpigen_write_store_args(ZERO_OP, LOCAL0_OP); acpigen_pop_len(); diff --git a/src/acpi/acpigen.c b/src/acpi/acpigen.c index b3e112d..1131729 100644 --- a/src/acpi/acpigen.c +++ b/src/acpi/acpigen.c @@ -1422,8 +1422,10 @@ acpigen_write_integer(val); }
+/* Closes previously opened if statement and generates ACPI code for else statement. */ void acpigen_write_else(void) { + acpigen_pop_len(); acpigen_emit_byte(ELSE_OP); acpigen_write_len_f(); } diff --git a/src/acpi/acpigen_dsm.c b/src/acpi/acpigen_dsm.c index fc53ddf..734fbd5 100644 --- a/src/acpi/acpigen_dsm.c +++ b/src/acpi/acpigen_dsm.c @@ -22,7 +22,6 @@ acpigen_write_if_lequal_op_int(LOCAL2_OP, 0x1); /* Return (Buffer (One) { 0x3 }) */ acpigen_write_return_singleton_buffer(0x3); - acpigen_pop_len(); /* Pop : If */ /* Else */ acpigen_write_else(); /* Return (Buffer (One) { 0x0 }) */ diff --git a/src/drivers/intel/usb4/retimer/retimer.c b/src/drivers/intel/usb4/retimer/retimer.c index 4e56d64..fad353b 100644 --- a/src/drivers/intel/usb4/retimer/retimer.c +++ b/src/drivers/intel/usb4/retimer/retimer.c @@ -77,7 +77,6 @@ */ acpigen_write_if_lequal_op_int(LOCAL0_OP, 0); acpigen_disable_tx_gpio(power_gpio); - acpigen_pop_len(); /* If */
/* * Else { diff --git a/src/include/acpi/acpigen.h b/src/include/acpi/acpigen.h index f7974eb..c798288 100644 --- a/src/include/acpi/acpigen.h +++ b/src/include/acpi/acpigen.h @@ -293,6 +293,10 @@ void acpigen_set_current(char *curr); char *acpigen_get_current(void); char *acpigen_write_package(int nr_el); +inline void acpigen_write_package_end(void) +{ + acpigen_pop_len(); +} void acpigen_write_zero(void); void acpigen_write_one(void); void acpigen_write_ones(void); @@ -319,9 +323,21 @@ void acpigen_write_name_integer(const char *name, uint64_t val); void acpigen_write_coreboot_hid(enum coreboot_acpi_ids id); void acpigen_write_scope(const char *name); +inline void acpigen_write_scope_end(void) +{ + acpigen_pop_len(); +} void acpigen_write_method(const char *name, int nargs); void acpigen_write_method_serialized(const char *name, int nargs); +inline void acpigen_write_method_end(void) +{ + acpigen_pop_len(); +} void acpigen_write_device(const char *name); +inline void acpigen_write_device_end(void) +{ + acpigen_pop_len(); +} void acpigen_write_PPC(u8 nr); void acpigen_write_PPC_NVS(void); void acpigen_write_empty_PCT(void); @@ -345,6 +361,10 @@ void acpigen_write_xpss_object(const struct acpi_xpss_sw_pstate *pstate_values, size_t nentries); void acpigen_write_processor(u8 cpuindex, u32 pblock_addr, u8 pblock_len); +inline void acpigen_write_processor_end(void) +{ + acpigen_pop_len(); +} void acpigen_write_processor_package(const char *name, unsigned int first_core, unsigned int core_count); @@ -362,6 +382,10 @@ void acpigen_write_uuid(const char *uuid); void acpigen_write_power_res(const char *name, uint8_t level, uint16_t order, const char * const dev_states[], size_t dev_states_count); +inline void acpigen_write_power_res_end(void) +{ + acpigen_pop_len(); +} void acpigen_write_sleep(uint64_t sleep_ms); void acpigen_write_store(void); void acpigen_write_store_int_to_namestr(uint64_t src, const char *dst); @@ -381,6 +405,10 @@ void acpigen_write_if_lequal_op_op(uint8_t op, uint8_t val); void acpigen_write_if_lequal_op_int(uint8_t op, uint64_t val); void acpigen_write_if_lequal_namestr_int(const char *namestr, uint64_t val); +inline void acpigen_write_if_end(void) +{ + acpigen_pop_len(); +} 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); diff --git a/src/soc/amd/common/block/graphics/graphics.c b/src/soc/amd/common/block/graphics/graphics.c index 942a803..82b437b 100644 --- a/src/soc/amd/common/block/graphics/graphics.c +++ b/src/soc/amd/common/block/graphics/graphics.c @@ -76,7 +76,6 @@ /* Return (Buffer (0x0C) { ... } */ acpigen_write_return_byte_buffer((uint8_t *)(void *)&verify_output, sizeof(verify_output)); - acpigen_pop_len(); /* if (LEqual(Local0, 0) */
/* ElseIf ((Local0 == 0x10)) */ acpigen_write_else(); @@ -92,7 +91,6 @@ /* Return (Buffer (0x0A) { ... } */ acpigen_write_return_byte_buffer((uint8_t *)(void *)&brightness_out, sizeof(brightness_out)); - acpigen_pop_len(); /* if (LEqual(Local2, ATIF_QBTC_REQUEST_LCD1) */ /* Else */ acpigen_write_else(); /* Return (Buffer (0x0A) */ diff --git a/src/soc/amd/picasso/pcie_gpp.c b/src/soc/amd/picasso/pcie_gpp.c index baa9fa3..582e128 100644 --- a/src/soc/amd/picasso/pcie_gpp.c +++ b/src/soc/amd/picasso/pcie_gpp.c @@ -149,7 +149,6 @@ acpigen_pop_len(); } acpigen_pop_len(); /* Package - APIC Routing */ - acpigen_pop_len(); /* End If */
/* Else */ acpigen_write_else(); diff --git a/src/soc/amd/picasso/root_complex.c b/src/soc/amd/picasso/root_complex.c index c954701..292ee20 100644 --- a/src/soc/amd/picasso/root_complex.c +++ b/src/soc/amd/picasso/root_complex.c @@ -228,8 +228,6 @@ dptc_call_alib("TABB", (uint8_t *)(void *)&tablet_mode_input, sizeof(tablet_mode_input));
- acpigen_pop_len(); /* If */ - /* Else */ acpigen_write_else();
diff --git a/src/soc/amd/stoneyridge/acpi.c b/src/soc/amd/stoneyridge/acpi.c index 8b97ace..de79ec3 100644 --- a/src/soc/amd/stoneyridge/acpi.c +++ b/src/soc/amd/stoneyridge/acpi.c @@ -187,8 +187,6 @@ /* Store (One, Local0) */ acpigen_write_store_ops(ONE_OP, LOCAL0_OP);
- acpigen_pop_len(); /* If */ - /* Else */ acpigen_write_else();
diff --git a/src/soc/intel/apollolake/acpi.c b/src/soc/intel/apollolake/acpi.c index 219ea95..34f760f 100644 --- a/src/soc/intel/apollolake/acpi.c +++ b/src/soc/intel/apollolake/acpi.c @@ -255,8 +255,6 @@ /* Store (One, Local0) */ acpigen_write_store_ops(ONE_OP, LOCAL0_OP);
- acpigen_pop_len(); /* If */ - /* Else */ acpigen_write_else();
diff --git a/src/soc/intel/common/block/pcie/rtd3/rtd3.c b/src/soc/intel/common/block/pcie/rtd3/rtd3.c index be412e7..5a04333 100644 --- a/src/soc/intel/common/block/pcie/rtd3/rtd3.c +++ b/src/soc/intel/common/block/pcie/rtd3/rtd3.c @@ -158,7 +158,6 @@
acpigen_write_if_lequal_op_op(LOCAL0_OP, LOCAL1_OP); acpigen_write_return_op(ZERO_OP); - acpigen_pop_len(); /* If */ acpigen_write_else(); acpigen_write_return_op(ONE_OP); acpigen_pop_len(); /* Else */ diff --git a/src/southbridge/intel/common/acpi_pirq_gen.c b/src/southbridge/intel/common/acpi_pirq_gen.c index 6100be8..73d1019 100644 --- a/src/southbridge/intel/common/acpi_pirq_gen.c +++ b/src/southbridge/intel/common/acpi_pirq_gen.c @@ -94,7 +94,6 @@ acpigen_write_package(num_devs); gen_pirq_route(EMIT_APIC, lpcb_path, pci_int_mapping); acpigen_pop_len(); /* package */ - acpigen_pop_len(); /* if PICM */ acpigen_write_else(); acpigen_emit_byte(RETURN_OP); acpigen_write_package(num_devs); diff --git a/src/superio/nuvoton/npcd378/superio.c b/src/superio/nuvoton/npcd378/superio.c index b7f98af..801592d 100644 --- a/src/superio/nuvoton/npcd378/superio.c +++ b/src/superio/nuvoton/npcd378/superio.c @@ -248,7 +248,6 @@ acpigen_write_integer(0xE8); acpigen_emit_namestring("^GPE2");
- acpigen_pop_len(); /* Pop If */ acpigen_write_else();
acpigen_emit_byte(AND_OP); @@ -268,7 +267,6 @@ acpigen_write_integer(0x10); acpigen_emit_namestring("^GPE2");
- acpigen_pop_len(); /* Pop If */ acpigen_write_else();
acpigen_emit_byte(AND_OP);