OvmfPkg/AcpiPlatformDxe/Xen.c: reuse CalculateSum8

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13542 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
jljusten 2012-07-18 22:33:48 +00:00
parent 377e758c3f
commit 4804ef4943
2 changed files with 6 additions and 36 deletions

View File

@ -47,6 +47,7 @@
HobLib
QemuFwCfgLib
MemoryAllocationLib
BaseLib
[Protocols]
gEfiAcpiTableProtocolGuid # PROTOCOL ALWAYS_CONSUMED

View File

@ -17,44 +17,13 @@
#include "AcpiPlatform.h"
#include <Library/HobLib.h>
#include <Guid/XenInfo.h>
#include <Library/BaseLib.h>
#define XEN_ACPI_PHYSICAL_ADDRESS 0x000EA020
#define XEN_BIOS_PHYSICAL_END 0x000FFFFF
EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *XenAcpiRsdpStructurePtr = NULL;
/**
Calculates the checksum of the ACPI tables.
@param Buffer Address of the ACPI table.
@param Size Size of the ACPI table need to check.
**/
UINT8
CalculateTableChecksum (
IN VOID *Buffer,
IN UINTN Size
)
{
UINT8 Sum;
UINT8 *Ptr;
Sum = 0;
//
// Initialize pointer
//
Ptr = Buffer;
//
// Add all content of buffer
//
while ((Size--) != 0) {
Sum = (UINT8) (Sum + (*Ptr++));
}
return Sum;
}
/**
This function detects if OVMF is running on Xen.
@ -113,8 +82,8 @@ GetXenAcpiRsdp (
// RSDP ACPI 1.0 checksum for 1.0/2.0/3.0 table.
// This is only the first 20 bytes of the structure
//
Sum = CalculateTableChecksum (
RsdpStructurePtr,
Sum = CalculateSum8 (
(CONST UINT8 *)RsdpStructurePtr,
sizeof (EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER)
);
if (Sum != 0) {
@ -125,8 +94,8 @@ GetXenAcpiRsdp (
//
// RSDP ACPI 2.0/3.0 checksum, this is the entire table
//
Sum = CalculateTableChecksum (
RsdpStructurePtr,
Sum = CalculateSum8 (
(CONST UINT8 *)RsdpStructurePtr,
sizeof (EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER)
);
if (Sum != 0) {