@@ -33,6 +33,9 @@ extern const unsigned char dsdt_anycpu_arm[];
_hidden
extern const int dsdt_anycpu_arm_len;
+#define ACPI_BUILD_APPNAME6 "XenARM"
+#define ACPI_BUILD_APPNAME4 "Xen "
+
enum {
RSDP,
XSDT,
@@ -109,6 +112,36 @@ static int libxl__estimate_acpi_size(libxl__gc *gc,
return 0;
}
+static void calculate_checksum(void *table, uint32_t checksum_offset,
+ uint32_t length)
+{
+ uint8_t *p, sum = 0;
+
+ p = table;
+ p[checksum_offset] = 0;
+
+ while ( length-- )
+ sum = sum + *p++;
+
+ p = table;
+ p[checksum_offset] = -sum;
+}
+
+static void make_acpi_rsdp(libxl__gc *gc, struct xc_dom_image *dom,
+ struct acpitable acpitables[])
+{
+ uint64_t offset = acpitables[RSDP].addr - GUEST_ACPI_BASE;
+ struct acpi_table_rsdp *rsdp = dom->acpitable_blob + offset;
+
+ memcpy(rsdp->signature, "RSD PTR ", sizeof(rsdp->signature));
+ memcpy(rsdp->oem_id, ACPI_BUILD_APPNAME6, sizeof(rsdp->oem_id));
+ rsdp->length = acpitables[RSDP].size;
+ rsdp->revision = 0x02;
+ rsdp->xsdt_physical_address = acpitables[XSDT].addr;
+ calculate_checksum(rsdp, offsetof(struct acpi_table_rsdp, checksum),
+ acpitables[RSDP].size);
+}
+
int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
libxl__domain_build_state *state,
struct xc_dom_image *dom)
@@ -134,6 +167,8 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
if (rc)
return rc;
+ make_acpi_rsdp(gc, dom, acpitables);
+
return 0;
}