[coreboot-gerrit] Patch set updated for coreboot: acpigen: Add function to generate ToUUID() from a string

Duncan Laurie (dlaurie@google.com) gerrit at coreboot.org
Sat May 21 00:39:24 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/14838

-gerrit

commit 5ec0086f5783e4a82bd021e0f0cf7f4de5954357
Author: Duncan Laurie <dlaurie at chromium.org>
Date:   Mon May 9 11:08:46 2016 -0700

    acpigen: Add function to generate ToUUID() from a string
    
    acpigen_write_uuid() will generate a ToUUID() 128-bit buffer object for a
    common universally unique identifier that is passed as a string.  The
    resulting buffer is the UUID in byte format with a specific order of the
    bytes as described in the ACPI specification:
    
      ToUUID (uuid)
    
    Compiles to:
    
      Buffer (16) { uuid[3], uuid[2], uuid[1], uuid[0], uuid[5], uuid[4],
                    uuid[7], uuid[6], uuid[8], uuid[9], uuid[10], uuid[11],
                    uuid[12], uuid[13], uuid[14], uuid[15] }
    
    Change-Id: Ibbeff926883532dd78477aaa2d26ffffb6ef30c0
    Signed-off-by: Duncan Laurie <dlaurie at chromium.org>
---
 src/arch/x86/acpigen.c              | 36 ++++++++++++++++++++++++++++++++++++
 src/arch/x86/include/arch/acpigen.h |  1 +
 2 files changed, 37 insertions(+)

diff --git a/src/arch/x86/acpigen.c b/src/arch/x86/acpigen.c
index 226fba1..c370321 100644
--- a/src/arch/x86/acpigen.c
+++ b/src/arch/x86/acpigen.c
@@ -24,6 +24,7 @@
 
 #define ACPIGEN_MAXLEN 0xfffff
 
+#include <lib.h>
 #include <string.h>
 #include <arch/acpigen.h>
 #include <console/console.h>
@@ -827,3 +828,38 @@ void acpigen_emit_eisaid(const char *eisaid)
 	acpigen_emit_byte((compact >> 8) & 0xff);
 	acpigen_emit_byte(compact & 0xff);
 }
+
+/*
+ * ToUUID(uuid)
+ *
+ * ACPI 6.1 Section 19.6.136 table 19-385 defines a special output
+ * order for the bytes that make up a UUID Buffer object.
+ * UUID byte order for input:
+ *   aabbccdd-eeff-gghh-iijj-kkllmmnnoopp
+ * UUID byte order for output:
+ *   ddccbbaa-ffee-hhgg-iijj-kkllmmnnoopp
+ */
+#define UUID_LEN 16
+void acpigen_write_uuid(const char *uuid)
+{
+	uint8_t buf[UUID_LEN];
+	size_t i, order[UUID_LEN] = { 3, 2, 1, 0, 5, 4, 7, 6,
+				      8, 9, 10, 11, 12, 13, 14, 15 };
+
+	/* Parse UUID string into bytes */
+	if (hexstrtobin(uuid, buf, UUID_LEN) < UUID_LEN)
+		return;
+
+	/* BufferOp */
+	acpigen_emit_byte(0x11);
+	acpigen_write_len_f();
+
+	/* Buffer length in bytes */
+	acpigen_write_word(UUID_LEN);
+
+	/* Output UUID in expected order */
+	for (i = 0; i < UUID_LEN; i++)
+		acpigen_emit_byte(buf[order[i]]);
+
+	acpigen_pop_len();
+}
diff --git a/src/arch/x86/include/arch/acpigen.h b/src/arch/x86/include/arch/acpigen.h
index e968778..9e6ef29 100644
--- a/src/arch/x86/include/arch/acpigen.h
+++ b/src/arch/x86/include/arch/acpigen.h
@@ -92,6 +92,7 @@ void acpigen_write_resourcetemplate_footer(void);
 void acpigen_write_mainboard_resource_template(void);
 void acpigen_write_mainboard_resources(const char *scope, const char *name);
 void acpigen_write_irq(u16 mask);
+void acpigen_write_uuid(const char *uuid);
 
 int get_cst_entries(acpi_cstate_t **);
 



More information about the coreboot-gerrit mailing list