[coreboot-gerrit] New patch to review for coreboot: acpigen: Add helper functions for strings

Duncan Laurie (dlaurie@google.com) gerrit at coreboot.org
Thu May 12 22:40:51 CEST 2016


Duncan Laurie (dlaurie at google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/14793

-gerrit

commit e604880f4021dbc73ea5126406ac10ca42a0484f
Author: Duncan Laurie <dlaurie at chromium.org>
Date:   Mon May 9 08:17:02 2016 -0700

    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 <dlaurie at chromium.org>
---
 src/arch/x86/acpigen.c              | 24 ++++++++++++++++++++++++
 src/arch/x86/include/arch/acpigen.h |  3 +++
 2 files changed, 27 insertions(+)

diff --git a/src/arch/x86/acpigen.c b/src/arch/x86/acpigen.c
index 55a6fd0..3782982 100644
--- a/src/arch/x86/acpigen.c
+++ b/src/arch/x86/acpigen.c
@@ -142,6 +142,14 @@ 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)
+{
+	if (string) {
+		acpigen_write_name(name);
+		acpigen_write_string(string);
+	}
+}
+
 void acpigen_emit_stream(const char *data, int size)
 {
 	int i;
@@ -150,6 +158,22 @@ void acpigen_emit_stream(const char *data, int size)
 	}
 }
 
+void acpigen_emit_string(const char *string)
+{
+	if (!string)
+		return;
+	acpigen_emit_stream(string, strlen(string));
+	acpigen_emit_byte(0x00); /* null */
+}
+
+void acpigen_write_string(const char *string)
+{
+	if (!string)
+		return;
+	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.«)
diff --git a/src/arch/x86/include/arch/acpigen.h b/src/arch/x86/include/arch/acpigen.h
index 9323475..f718f51 100644
--- a/src/arch/x86/include/arch/acpigen.h
+++ b/src/arch/x86/include/arch/acpigen.h
@@ -32,12 +32,15 @@ void acpigen_emit_byte(unsigned char data);
 void acpigen_emit_word(unsigned int data);
 void acpigen_emit_dword(unsigned int data);
 void acpigen_emit_stream(const char *data, int size);
+void acpigen_emit_string(const char *string);
 void acpigen_emit_namestring(const char *namepath);
 void acpigen_emit_eisaid(const char *eisaid);
 void acpigen_write_word(unsigned int data);
 void acpigen_write_dword(unsigned int data);
 void acpigen_write_qword(uint64_t data);
+void acpigen_write_string(const char *string);
 void acpigen_write_name(const char *name);
+void acpigen_write_name_string(const char *name, const char *string);
 void acpigen_write_name_dword(const char *name, uint32_t val);
 void acpigen_write_name_qword(const char *name, uint64_t val);
 void acpigen_write_name_byte(const char *name, uint8_t val);



More information about the coreboot-gerrit mailing list