summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Core/RuntimeDxe
diff options
context:
space:
mode:
authorLiming Gao <liming.gao@intel.com>2017-09-08 13:18:25 +0800
committerLiming Gao <liming.gao@intel.com>2017-10-10 18:10:16 +0800
commit05542f49877f9047c536b61fd8f15dd4c4496b4b (patch)
treea1dff968108f1ad46936a501cff7c03009f8dd58 /MdeModulePkg/Core/RuntimeDxe
parent0a8e6f7971ad778897cacee2be09016d4366a4a1 (diff)
downloadedk2-05542f49877f9047c536b61fd8f15dd4c4496b4b.tar.gz
edk2-05542f49877f9047c536b61fd8f15dd4c4496b4b.tar.bz2
edk2-05542f49877f9047c536b61fd8f15dd4c4496b4b.zip
MdeModulePkg: Update modules to consume CalculateCrc32()
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
Diffstat (limited to 'MdeModulePkg/Core/RuntimeDxe')
-rw-r--r--MdeModulePkg/Core/RuntimeDxe/Crc32.c74
-rw-r--r--MdeModulePkg/Core/RuntimeDxe/Runtime.c5
-rw-r--r--MdeModulePkg/Core/RuntimeDxe/Runtime.h9
3 files changed, 3 insertions, 85 deletions
diff --git a/MdeModulePkg/Core/RuntimeDxe/Crc32.c b/MdeModulePkg/Core/RuntimeDxe/Crc32.c
index a6fe77fa34..3e91e08049 100644
--- a/MdeModulePkg/Core/RuntimeDxe/Crc32.c
+++ b/MdeModulePkg/Core/RuntimeDxe/Crc32.c
@@ -7,7 +7,7 @@
EFI Runtime Services Table are converted from physical address to
virtual addresses. This requires that the 32-bit CRC be recomputed.
-Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -20,8 +20,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Uefi.h>
-
-UINT32 mCrcTable[256];
+#include <Library/BaseLib.h>
/**
Calculate CRC32 for target data.
@@ -43,73 +42,6 @@ RuntimeDriverCalculateCrc32 (
OUT UINT32 *CrcOut
)
{
- UINT32 Crc;
- UINTN Index;
- UINT8 *Ptr;
-
- if (Data == NULL || DataSize == 0 || CrcOut == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- Crc = 0xffffffff;
- for (Index = 0, Ptr = Data; Index < DataSize; Index++, Ptr++) {
- Crc = (Crc >> 8) ^ mCrcTable[(UINT8) Crc ^ *Ptr];
- }
-
- *CrcOut = Crc ^ 0xffffffff;
+ *CrcOut = CalculateCrc32 (Data, DataSize);
return EFI_SUCCESS;
}
-
-
-/**
- This internal function reverses bits for 32bit data.
-
- @param Value The data to be reversed.
-
- @return Data reversed.
-
-**/
-UINT32
-ReverseBits (
- UINT32 Value
- )
-{
- UINTN Index;
- UINT32 NewValue;
-
- NewValue = 0;
- for (Index = 0; Index < 32; Index++) {
- if ((Value & (1 << Index)) != 0) {
- NewValue = NewValue | (1 << (31 - Index));
- }
- }
-
- return NewValue;
-}
-
-/**
- Initialize CRC32 table.
-
-**/
-VOID
-RuntimeDriverInitializeCrc32Table (
- VOID
- )
-{
- UINTN TableEntry;
- UINTN Index;
- UINT32 Value;
-
- for (TableEntry = 0; TableEntry < 256; TableEntry++) {
- Value = ReverseBits ((UINT32) TableEntry);
- for (Index = 0; Index < 8; Index++) {
- if ((Value & 0x80000000) != 0) {
- Value = (Value << 1) ^ 0x04c11db7;
- } else {
- Value = Value << 1;
- }
- }
-
- mCrcTable[TableEntry] = ReverseBits (Value);
- }
-}
diff --git a/MdeModulePkg/Core/RuntimeDxe/Runtime.c b/MdeModulePkg/Core/RuntimeDxe/Runtime.c
index c61301cf80..0557457e04 100644
--- a/MdeModulePkg/Core/RuntimeDxe/Runtime.c
+++ b/MdeModulePkg/Core/RuntimeDxe/Runtime.c
@@ -401,11 +401,6 @@ RuntimeDriverInitialize (
mMyImageBase = MyLoadedImage->ImageBase;
//
- // Initialize the table used to compute 32-bit CRCs
- //
- RuntimeDriverInitializeCrc32Table ();
-
- //
// Fill in the entries of the EFI Boot Services and EFI Runtime Services Tables
//
gBS->CalculateCrc32 = RuntimeDriverCalculateCrc32;
diff --git a/MdeModulePkg/Core/RuntimeDxe/Runtime.h b/MdeModulePkg/Core/RuntimeDxe/Runtime.h
index f2cee9c7c6..506915e112 100644
--- a/MdeModulePkg/Core/RuntimeDxe/Runtime.h
+++ b/MdeModulePkg/Core/RuntimeDxe/Runtime.h
@@ -104,15 +104,6 @@ RuntimeDriverSetVirtualAddressMap (
);
/**
- Initialize CRC32 table.
-
-**/
-VOID
-RuntimeDriverInitializeCrc32Table (
- VOID
- );
-
-/**
Install Runtime AP. This code includes the EfiRuntimeLib, but it only
functions at RT in physical mode.