Re: [Xen-devel] [PATCH v3 07/17] libxl/arm: Construct ACPI RSDP table

2016-07-07 Thread Shannon Zhao


On 2016/7/8 6:43, Boris Ostrovsky wrote:
>> +calculate_checksum(rsdp, offsetof(struct acpi_table_rsdp, checksum),
>> > +   acpitables[RSDP].size);
> Should this be extended_checksum? checksum is for ACPI v1 (and thus for
> smaller size structure, with only RSDT pointer).
Ah, right. Will fix this.

Thanks,
-- 
Shannon


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v3 07/17] libxl/arm: Construct ACPI RSDP table

2016-07-07 Thread Boris Ostrovsky
On 07/04/2016 11:12 PM, Shannon Zhao wrote:
> From: Shannon Zhao 
>
> Construct ACPI RSDP table and add a helper to calculate the ACPI table
> checksum.
>
> Signed-off-by: Shannon Zhao 
> ---
>  tools/libxl/libxl_arm_acpi.c | 35 +++
>  1 file changed, 35 insertions(+)
>
> diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c
> index 7a59126..9df1573 100644
> --- a/tools/libxl/libxl_arm_acpi.c
> +++ b/tools/libxl/libxl_arm_acpi.c
> @@ -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);

Should this be extended_checksum? checksum is for ACPI v1 (and thus for
smaller size structure, with only RSDT pointer).

-boris


> +}
> +
>  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;
>  }
>  




___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v3 07/17] libxl/arm: Construct ACPI RSDP table

2016-07-04 Thread Shannon Zhao
From: Shannon Zhao 

Construct ACPI RSDP table and add a helper to calculate the ACPI table
checksum.

Signed-off-by: Shannon Zhao 
---
 tools/libxl/libxl_arm_acpi.c | 35 +++
 1 file changed, 35 insertions(+)

diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c
index 7a59126..9df1573 100644
--- a/tools/libxl/libxl_arm_acpi.c
+++ b/tools/libxl/libxl_arm_acpi.c
@@ -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;
 }
 
-- 
2.0.4



___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel