diff mbox series

[Linaro-uefi,Linaro-uefi,v2,05/17] Hisilicon: Fix ACPI/DSDT table checksum error

Message ID 1491046162-53797-6-git-send-email-chenhui.sun@linaro.org
State New
Headers show
Series D03/D05 platforms bug fix | expand

Commit Message

Chenhui Sun April 1, 2017, 11:29 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 | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

Comments

Leif Lindholm April 6, 2017, 4:45 p.m. UTC | #1
On Sat, Apr 01, 2017 at 07:29:10PM +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>

See my last comment on v1.

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

Patch

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