diff mbox

[Linaro-uefi] Hisilicon: Fix ACPI/DSDT table checksum error

Message ID 1491911284-128983-1-git-send-email-chenhui.sun@linaro.org
State New
Headers show

Commit Message

Chenhui Sun April 11, 2017, 11:48 a.m. UTC
Refresh checksum after changing DSDT table.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Heyi Guo <heyi.guo@linaro.org>
Signed-off-by: Yi Li <phoenix.liyi@huawei.com>
Signed-off-by: Chenhui Sun <chenhui.sun@linaro.org>
---
 Chips/Hisilicon/Drivers/AcpiPlatformDxe/EthMac.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

Comments

Leif Lindholm April 11, 2017, 10:23 p.m. UTC | #1
On Tue, Apr 11, 2017 at 07:48:04PM +0800, Chenhui Sun wrote:
> Refresh checksum after changing DSDT table.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Heyi Guo <heyi.guo@linaro.org>
> Signed-off-by: Yi Li <phoenix.liyi@huawei.com>
> Signed-off-by: Chenhui Sun <chenhui.sun@linaro.org>

Thanks - much cleaner this way.

Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>

Pushed.

> ---
>  Chips/Hisilicon/Drivers/AcpiPlatformDxe/EthMac.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/Chips/Hisilicon/Drivers/AcpiPlatformDxe/EthMac.c b/Chips/Hisilicon/Drivers/AcpiPlatformDxe/EthMac.c
> index 41f5692..1f74d31 100644
> --- a/Chips/Hisilicon/Drivers/AcpiPlatformDxe/EthMac.c
> +++ b/Chips/Hisilicon/Drivers/AcpiPlatformDxe/EthMac.c
> @@ -442,6 +442,29 @@ static EFI_STATUS ProcessDSDT(
>    return EFI_SUCCESS;
>  }
>  
> +STATIC
> +VOID
> +AcpiCheckSum (
> +  IN OUT  EFI_ACPI_SDT_HEADER *Table
> +  )
> +{
> +  UINTN ChecksumOffset;
> +  UINT8 *Buffer;
> +
> +  ChecksumOffset = OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER, Checksum);
> +  Buffer = (UINT8 *)Table;
> +
> +  //
> +  // set checksum to 0 first
> +  //
> +  Buffer[ChecksumOffset] = 0;
> +
> +  //
> +  // Update checksum value
> +  //
> +  Buffer[ChecksumOffset] = CalculateCheckSum8 (Buffer, Table->Length);
> +}
> +
>  EFI_STATUS EthMacInit(void)
>  {
>    EFI_STATUS              Status;
> @@ -478,6 +501,7 @@ EFI_STATUS EthMacInit(void)
>      ProcessDSDT(AcpiTableProtocol, TableHandle);
>  
>      AcpiTableProtocol->Close(TableHandle);
> +    AcpiCheckSum (Table);
>    }
>  
>    return EFI_SUCCESS;
> -- 
> 1.9.1
>
diff mbox

Patch

diff --git a/Chips/Hisilicon/Drivers/AcpiPlatformDxe/EthMac.c b/Chips/Hisilicon/Drivers/AcpiPlatformDxe/EthMac.c
index 41f5692..1f74d31 100644
--- a/Chips/Hisilicon/Drivers/AcpiPlatformDxe/EthMac.c
+++ b/Chips/Hisilicon/Drivers/AcpiPlatformDxe/EthMac.c
@@ -442,6 +442,29 @@  static EFI_STATUS ProcessDSDT(
   return EFI_SUCCESS;
 }
 
+STATIC
+VOID
+AcpiCheckSum (
+  IN OUT  EFI_ACPI_SDT_HEADER *Table
+  )
+{
+  UINTN ChecksumOffset;
+  UINT8 *Buffer;
+
+  ChecksumOffset = OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER, Checksum);
+  Buffer = (UINT8 *)Table;
+
+  //
+  // set checksum to 0 first
+  //
+  Buffer[ChecksumOffset] = 0;
+
+  //
+  // Update checksum value
+  //
+  Buffer[ChecksumOffset] = CalculateCheckSum8 (Buffer, Table->Length);
+}
+
 EFI_STATUS EthMacInit(void)
 {
   EFI_STATUS              Status;
@@ -478,6 +501,7 @@  EFI_STATUS EthMacInit(void)
     ProcessDSDT(AcpiTableProtocol, TableHandle);
 
     AcpiTableProtocol->Close(TableHandle);
+    AcpiCheckSum (Table);
   }
 
   return EFI_SUCCESS;