]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Core/RuntimeDxe/Crc32.c
MdeModulePkg: Update RuntimeDxe Crc32 to check the input parameter
[mirror_edk2.git] / MdeModulePkg / Core / RuntimeDxe / Crc32.c
1 /** @file
2 This file implements CalculateCrc32 Boot Services as defined in
3 Platform Initialization specification 1.0 VOLUME 2 DXE Core Interface.
4
5 This Boot Services is in the Runtime Driver because this service is
6 also required by SetVirtualAddressMap() when the EFI System Table and
7 EFI Runtime Services Table are converted from physical address to
8 virtual addresses. This requires that the 32-bit CRC be recomputed.
9
10 Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
11 This program and the accompanying materials
12 are licensed and made available under the terms and conditions of the BSD License
13 which accompanies this distribution. The full text of the license may be found at
14 http://opensource.org/licenses/bsd-license.php
15
16 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
17 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18
19 **/
20
21
22 #include <Uefi.h>
23 #include <Library/BaseLib.h>
24
25 /**
26 Calculate CRC32 for target data.
27
28 @param Data The target data.
29 @param DataSize The target data size.
30 @param CrcOut The CRC32 for target data.
31
32 @retval EFI_SUCCESS The CRC32 for target data is calculated successfully.
33 @retval EFI_INVALID_PARAMETER Some parameter is not valid, so the CRC32 is not
34 calculated.
35
36 **/
37 EFI_STATUS
38 EFIAPI
39 RuntimeDriverCalculateCrc32 (
40 IN VOID *Data,
41 IN UINTN DataSize,
42 OUT UINT32 *CrcOut
43 )
44 {
45 if (Data == NULL || DataSize == 0 || CrcOut == NULL) {
46 return EFI_INVALID_PARAMETER;
47 }
48
49 *CrcOut = CalculateCrc32 (Data, DataSize);
50 return EFI_SUCCESS;
51 }