]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/RuntimeDxe/Crc32.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Core / RuntimeDxe / Crc32.c
index 14370dbc7d9b4d5d51ff13d95ab73468b0d3a461..fa3e0decdb28b9096f04fde91329541d1e283d30 100644 (file)
@@ -1,26 +1,19 @@
 /** @file\r
-  CalculateCrc32 Boot Services as defined in DXE CIS.\r
+  This file implements CalculateCrc32 Boot Services as defined in\r
+  Platform Initialization specification 1.0 VOLUME 2 DXE Core Interface.\r
 \r
   This Boot Services is in the Runtime Driver because this service is\r
   also required by SetVirtualAddressMap() when the EFI System Table and\r
   EFI Runtime Services Table are converted from physical address to\r
-  virtual addresses.   This requires that the 32-bit CRC be recomputed.\r
+  virtual addresses.  This requires that the 32-bit CRC be recomputed.\r
 \r
-Copyright (c) 2006, Intel Corporation. <BR>\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
-\r
-#include <PiDxe.h>\r
-\r
-UINT32  mCrcTable[256];\r
+#include <Uefi.h>\r
+#include <Library/BaseLib.h>\r
 \r
 /**\r
   Calculate CRC32 for target data.\r
@@ -42,73 +35,10 @@ RuntimeDriverCalculateCrc32 (
   OUT UINT32  *CrcOut\r
   )\r
 {\r
-  UINT32  Crc;\r
-  UINTN   Index;\r
-  UINT8   *Ptr;\r
-\r
-  if (Data == NULL || DataSize == 0 || CrcOut == NULL) {\r
+  if ((Data == NULL) || (DataSize == 0) || (CrcOut == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  Crc = 0xffffffff;\r
-  for (Index = 0, Ptr = Data; Index < DataSize; Index++, Ptr++) {\r
-    Crc = (Crc >> 8) ^ mCrcTable[(UINT8) Crc ^ *Ptr];\r
-  }\r
-\r
-  *CrcOut = Crc ^ 0xffffffff;\r
+  *CrcOut = CalculateCrc32 (Data, DataSize);\r
   return EFI_SUCCESS;\r
 }\r
-\r
-\r
-/**\r
-  Reverse bits for 32bit data.\r
-  This is a internal function.\r
-\r
-  @param  Value                 The data to be reversed.\r
-\r
-  @return                       Data reversed.\r
-\r
-**/\r
-UINT32\r
-ReverseBits (\r
-  UINT32  Value\r
-  )\r
-{\r
-  UINTN   Index;\r
-  UINT32  NewValue;\r
-\r
-  NewValue = 0;\r
-  for (Index = 0; Index < 32; Index++) {\r
-    if ((Value & (1 << Index)) != 0) {\r
-      NewValue = NewValue | (1 << (31 - Index));\r
-    }\r
-  }\r
-\r
-  return NewValue;\r
-}\r
-\r
-/**\r
-  Initialize CRC32 table.\r
-**/\r
-VOID\r
-RuntimeDriverInitializeCrc32Table (\r
-  VOID\r
-  )\r
-{\r
-  UINTN   TableEntry;\r
-  UINTN   Index;\r
-  UINT32  Value;\r
-\r
-  for (TableEntry = 0; TableEntry < 256; TableEntry++) {\r
-    Value = ReverseBits ((UINT32) TableEntry);\r
-    for (Index = 0; Index < 8; Index++) {\r
-      if ((Value & 0x80000000) != 0) {\r
-        Value = (Value << 1) ^ 0x04c11db7;\r
-      } else {\r
-        Value = Value << 1;\r
-      }\r
-    }\r
-\r
-    mCrcTable[TableEntry] = ReverseBits (Value);\r
-  }\r
-}\r