From e608308adebc058f47eb7c51721ae0f077018691 Mon Sep 17 00:00:00 2001 From: Cliff Huang Date: Thu, 19 Jan 2023 21:18:23 -0800 Subject: [PATCH] src/acpi: add debug message with concatenated string MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit add functions for concatenate OP add debug message containing concatenated string with string, value, or OPs Ex1: to print string with another string provided from C side: acpigen_write_debug_concatenate_string_string("Wait loop Timeout! var=", name, LOCAL6_OP); will generate: Concatenate ("Wait loop Timeout! var=", "L23E", Local6) Debug = Local6 Ex2: to print string with a value: acpigen_write_debug_concatenate_string_int("ModPHY enabling for RP:", pcie_rp, LOCAL0_OP); will generate: Concatenate ("ModPHY enabling for RP:", 0x05, Local0) Debug = Local0 Ex3: to print string with an ACPI OP: acpigen_write_debug_concatenate_string_op("while Loop count: ", LOCAL7_OP, LOCAL6_OP) will generate: Concatenate ("while Loop count: ", Local7, Local6) Debug = Local6 TEST=Add above functions in the acpigen code and check the generated SSDT table after OS boot Signed-off-by: Cliff Huang Change-Id: I370745efe3d6b513ec2c5376248362a3eb4b3d21 Reviewed-on: https://review.coreboot.org/c/coreboot/+/72126 Reviewed-by: Jérémy Compostella Tested-by: build bot (Jenkins) Reviewed-by: Bora Guvendik --- src/acpi/acpigen.c | 54 ++++++++++++++++++++++++++++++++++++++ src/include/acpi/acpigen.h | 8 ++++++ 2 files changed, 62 insertions(+) diff --git a/src/acpi/acpigen.c b/src/acpi/acpigen.c index 7afb839e5d..08915a9ea7 100644 --- a/src/acpi/acpigen.c +++ b/src/acpi/acpigen.c @@ -1402,6 +1402,33 @@ 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) +{ + acpigen_emit_byte(CONCATENATE_OP); + acpigen_write_string(str); + acpigen_emit_byte(src_res); + acpigen_emit_byte(dest_res); +} + /* Store (str, DEBUG) */ void acpigen_write_debug_string(const char *str) { @@ -1434,6 +1461,33 @@ void acpigen_write_debug_namestr(const char *str) acpigen_emit_ext_op(DEBUG_OP); } +/* Concatenate (str1, str2, tmp_res) + Store(tmp_res, DEBUG) */ +void acpigen_write_debug_concatenate_string_string(const char *str1, const char *str2, + uint8_t tmp_res) +{ + acpigen_concatenate_string_string(str1, str2, 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) +{ + acpigen_concatenate_string_int(str, val, tmp_res); + acpigen_write_debug_op(tmp_res); +} + +/* 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) +{ + acpigen_concatenate_string_op(str, res, tmp_res); + acpigen_write_debug_op(tmp_res); +} + void acpigen_write_if(void) { acpigen_emit_byte(IF_OP); diff --git a/src/include/acpi/acpigen.h b/src/include/acpi/acpigen.h index 789dd47dcd..bb36707f9c 100644 --- a/src/include/acpi/acpigen.h +++ b/src/include/acpi/acpigen.h @@ -485,10 +485,18 @@ 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_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);