TianoCore EDK2 master
|
#include "BaseLibInternals.h"
Go to the source code of this file.
Functions | |
UINT8 EFIAPI | CalculateSum8 (IN CONST UINT8 *Buffer, IN UINTN Length) |
UINT8 EFIAPI | CalculateCheckSum8 (IN CONST UINT8 *Buffer, IN UINTN Length) |
UINT16 EFIAPI | CalculateSum16 (IN CONST UINT16 *Buffer, IN UINTN Length) |
UINT16 EFIAPI | CalculateCheckSum16 (IN CONST UINT16 *Buffer, IN UINTN Length) |
UINT32 EFIAPI | CalculateSum32 (IN CONST UINT32 *Buffer, IN UINTN Length) |
UINT32 EFIAPI | CalculateCheckSum32 (IN CONST UINT32 *Buffer, IN UINTN Length) |
UINT64 EFIAPI | CalculateSum64 (IN CONST UINT64 *Buffer, IN UINTN Length) |
UINT64 EFIAPI | CalculateCheckSum64 (IN CONST UINT64 *Buffer, IN UINTN Length) |
UINT32 EFIAPI | CalculateCrc32 (IN VOID *Buffer, IN UINTN Length) |
UINT16 EFIAPI | CalculateCrc16Ansi (IN CONST VOID *Buffer, IN UINTN Length, IN UINT16 InitialValue) |
UINT32 EFIAPI | CalculateCrc32c (IN CONST VOID *Buffer, IN UINTN Length, IN UINT32 InitialValue) |
UINT16 EFIAPI | CalculateCrc16CcittF (IN CONST VOID *Buffer, IN UINTN Length, IN UINT16 InitialValue) |
Variables | |
GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT32 | mCrcTable [256] |
GLOBAL_REMOVE_IF_UNREFERENCED STATIC CONST UINT16 | mCrc16LookupTable [256] |
GLOBAL_REMOVE_IF_UNREFERENCED STATIC CONST UINT32 | mCrc32cLookupTable [256] |
GLOBAL_REMOVE_IF_UNREFERENCED STATIC CONST UINT16 | mCrc16CcittFLookupTable [256] |
Utility functions to generate checksum based on 2's complement algorithm.
Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
Copyright (c) 2022, Pedro Falcato. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file CheckSum.c.
Returns the two's complement checksum of all elements in a buffer of 16-bit values.
This function first calculates the sum of the 16-bit values in the buffer specified by Buffer and Length. The carry bits in the result of addition are dropped. Then, the two's complement of the sum is returned. If Length is 0, then 0 is returned.
If Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 16-bit boundary, then ASSERT(). If Length is not aligned on a 16-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
Buffer | The pointer to the buffer to carry out the checksum operation. |
Length | The size, in bytes, of Buffer. |
Definition at line 151 of file CheckSum.c.
Returns the two's complement checksum of all elements in a buffer of 32-bit values.
This function first calculates the sum of the 32-bit values in the buffer specified by Buffer and Length. The carry bits in the result of addition are dropped. Then, the two's complement of the sum is returned. If Length is 0, then 0 is returned.
If Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). If Length is not aligned on a 32-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
Buffer | The pointer to the buffer to carry out the checksum operation. |
Length | The size, in bytes, of Buffer. |
Definition at line 231 of file CheckSum.c.
Returns the two's complement checksum of all elements in a buffer of 64-bit values.
This function first calculates the sum of the 64-bit values in the buffer specified by Buffer and Length. The carry bits in the result of addition are dropped. Then, the two's complement of the sum is returned. If Length is 0, then 0 is returned.
If Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 64-bit boundary, then ASSERT(). If Length is not aligned on a 64-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
Buffer | The pointer to the buffer to carry out the checksum operation. |
Length | The size, in bytes, of Buffer. |
Definition at line 311 of file CheckSum.c.
Returns the two's complement checksum of all elements in a buffer of 8-bit values.
This function first calculates the sum of the 8-bit values in the buffer specified by Buffer and Length. The carry bits in the result of addition are dropped. Then, the two's complement of the sum is returned. If Length is 0, then 0 is returned.
If Buffer is NULL, then ASSERT(). If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
Buffer | The pointer to the buffer to carry out the checksum operation. |
Length | The size, in bytes, of Buffer. |
Definition at line 71 of file CheckSum.c.
UINT16 EFIAPI CalculateCrc16Ansi | ( | IN CONST VOID * | Buffer, |
IN UINTN | Length, | ||
IN UINT16 | InitialValue | ||
) |
Calculates the CRC16-ANSI checksum of the given buffer.
[in] | Buffer | Pointer to the buffer. |
[in] | Length | Length of the buffer, in bytes. |
[in] | InitialValue | Initial value of the CRC. |
Definition at line 670 of file CheckSum.c.
UINT16 EFIAPI CalculateCrc16CcittF | ( | IN CONST VOID * | Buffer, |
IN UINTN | Length, | ||
IN UINT16 | InitialValue | ||
) |
Calculates the CRC16-CCITT-FALSE checksum of the given buffer.
[in] | Buffer | Pointer to the buffer. |
[in] | Length | Length of the buffer, in bytes. |
[in] | InitialValue | Initial value of the CRC. |
Definition at line 813 of file CheckSum.c.
Computes and returns a 32-bit CRC for a data buffer. CRC32 value bases on ITU-T V.42.
If Buffer is NULL, then ASSERT(). If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
[in] | Buffer | A pointer to the buffer on which the 32-bit CRC is to be computed. |
[in] | Length | The number of bytes in the buffer Data. |
Crc32 | The 32-bit CRC was computed for the data buffer. |
Definition at line 600 of file CheckSum.c.
Calculates the CRC32c checksum of the given buffer.
[in] | Buffer | Pointer to the buffer. |
[in] | Length | Length of the buffer, in bytes. |
[in] | InitialValue | Initial value of the CRC. |
Definition at line 747 of file CheckSum.c.
Returns the sum of all elements in a buffer of 16-bit values. During calculation, the carry bits are dropped.
This function calculates the sum of the 16-bit values in the buffer specified by Buffer and Length. The carry bits in result of addition are dropped. The 16-bit result is returned. If Length is 0, then 0 is returned.
If Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 16-bit boundary, then ASSERT(). If Length is not aligned on a 16-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
Buffer | The pointer to the buffer to carry out the sum operation. |
Length | The size, in bytes, of Buffer. |
Definition at line 107 of file CheckSum.c.
Returns the sum of all elements in a buffer of 32-bit values. During calculation, the carry bits are dropped.
This function calculates the sum of the 32-bit values in the buffer specified by Buffer and Length. The carry bits in result of addition are dropped. The 32-bit result is returned. If Length is 0, then 0 is returned.
If Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 32-bit boundary, then ASSERT(). If Length is not aligned on a 32-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
Buffer | The pointer to the buffer to carry out the sum operation. |
Length | The size, in bytes, of Buffer. |
Definition at line 187 of file CheckSum.c.
Returns the sum of all elements in a buffer of 64-bit values. During calculation, the carry bits are dropped.
This function calculates the sum of the 64-bit values in the buffer specified by Buffer and Length. The carry bits in result of addition are dropped. The 64-bit result is returned. If Length is 0, then 0 is returned.
If Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 64-bit boundary, then ASSERT(). If Length is not aligned on a 64-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
Buffer | The pointer to the buffer to carry out the sum operation. |
Length | The size, in bytes, of Buffer. |
Definition at line 267 of file CheckSum.c.
Returns the sum of all elements in a buffer in unit of UINT8. During calculation, the carry bits are dropped.
This function calculates the sum of all elements in a buffer in unit of UINT8. The carry bits in result of addition are dropped. The result is returned as UINT8. If Length is Zero, then Zero is returned.
If Buffer is NULL, then ASSERT(). If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
Buffer | The pointer to the buffer to carry out the sum operation. |
Length | The size, in bytes, of Buffer. |
Definition at line 33 of file CheckSum.c.
GLOBAL_REMOVE_IF_UNREFERENCED STATIC CONST UINT16 mCrc16CcittFLookupTable[256] |
Definition at line 767 of file CheckSum.c.
GLOBAL_REMOVE_IF_UNREFERENCED STATIC CONST UINT16 mCrc16LookupTable[256] |
Definition at line 623 of file CheckSum.c.
GLOBAL_REMOVE_IF_UNREFERENCED STATIC CONST UINT32 mCrc32cLookupTable[256] |
Definition at line 690 of file CheckSum.c.
GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT32 mCrcTable[256] |
Definition at line 326 of file CheckSum.c.