]>
git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Sample/Tools/Source/Common/Crc32.c
3 Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 CalcuateCrc32 routine.
23 #include "TianoCommon.h"
26 UINT32 mCrcTable
[256] = {
289 IN OUT UINT32
*CrcOut
295 The CalculateCrc32 routine.
299 Data - The buffer contaning the data to be processed
300 DataSize - The size of data to be processed
301 CrcOut - A pointer to the caller allocated UINT32 that on
302 contains the CRC32 checksum of Data
306 EFI_SUCCESS - Calculation is successful.
307 EFI_INVALID_PARAMETER - Data / CrcOut = NULL, or DataSize = 0
315 if ((DataSize
== 0) || (Data
== NULL
) || (CrcOut
== NULL
)) {
316 return EFI_INVALID_PARAMETER
;
320 for (Index
= 0, Ptr
= Data
; Index
< DataSize
; Index
++, Ptr
++) {
321 Crc
= (Crc
>> 8) ^ mCrcTable
[(UINT8
) Crc
^ *Ptr
];
324 *CrcOut
= Crc
^ 0xffffffff;