summaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
authorPatrick Rudolph <patrick.rudolph@9elements.com>2019-12-17 13:54:41 +0100
committerPatrick Rudolph <siro@das-labor.org>2020-01-07 08:16:20 +0000
commit389c8279432a4e213391ed21ef25707090fde7ef (patch)
treeec9f415937824893007f22e650e7c94a70178f85 /src/arch
parent2dd3b5c0f8e62505b4c2559518e4ddbd1fbd6aae (diff)
downloadcoreboot-389c8279432a4e213391ed21ef25707090fde7ef.tar.xz
acpigen: Add function to generate unicode names
The ACPI spec 6.3 chapter 6.1.10 states that _STR has to return a buffer containing UTF-16 characters. Add function to generate Unicode names and use it for _STR. It will replace non-ASCII characters with '?'. Use the introduced function in IPMI driver. Fixes ACPI warning shown in fwts. Change-Id: I16992bd449e3a51f6a8875731cd45a9f43de5c8c Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/37789 Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Philipp Deppenwiese <zaolin.daisuki@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/x86/acpigen.c15
-rw-r--r--src/arch/x86/include/arch/acpigen.h1
2 files changed, 16 insertions, 0 deletions
diff --git a/src/arch/x86/acpigen.c b/src/arch/x86/acpigen.c
index cc724a0cc1..493131eda1 100644
--- a/src/arch/x86/acpigen.c
+++ b/src/arch/x86/acpigen.c
@@ -199,6 +199,21 @@ void acpigen_write_name_string(const char *name, const char *string)
acpigen_write_string(string);
}
+void acpigen_write_name_unicode(const char *name, const char *string)
+{
+ const size_t len = strlen(string) + 1;
+ acpigen_write_name(name);
+ acpigen_emit_byte(BUFFER_OP);
+ acpigen_write_len_f();
+ acpigen_write_integer(len);
+ for (size_t i = 0; i < len; i++) {
+ const char c = string[i];
+ /* Simple ASCII to UTF-16 conversion, replace non ASCII characters */
+ acpigen_emit_word(c >= 0 ? c : '?');
+ }
+ acpigen_pop_len();
+}
+
void acpigen_emit_stream(const char *data, int size)
{
int i;
diff --git a/src/arch/x86/include/arch/acpigen.h b/src/arch/x86/include/arch/acpigen.h
index 11fe232272..c9a648505c 100644
--- a/src/arch/x86/include/arch/acpigen.h
+++ b/src/arch/x86/include/arch/acpigen.h
@@ -309,6 +309,7 @@ void acpigen_write_dword(unsigned int data);
void acpigen_write_qword(uint64_t data);
void acpigen_write_integer(uint64_t data);
void acpigen_write_string(const char *string);
+void acpigen_write_name_unicode(const char *name, const char *string);
void acpigen_write_name(const char *name);
void acpigen_write_name_zero(const char *name);
void acpigen_write_name_one(const char *name);