diff mbox

[v4,13/20] hw/acpi/aml-build: Add ToUUID macro

Message ID 1428055432-12120-14-git-send-email-zhaoshenglong@huawei.com
State New
Headers show

Commit Message

Shannon Zhao April 3, 2015, 10:03 a.m. UTC
From: Shannon Zhao <shannon.zhao@linaro.org>

Add ToUUID macro, this is useful for generating PCIe ACPI table.

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 hw/acpi/aml-build.c         | 23 +++++++++++++++++++++++
 include/hw/acpi/aml-build.h |  2 ++
 2 files changed, 25 insertions(+)
diff mbox

Patch

diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index bd1713c..5a94fc9 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -933,6 +933,29 @@  Aml *aml_qword_memory(AmlDecode dec, AmlMinFixed min_fixed,
                              addr_trans, len, flags);
 }
 
+/*
+ * ACPI 3.0: 17.5.124 ToUUID (Convert String to UUID Macro)
+ * e.g. UUID: E5C937D0-3553-4d7a-9117-EA4D19C3434D
+ * call aml_touuid(0xE5C937D0, 0x3553, 0x4d7a, 0x9117, 0xEA4D19C3434D);
+ */
+Aml *aml_touuid(int32_t val1, int16_t val2, int16_t val3,
+                int16_t val4, int64_t val5)
+{
+    int i;
+    Aml *UUID = aml_buffer();
+
+    build_append_int_noprefix(UUID->buf, val1, 4);
+    build_append_int_noprefix(UUID->buf, val2, 2);
+    build_append_int_noprefix(UUID->buf, val3, 2);
+    build_append_int_noprefix(UUID->buf, (val4 >> 8) & 0xFF, 1);
+    build_append_int_noprefix(UUID->buf, val4 & 0xFF, 1);
+    for (i = 40; i >= 0; i -= 8) {
+        build_append_int_noprefix(UUID->buf, (val5 >> i) & 0xFF, 1);
+    }
+
+    return UUID;
+}
+
 void
 build_header(GArray *linker, GArray *table_data,
              AcpiTableHeader *h, const char *sig, int len, uint8_t rev)
diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h
index 315c729..942d986 100644
--- a/include/hw/acpi/aml-build.h
+++ b/include/hw/acpi/aml-build.h
@@ -209,6 +209,8 @@  Aml *aml_buffer(void);
 Aml *aml_resource_template(void);
 Aml *aml_field(const char *name, AmlFieldFlags flags);
 Aml *aml_varpackage(uint32_t num_elements);
+Aml *aml_touuid(int32_t val1, int16_t val2, int16_t val3,
+                int16_t val4, int64_t val5);
 
 void
 build_header(GArray *linker, GArray *table_data,