From 56b69aa9c7d5628dec0d6345c29fb0a1cfeae9fc Mon Sep 17 00:00:00 2001 From: Duncan Laurie Date: Mon, 9 May 2016 08:17:02 -0700 Subject: acpigen: Add helper functions for strings Add helper function to emit a string into the SSDT AML bytestream with a NULL terminator. Also add a helper function to emit the string OpCode followed by the string itself. acpigen_emit_string(string) /* Raw string output */ acpigen_write_string(string) /* OpCode followed by raw string */ Change-Id: I4a3a8728066e0c41d7ad6429fad983e6ae6962fe Signed-off-by: Duncan Laurie Reviewed-on: https://review.coreboot.org/14793 Reviewed-by: Aaron Durbin Tested-by: build bot (Jenkins) --- src/arch/x86/acpigen.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/arch/x86/acpigen.c') diff --git a/src/arch/x86/acpigen.c b/src/arch/x86/acpigen.c index a612149ef2..f274ea2177 100644 --- a/src/arch/x86/acpigen.c +++ b/src/arch/x86/acpigen.c @@ -141,6 +141,12 @@ void acpigen_write_name_qword(const char *name, uint64_t val) acpigen_write_qword(val); } +void acpigen_write_name_string(const char *name, const char *string) +{ + acpigen_write_name(name); + acpigen_write_string(string); +} + void acpigen_emit_stream(const char *data, int size) { int i; @@ -149,6 +155,18 @@ void acpigen_emit_stream(const char *data, int size) } } +void acpigen_emit_string(const char *string) +{ + acpigen_emit_stream(string, string ? 0 : strlen(string)); + acpigen_emit_byte('\0'); /* NUL */ +} + +void acpigen_write_string(const char *string) +{ + acpigen_emit_byte(0x0d); + acpigen_emit_string(string); +} + /* * The naming conventions for ACPI namespace names are a bit tricky as * each element has to be 4 chars wide (»All names are a fixed 32 bits.«) -- cgit v1.2.3