diff mbox

[Xen-devel,v2,06/17] libxl/arm: Construct ACPI XSDT table

Message ID 1466651824-6964-7-git-send-email-zhaoshenglong@huawei.com
State New
Headers show

Commit Message

Shannon Zhao June 23, 2016, 3:16 a.m. UTC
From: Shannon Zhao <shannon.zhao@linaro.org>

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 tools/libxl/libxl_arm_acpi.c | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
diff mbox

Patch

diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c
index 5f332fa..d5ffedf 100644
--- a/tools/libxl/libxl_arm_acpi.c
+++ b/tools/libxl/libxl_arm_acpi.c
@@ -36,6 +36,9 @@  typedef uint64_t u64;
 #include <acpi/acconfig.h>
 #include <acpi/actbl.h>
 
+#define ACPI_BUILD_APPNAME6 "XenARM"
+#define ACPI_BUILD_APPNAME4 "Xen "
+
 enum {
     RSDP,
     XSDT,
@@ -71,6 +74,42 @@  static void make_acpi_rsdp(libxl__gc *gc, struct xc_dom_image *dom)
     dom->acpitable_size += ROUNDUP(acpitables[RSDP].size, 3);
 }
 
+static void make_acpi_header(struct acpi_table_header *h, const char *sig,
+                             int len, uint8_t rev)
+{
+    memcpy(h->signature, sig, 4);
+    h->length = len;
+    h->revision = rev;
+    memcpy(h->oem_id, ACPI_BUILD_APPNAME6, 6);
+    memcpy(h->oem_table_id, ACPI_BUILD_APPNAME4, 4);
+    memcpy(h->oem_table_id + 4, sig, 4);
+    h->oem_revision = 1;
+    memcpy(h->asl_compiler_id, ACPI_BUILD_APPNAME4, 4);
+    h->asl_compiler_revision = 1;
+    h->checksum = 0;
+}
+
+static void make_acpi_xsdt(libxl__gc *gc, struct xc_dom_image *dom)
+{
+    uint32_t size;
+    struct acpi_table_xsdt *xsdt;
+
+    /*
+     * Currently only 3 tables(GTDT, FADT, MADT) are pointed by XSDT. Alloc
+     * entries for them but the entry values will be specified when the tables
+     * are linked together later.
+     */
+    size = sizeof(*xsdt) + sizeof(uint64_t) * 2;
+    xsdt = libxl__zalloc(gc, size);
+
+    make_acpi_header(&xsdt->header, "XSDT", size, 1);
+
+    acpitables[XSDT].table = xsdt;
+    acpitables[XSDT].size = size;
+    /* Align to 64bit. */
+    dom->acpitable_size += ROUNDUP(acpitables[XSDT].size, 3);
+}
+
 int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
                         libxl__domain_build_state *state,
                         struct xc_dom_image *dom)
@@ -92,6 +131,7 @@  int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
     dom->acpitable_size = 0;
 
     make_acpi_rsdp(gc, dom);
+    make_acpi_xsdt(gc, dom);
 
     return 0;
 }