diff mbox

[Xen-devel,v2,12/17] libxl/arm: Add a helper to calculate the ACPI table checksum

Message ID 1466651824-6964-13-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 | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Julien Grall June 23, 2016, 5:05 p.m. UTC | #1
Hi Shannon,

On 23/06/16 04:16, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>   tools/libxl/libxl_arm_acpi.c | 15 +++++++++++++++
>   1 file changed, 15 insertions(+)
>
> diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c
> index 45fc354..d8779af 100644
> --- a/tools/libxl/libxl_arm_acpi.c
> +++ b/tools/libxl/libxl_arm_acpi.c
> @@ -270,6 +270,21 @@ static void make_acpi_dsdt(libxl__gc *gc, struct xc_dom_image *dom)
>       dom->acpitable_size += ROUNDUP(acpitables[DSDT].size, 3);
>   }
>
> +static void calculate_checksum(void *table, uint32_t checksum_offset,
> +                               uint32_t length)

This will break compilation and therefore bisection as nobody is using 
this function. Please make sure that all the patch can build one by one.

> +{
> +    uint8_t *p, sum = 0;
> +
> +    p = table;
> +    p[checksum_offset] = 0;
> +
> +    while ( length-- )
> +        sum = sum + *p++;
> +
> +    p = table;
> +    p[checksum_offset] = -sum;
> +}
> +
>   int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
>                           libxl__domain_build_state *state,
>                           struct xc_dom_image *dom)
>

Regards,
diff mbox

Patch

diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c
index 45fc354..d8779af 100644
--- a/tools/libxl/libxl_arm_acpi.c
+++ b/tools/libxl/libxl_arm_acpi.c
@@ -270,6 +270,21 @@  static void make_acpi_dsdt(libxl__gc *gc, struct xc_dom_image *dom)
     dom->acpitable_size += ROUNDUP(acpitables[DSDT].size, 3);
 }
 
+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;
+}
+
 int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
                         libxl__domain_build_state *state,
                         struct xc_dom_image *dom)