diff options
author | Cliff Huang <cliff.huang@intel.com> | 2023-02-18 00:17:26 -0800 |
---|---|---|
committer | Lean Sheng Tan <sheng.tan@9elements.com> | 2023-05-16 12:22:32 +0000 |
commit | 063a1b83f88bdfc090c60ebdfc111bc942958a1d (patch) | |
tree | bc9cc5f9d7b1651d2c98079bcaaf9e8f7e1f16bb /src | |
parent | 688350f33d49b1021d9762c82e4df26359e8e5c9 (diff) |
acpigen: Add printf-like function for debug string
Generate formatted string and ACPI code to print debug string.
For example (with pcie_rp = 1):
acpigen_write_debug_sprintf("calling _ON for RP: %u", pcie_rp);
generates the following ACPI code:
Debug = "calling _ON for RP: 1"
With this new function, the following functions are not needed anymore
and therefore are removed by this patch.
- acpigen_concatenate_string_string()
- acpigen_concatenate_string_int()
- acpigen_write_debug_concatenate_string_string()
- acpigen_write_debug_concatenate_string_int()
BRANCH=firmware-brya-14505.B
TEST=Add above functions in the acpigen code and check the generated
SSDT table after OS boot. Check the debug messages is in the
kernel log when /sys/modules/acpi/parameters/aml_debug_output is
set to '1'.
Change-Id: Id4a42e5854516a22b7bc4559c2ed08680722c5ba
Signed-off-by: Cliff Huang <cliff.huang@intel.com>
Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/73113
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Bora Guvendik <bora.guvendik@intel.com>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Zhixing Ma <zhixing.ma@intel.com>
Reviewed-by: Musse Abdullahi <musse.abdullahi@intel.corp-partner.google.com>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Lean Sheng Tan <sheng.tan@9elements.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/acpi/acpigen.c | 51 | ||||
-rw-r--r-- | src/include/acpi/acpigen.h | 7 |
2 files changed, 19 insertions, 39 deletions
diff --git a/src/acpi/acpigen.c b/src/acpi/acpigen.c index b85acbc9b4..fdf98cdda2 100644 --- a/src/acpi/acpigen.c +++ b/src/acpi/acpigen.c @@ -1448,24 +1448,6 @@ void acpigen_write_not(uint8_t arg, uint8_t res) acpigen_emit_byte(res); } -/* Concatenate (str1, str2, res) */ -void acpigen_concatenate_string_string(const char *str1, const char *str2, uint8_t res) -{ - acpigen_emit_byte(CONCATENATE_OP); - acpigen_write_string(str1); - acpigen_write_string(str2); - acpigen_emit_byte(res); -} - -/* Concatenate (str, val, tmp_res) */ -void acpigen_concatenate_string_int(const char *str, uint64_t val, uint8_t res) -{ - acpigen_emit_byte(CONCATENATE_OP); - acpigen_write_string(str); - acpigen_write_integer(val); - acpigen_emit_byte(res); -} - /* Concatenate (str, src_res, dest_res) */ void acpigen_concatenate_string_op(const char *str, uint8_t src_res, uint8_t dest_res) { @@ -1507,31 +1489,34 @@ void acpigen_write_debug_namestr(const char *str) acpigen_emit_ext_op(DEBUG_OP); } -/* Concatenate (str1, str2, tmp_res) +/* Concatenate (str1, res, tmp_res) Store(tmp_res, DEBUG) */ -void acpigen_write_debug_concatenate_string_string(const char *str1, const char *str2, +void acpigen_write_debug_concatenate_string_op(const char *str, uint8_t res, uint8_t tmp_res) { - acpigen_concatenate_string_string(str1, str2, tmp_res); + acpigen_concatenate_string_op(str, res, tmp_res); acpigen_write_debug_op(tmp_res); } -/* Concatenate (str1, val, tmp_res) - Store(tmp_res, DEBUG) */ -void acpigen_write_debug_concatenate_string_int(const char *str, uint64_t val, - uint8_t tmp_res) +static void acpigen_tx_byte(unsigned char byte, void *data) { - acpigen_concatenate_string_int(str, val, tmp_res); - acpigen_write_debug_op(tmp_res); + acpigen_emit_byte(byte); } -/* Concatenate (str1, res, tmp_res) - Store(tmp_res, DEBUG) */ -void acpigen_write_debug_concatenate_string_op(const char *str, uint8_t res, - uint8_t tmp_res) +/* Store("formatted string", DEBUG) */ +void acpigen_write_debug_sprintf(const char *fmt, ...) { - acpigen_concatenate_string_op(str, res, tmp_res); - acpigen_write_debug_op(tmp_res); + va_list args; + + acpigen_write_store(); + + acpigen_emit_byte(STRING_PREFIX); + va_start(args, fmt); + vtxprintf(acpigen_tx_byte, fmt, args, NULL); + va_end(args); + acpigen_emit_byte('\0'); + + acpigen_emit_ext_op(DEBUG_OP); } void acpigen_write_if(void) diff --git a/src/include/acpi/acpigen.h b/src/include/acpi/acpigen.h index 35d14ab350..614cd6e713 100644 --- a/src/include/acpi/acpigen.h +++ b/src/include/acpi/acpigen.h @@ -495,18 +495,13 @@ void acpigen_write_or(uint8_t arg1, uint8_t arg2, uint8_t res); void acpigen_write_xor(uint8_t arg1, uint8_t arg2, uint8_t res); void acpigen_write_and(uint8_t arg1, uint8_t arg2, uint8_t res); void acpigen_write_not(uint8_t arg, uint8_t res); -void acpigen_concatenate_string_string(const char *str1, const char *str2, uint8_t res); -void acpigen_concatenate_string_int(const char *str, uint64_t val, uint8_t res); void acpigen_concatenate_string_op(const char *str, uint8_t src_res, uint8_t dest_res); void acpigen_write_debug_string(const char *str); void acpigen_write_debug_namestr(const char *str); void acpigen_write_debug_integer(uint64_t val); void acpigen_write_debug_op(uint8_t op); -void acpigen_write_debug_concatenate_string_string(const char *str1, const char *str2, - uint8_t tmp_res); -void acpigen_write_debug_concatenate_string_int(const char *str1, uint64_t val, - uint8_t tmp_res); void acpigen_write_debug_concatenate_string_op(const char *str1, uint8_t res, uint8_t tmp_res); +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); |