xref: /src/sys/contrib/edk2/Include/Library/BaseMemoryLib.h (revision 3245fa215aca18d135839a15c80ae1c905666a37)
10499b37cSWarner Losh /** @file
20499b37cSWarner Losh   Provides copy memory, fill memory, zero memory, and GUID functions.
30499b37cSWarner Losh 
40499b37cSWarner Losh   The Base Memory Library provides optimized implementations for common memory-based operations.
50499b37cSWarner Losh   These functions should be used in place of coding your own loops to do equivalent common functions.
60499b37cSWarner Losh   This allows optimized library implementations to help increase performance.
70499b37cSWarner Losh 
84a14dfccSMitchell Horne Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
94a14dfccSMitchell Horne SPDX-License-Identifier: BSD-2-Clause-Patent
100499b37cSWarner Losh 
110499b37cSWarner Losh **/
120499b37cSWarner Losh 
130499b37cSWarner Losh #ifndef __BASE_MEMORY_LIB__
140499b37cSWarner Losh #define __BASE_MEMORY_LIB__
150499b37cSWarner Losh 
160499b37cSWarner Losh /**
170499b37cSWarner Losh   Copies a source buffer to a destination buffer, and returns the destination buffer.
180499b37cSWarner Losh 
190499b37cSWarner Losh   This function copies Length bytes from SourceBuffer to DestinationBuffer, and returns
200499b37cSWarner Losh   DestinationBuffer.  The implementation must be reentrant, and it must handle the case
210499b37cSWarner Losh   where SourceBuffer overlaps DestinationBuffer.
220499b37cSWarner Losh 
230499b37cSWarner Losh   If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT().
240499b37cSWarner Losh   If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().
250499b37cSWarner Losh 
260499b37cSWarner Losh   @param  DestinationBuffer   The pointer to the destination buffer of the memory copy.
270499b37cSWarner Losh   @param  SourceBuffer        The pointer to the source buffer of the memory copy.
280499b37cSWarner Losh   @param  Length              The number of bytes to copy from SourceBuffer to DestinationBuffer.
290499b37cSWarner Losh 
300499b37cSWarner Losh   @return DestinationBuffer.
310499b37cSWarner Losh 
320499b37cSWarner Losh **/
330499b37cSWarner Losh VOID *
340499b37cSWarner Losh EFIAPI
350499b37cSWarner Losh CopyMem (
360499b37cSWarner Losh   OUT VOID       *DestinationBuffer,
370499b37cSWarner Losh   IN CONST VOID  *SourceBuffer,
380499b37cSWarner Losh   IN UINTN       Length
390499b37cSWarner Losh   );
400499b37cSWarner Losh 
410499b37cSWarner Losh /**
420499b37cSWarner Losh   Fills a target buffer with a byte value, and returns the target buffer.
430499b37cSWarner Losh 
440499b37cSWarner Losh   This function fills Length bytes of Buffer with Value, and returns Buffer.
450499b37cSWarner Losh 
460499b37cSWarner Losh   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
470499b37cSWarner Losh 
480499b37cSWarner Losh   @param  Buffer    The memory to set.
490499b37cSWarner Losh   @param  Length    The number of bytes to set.
500499b37cSWarner Losh   @param  Value     The value with which to fill Length bytes of Buffer.
510499b37cSWarner Losh 
520499b37cSWarner Losh   @return Buffer.
530499b37cSWarner Losh 
540499b37cSWarner Losh **/
550499b37cSWarner Losh VOID *
560499b37cSWarner Losh EFIAPI
570499b37cSWarner Losh SetMem (
580499b37cSWarner Losh   OUT VOID  *Buffer,
590499b37cSWarner Losh   IN UINTN  Length,
600499b37cSWarner Losh   IN UINT8  Value
610499b37cSWarner Losh   );
620499b37cSWarner Losh 
630499b37cSWarner Losh /**
640499b37cSWarner Losh   Fills a target buffer with a 16-bit value, and returns the target buffer.
650499b37cSWarner Losh 
660499b37cSWarner Losh   This function fills Length bytes of Buffer with the 16-bit value specified by
670499b37cSWarner Losh   Value, and returns Buffer. Value is repeated every 16-bits in for Length
680499b37cSWarner Losh   bytes of Buffer.
690499b37cSWarner Losh 
700499b37cSWarner Losh   If Length > 0 and Buffer is NULL, then ASSERT().
710499b37cSWarner Losh   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
720499b37cSWarner Losh   If Buffer is not aligned on a 16-bit boundary, then ASSERT().
730499b37cSWarner Losh   If Length is not aligned on a 16-bit boundary, then ASSERT().
740499b37cSWarner Losh 
750499b37cSWarner Losh   @param  Buffer  The pointer to the target buffer to fill.
760499b37cSWarner Losh   @param  Length  The number of bytes in Buffer to fill.
770499b37cSWarner Losh   @param  Value   The value with which to fill Length bytes of Buffer.
780499b37cSWarner Losh 
790499b37cSWarner Losh   @return Buffer.
800499b37cSWarner Losh 
810499b37cSWarner Losh **/
820499b37cSWarner Losh VOID *
830499b37cSWarner Losh EFIAPI
840499b37cSWarner Losh SetMem16 (
850499b37cSWarner Losh   OUT VOID   *Buffer,
860499b37cSWarner Losh   IN UINTN   Length,
870499b37cSWarner Losh   IN UINT16  Value
880499b37cSWarner Losh   );
890499b37cSWarner Losh 
900499b37cSWarner Losh /**
910499b37cSWarner Losh   Fills a target buffer with a 32-bit value, and returns the target buffer.
920499b37cSWarner Losh 
930499b37cSWarner Losh   This function fills Length bytes of Buffer with the 32-bit value specified by
940499b37cSWarner Losh   Value, and returns Buffer. Value is repeated every 32-bits in for Length
950499b37cSWarner Losh   bytes of Buffer.
960499b37cSWarner Losh 
970499b37cSWarner Losh   If Length > 0 and Buffer is NULL, then ASSERT().
980499b37cSWarner Losh   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
990499b37cSWarner Losh   If Buffer is not aligned on a 32-bit boundary, then ASSERT().
1000499b37cSWarner Losh   If Length is not aligned on a 32-bit boundary, then ASSERT().
1010499b37cSWarner Losh 
1020499b37cSWarner Losh   @param  Buffer  The pointer to the target buffer to fill.
1030499b37cSWarner Losh   @param  Length  The number of bytes in Buffer to fill.
1040499b37cSWarner Losh   @param  Value   The value with which to fill Length bytes of Buffer.
1050499b37cSWarner Losh 
1060499b37cSWarner Losh   @return Buffer.
1070499b37cSWarner Losh 
1080499b37cSWarner Losh **/
1090499b37cSWarner Losh VOID *
1100499b37cSWarner Losh EFIAPI
1110499b37cSWarner Losh SetMem32 (
1120499b37cSWarner Losh   OUT VOID   *Buffer,
1130499b37cSWarner Losh   IN UINTN   Length,
1140499b37cSWarner Losh   IN UINT32  Value
1150499b37cSWarner Losh   );
1160499b37cSWarner Losh 
1170499b37cSWarner Losh /**
1180499b37cSWarner Losh   Fills a target buffer with a 64-bit value, and returns the target buffer.
1190499b37cSWarner Losh 
1200499b37cSWarner Losh   This function fills Length bytes of Buffer with the 64-bit value specified by
1210499b37cSWarner Losh   Value, and returns Buffer. Value is repeated every 64-bits in for Length
1220499b37cSWarner Losh   bytes of Buffer.
1230499b37cSWarner Losh 
1240499b37cSWarner Losh   If Length > 0 and Buffer is NULL, then ASSERT().
1250499b37cSWarner Losh   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
1260499b37cSWarner Losh   If Buffer is not aligned on a 64-bit boundary, then ASSERT().
1270499b37cSWarner Losh   If Length is not aligned on a 64-bit boundary, then ASSERT().
1280499b37cSWarner Losh 
1290499b37cSWarner Losh   @param  Buffer  The pointer to the target buffer to fill.
1300499b37cSWarner Losh   @param  Length  The number of bytes in Buffer to fill.
1310499b37cSWarner Losh   @param  Value   The value with which to fill Length bytes of Buffer.
1320499b37cSWarner Losh 
1330499b37cSWarner Losh   @return Buffer.
1340499b37cSWarner Losh 
1350499b37cSWarner Losh **/
1360499b37cSWarner Losh VOID *
1370499b37cSWarner Losh EFIAPI
1380499b37cSWarner Losh SetMem64 (
1390499b37cSWarner Losh   OUT VOID   *Buffer,
1400499b37cSWarner Losh   IN UINTN   Length,
1410499b37cSWarner Losh   IN UINT64  Value
1420499b37cSWarner Losh   );
1430499b37cSWarner Losh 
1440499b37cSWarner Losh /**
1450499b37cSWarner Losh   Fills a target buffer with a value that is size UINTN, and returns the target buffer.
1460499b37cSWarner Losh 
1470499b37cSWarner Losh   This function fills Length bytes of Buffer with the UINTN sized value specified by
1480499b37cSWarner Losh   Value, and returns Buffer. Value is repeated every sizeof(UINTN) bytes for Length
1490499b37cSWarner Losh   bytes of Buffer.
1500499b37cSWarner Losh 
1510499b37cSWarner Losh   If Length > 0 and Buffer is NULL, then ASSERT().
1520499b37cSWarner Losh   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
1530499b37cSWarner Losh   If Buffer is not aligned on a UINTN boundary, then ASSERT().
1540499b37cSWarner Losh   If Length is not aligned on a UINTN boundary, then ASSERT().
1550499b37cSWarner Losh 
1560499b37cSWarner Losh   @param  Buffer  The pointer to the target buffer to fill.
1570499b37cSWarner Losh   @param  Length  The number of bytes in Buffer to fill.
1580499b37cSWarner Losh   @param  Value   The value with which to fill Length bytes of Buffer.
1590499b37cSWarner Losh 
1600499b37cSWarner Losh   @return Buffer.
1610499b37cSWarner Losh 
1620499b37cSWarner Losh **/
1630499b37cSWarner Losh VOID *
1640499b37cSWarner Losh EFIAPI
1650499b37cSWarner Losh SetMemN (
1660499b37cSWarner Losh   OUT VOID  *Buffer,
1670499b37cSWarner Losh   IN UINTN  Length,
1680499b37cSWarner Losh   IN UINTN  Value
1690499b37cSWarner Losh   );
1700499b37cSWarner Losh 
1710499b37cSWarner Losh /**
1720499b37cSWarner Losh   Fills a target buffer with zeros, and returns the target buffer.
1730499b37cSWarner Losh 
1740499b37cSWarner Losh   This function fills Length bytes of Buffer with zeros, and returns Buffer.
1750499b37cSWarner Losh 
1760499b37cSWarner Losh   If Length > 0 and Buffer is NULL, then ASSERT().
1770499b37cSWarner Losh   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
1780499b37cSWarner Losh 
1790499b37cSWarner Losh   @param  Buffer      The pointer to the target buffer to fill with zeros.
1800499b37cSWarner Losh   @param  Length      The number of bytes in Buffer to fill with zeros.
1810499b37cSWarner Losh 
1820499b37cSWarner Losh   @return Buffer.
1830499b37cSWarner Losh 
1840499b37cSWarner Losh **/
1850499b37cSWarner Losh VOID *
1860499b37cSWarner Losh EFIAPI
1870499b37cSWarner Losh ZeroMem (
1880499b37cSWarner Losh   OUT VOID  *Buffer,
1890499b37cSWarner Losh   IN UINTN  Length
1900499b37cSWarner Losh   );
1910499b37cSWarner Losh 
1920499b37cSWarner Losh /**
1930499b37cSWarner Losh   Compares the contents of two buffers.
1940499b37cSWarner Losh 
1950499b37cSWarner Losh   This function compares Length bytes of SourceBuffer to Length bytes of DestinationBuffer.
1960499b37cSWarner Losh   If all Length bytes of the two buffers are identical, then 0 is returned.  Otherwise, the
1970499b37cSWarner Losh   value returned is the first mismatched byte in SourceBuffer subtracted from the first
1980499b37cSWarner Losh   mismatched byte in DestinationBuffer.
1990499b37cSWarner Losh 
2000499b37cSWarner Losh   If Length > 0 and DestinationBuffer is NULL, then ASSERT().
2010499b37cSWarner Losh   If Length > 0 and SourceBuffer is NULL, then ASSERT().
2020499b37cSWarner Losh   If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT().
2030499b37cSWarner Losh   If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().
2040499b37cSWarner Losh 
2050499b37cSWarner Losh   @param  DestinationBuffer The pointer to the destination buffer to compare.
2060499b37cSWarner Losh   @param  SourceBuffer      The pointer to the source buffer to compare.
2070499b37cSWarner Losh   @param  Length            The number of bytes to compare.
2080499b37cSWarner Losh 
2090499b37cSWarner Losh   @return 0                 All Length bytes of the two buffers are identical.
2100499b37cSWarner Losh   @retval Non-zero          The first mismatched byte in SourceBuffer subtracted from the first
2110499b37cSWarner Losh                             mismatched byte in DestinationBuffer.
2120499b37cSWarner Losh 
2130499b37cSWarner Losh **/
2140499b37cSWarner Losh INTN
2150499b37cSWarner Losh EFIAPI
2160499b37cSWarner Losh CompareMem (
2170499b37cSWarner Losh   IN CONST VOID  *DestinationBuffer,
2180499b37cSWarner Losh   IN CONST VOID  *SourceBuffer,
2190499b37cSWarner Losh   IN UINTN       Length
2200499b37cSWarner Losh   );
2210499b37cSWarner Losh 
2220499b37cSWarner Losh /**
2230499b37cSWarner Losh   Scans a target buffer for an 8-bit value, and returns a pointer to the matching 8-bit value
2240499b37cSWarner Losh   in the target buffer.
2250499b37cSWarner Losh 
2260499b37cSWarner Losh   This function searches target the buffer specified by Buffer and Length from the lowest
2270499b37cSWarner Losh   address to the highest address for an 8-bit value that matches Value.  If a match is found,
2280499b37cSWarner Losh   then a pointer to the matching byte in the target buffer is returned.  If no match is found,
2290499b37cSWarner Losh   then NULL is returned.  If Length is 0, then NULL is returned.
2300499b37cSWarner Losh 
2310499b37cSWarner Losh   If Length > 0 and Buffer is NULL, then ASSERT().
2320499b37cSWarner Losh   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
2330499b37cSWarner Losh 
2340499b37cSWarner Losh   @param  Buffer      The pointer to the target buffer to scan.
2350499b37cSWarner Losh   @param  Length      The number of bytes in Buffer to scan.
2360499b37cSWarner Losh   @param  Value       The value to search for in the target buffer.
2370499b37cSWarner Losh 
2380499b37cSWarner Losh   @return A pointer to the matching byte in the target buffer, otherwise NULL.
2390499b37cSWarner Losh 
2400499b37cSWarner Losh **/
2410499b37cSWarner Losh VOID *
2420499b37cSWarner Losh EFIAPI
2430499b37cSWarner Losh ScanMem8 (
2440499b37cSWarner Losh   IN CONST VOID  *Buffer,
2450499b37cSWarner Losh   IN UINTN       Length,
2460499b37cSWarner Losh   IN UINT8       Value
2470499b37cSWarner Losh   );
2480499b37cSWarner Losh 
2490499b37cSWarner Losh /**
2500499b37cSWarner Losh   Scans a target buffer for a 16-bit value, and returns a pointer to the matching 16-bit value
2510499b37cSWarner Losh   in the target buffer.
2520499b37cSWarner Losh 
2530499b37cSWarner Losh   This function searches target the buffer specified by Buffer and Length from the lowest
2540499b37cSWarner Losh   address to the highest address for a 16-bit value that matches Value.  If a match is found,
2550499b37cSWarner Losh   then a pointer to the matching byte in the target buffer is returned.  If no match is found,
2560499b37cSWarner Losh   then NULL is returned.  If Length is 0, then NULL is returned.
2570499b37cSWarner Losh 
2580499b37cSWarner Losh   If Length > 0 and Buffer is NULL, then ASSERT().
2590499b37cSWarner Losh   If Buffer is not aligned on a 16-bit boundary, then ASSERT().
2600499b37cSWarner Losh   If Length is not aligned on a 16-bit boundary, then ASSERT().
2610499b37cSWarner Losh   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
2620499b37cSWarner Losh 
2630499b37cSWarner Losh   @param  Buffer      The pointer to the target buffer to scan.
2640499b37cSWarner Losh   @param  Length      The number of bytes in Buffer to scan.
2650499b37cSWarner Losh   @param  Value       The value to search for in the target buffer.
2660499b37cSWarner Losh 
2670499b37cSWarner Losh   @return A pointer to the matching byte in the target buffer, otherwise NULL.
2680499b37cSWarner Losh 
2690499b37cSWarner Losh **/
2700499b37cSWarner Losh VOID *
2710499b37cSWarner Losh EFIAPI
2720499b37cSWarner Losh ScanMem16 (
2730499b37cSWarner Losh   IN CONST VOID  *Buffer,
2740499b37cSWarner Losh   IN UINTN       Length,
2750499b37cSWarner Losh   IN UINT16      Value
2760499b37cSWarner Losh   );
2770499b37cSWarner Losh 
2780499b37cSWarner Losh /**
2790499b37cSWarner Losh   Scans a target buffer for a 32-bit value, and returns a pointer to the matching 32-bit value
2800499b37cSWarner Losh   in the target buffer.
2810499b37cSWarner Losh 
2820499b37cSWarner Losh   This function searches target the buffer specified by Buffer and Length from the lowest
2830499b37cSWarner Losh   address to the highest address for a 32-bit value that matches Value.  If a match is found,
2840499b37cSWarner Losh   then a pointer to the matching byte in the target buffer is returned.  If no match is found,
2850499b37cSWarner Losh   then NULL is returned.  If Length is 0, then NULL is returned.
2860499b37cSWarner Losh 
2870499b37cSWarner Losh   If Length > 0 and Buffer is NULL, then ASSERT().
2880499b37cSWarner Losh   If Buffer is not aligned on a 32-bit boundary, then ASSERT().
2890499b37cSWarner Losh   If Length is not aligned on a 32-bit boundary, then ASSERT().
2900499b37cSWarner Losh   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
2910499b37cSWarner Losh 
2920499b37cSWarner Losh   @param  Buffer      The pointer to the target buffer to scan.
2930499b37cSWarner Losh   @param  Length      The number of bytes in Buffer to scan.
2940499b37cSWarner Losh   @param  Value       The value to search for in the target buffer.
2950499b37cSWarner Losh 
2960499b37cSWarner Losh   @return A pointer to the matching byte in the target buffer, otherwise NULL.
2970499b37cSWarner Losh 
2980499b37cSWarner Losh **/
2990499b37cSWarner Losh VOID *
3000499b37cSWarner Losh EFIAPI
3010499b37cSWarner Losh ScanMem32 (
3020499b37cSWarner Losh   IN CONST VOID  *Buffer,
3030499b37cSWarner Losh   IN UINTN       Length,
3040499b37cSWarner Losh   IN UINT32      Value
3050499b37cSWarner Losh   );
3060499b37cSWarner Losh 
3070499b37cSWarner Losh /**
3080499b37cSWarner Losh   Scans a target buffer for a 64-bit value, and returns a pointer to the matching 64-bit value
3090499b37cSWarner Losh   in the target buffer.
3100499b37cSWarner Losh 
3110499b37cSWarner Losh   This function searches target the buffer specified by Buffer and Length from the lowest
3120499b37cSWarner Losh   address to the highest address for a 64-bit value that matches Value.  If a match is found,
3130499b37cSWarner Losh   then a pointer to the matching byte in the target buffer is returned.  If no match is found,
3140499b37cSWarner Losh   then NULL is returned.  If Length is 0, then NULL is returned.
3150499b37cSWarner Losh 
3160499b37cSWarner Losh   If Length > 0 and Buffer is NULL, then ASSERT().
3170499b37cSWarner Losh   If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3180499b37cSWarner Losh   If Length is not aligned on a 64-bit boundary, then ASSERT().
3190499b37cSWarner Losh   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3200499b37cSWarner Losh 
3210499b37cSWarner Losh   @param  Buffer      The pointer to the target buffer to scan.
3220499b37cSWarner Losh   @param  Length      The number of bytes in Buffer to scan.
3230499b37cSWarner Losh   @param  Value       The value to search for in the target buffer.
3240499b37cSWarner Losh 
3250499b37cSWarner Losh   @return A pointer to the matching byte in the target buffer, otherwise NULL.
3260499b37cSWarner Losh 
3270499b37cSWarner Losh **/
3280499b37cSWarner Losh VOID *
3290499b37cSWarner Losh EFIAPI
3300499b37cSWarner Losh ScanMem64 (
3310499b37cSWarner Losh   IN CONST VOID  *Buffer,
3320499b37cSWarner Losh   IN UINTN       Length,
3330499b37cSWarner Losh   IN UINT64      Value
3340499b37cSWarner Losh   );
3350499b37cSWarner Losh 
3360499b37cSWarner Losh /**
3370499b37cSWarner Losh   Scans a target buffer for a UINTN sized value, and returns a pointer to the matching
3380499b37cSWarner Losh   UINTN sized value in the target buffer.
3390499b37cSWarner Losh 
3400499b37cSWarner Losh   This function searches target the buffer specified by Buffer and Length from the lowest
3410499b37cSWarner Losh   address to the highest address for a UINTN sized value that matches Value.  If a match is found,
3420499b37cSWarner Losh   then a pointer to the matching byte in the target buffer is returned.  If no match is found,
3430499b37cSWarner Losh   then NULL is returned.  If Length is 0, then NULL is returned.
3440499b37cSWarner Losh 
3450499b37cSWarner Losh   If Length > 0 and Buffer is NULL, then ASSERT().
3460499b37cSWarner Losh   If Buffer is not aligned on a UINTN boundary, then ASSERT().
3470499b37cSWarner Losh   If Length is not aligned on a UINTN boundary, then ASSERT().
3480499b37cSWarner Losh   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3490499b37cSWarner Losh 
3500499b37cSWarner Losh   @param  Buffer      The pointer to the target buffer to scan.
3510499b37cSWarner Losh   @param  Length      The number of bytes in Buffer to scan.
3520499b37cSWarner Losh   @param  Value       The value to search for in the target buffer.
3530499b37cSWarner Losh 
3540499b37cSWarner Losh   @return A pointer to the matching byte in the target buffer, otherwise NULL.
3550499b37cSWarner Losh 
3560499b37cSWarner Losh **/
3570499b37cSWarner Losh VOID *
3580499b37cSWarner Losh EFIAPI
3590499b37cSWarner Losh ScanMemN (
3600499b37cSWarner Losh   IN CONST VOID  *Buffer,
3610499b37cSWarner Losh   IN UINTN       Length,
3620499b37cSWarner Losh   IN UINTN       Value
3630499b37cSWarner Losh   );
3640499b37cSWarner Losh 
3650499b37cSWarner Losh /**
3660499b37cSWarner Losh   Copies a source GUID to a destination GUID.
3670499b37cSWarner Losh 
3680499b37cSWarner Losh   This function copies the contents of the 128-bit GUID specified by SourceGuid to
3690499b37cSWarner Losh   DestinationGuid, and returns DestinationGuid.
3700499b37cSWarner Losh 
3710499b37cSWarner Losh   If DestinationGuid is NULL, then ASSERT().
3720499b37cSWarner Losh   If SourceGuid is NULL, then ASSERT().
3730499b37cSWarner Losh 
3740499b37cSWarner Losh   @param  DestinationGuid   The pointer to the destination GUID.
3750499b37cSWarner Losh   @param  SourceGuid        The pointer to the source GUID.
3760499b37cSWarner Losh 
3770499b37cSWarner Losh   @return DestinationGuid.
3780499b37cSWarner Losh 
3790499b37cSWarner Losh **/
3800499b37cSWarner Losh GUID *
3810499b37cSWarner Losh EFIAPI
3820499b37cSWarner Losh CopyGuid (
3830499b37cSWarner Losh   OUT GUID       *DestinationGuid,
3840499b37cSWarner Losh   IN CONST GUID  *SourceGuid
3850499b37cSWarner Losh   );
3860499b37cSWarner Losh 
3870499b37cSWarner Losh /**
3880499b37cSWarner Losh   Compares two GUIDs.
3890499b37cSWarner Losh 
3900499b37cSWarner Losh   This function compares Guid1 to Guid2.  If the GUIDs are identical then TRUE is returned.
3910499b37cSWarner Losh   If there are any bit differences in the two GUIDs, then FALSE is returned.
3920499b37cSWarner Losh 
3930499b37cSWarner Losh   If Guid1 is NULL, then ASSERT().
3940499b37cSWarner Losh   If Guid2 is NULL, then ASSERT().
3950499b37cSWarner Losh 
3960499b37cSWarner Losh   @param  Guid1       A pointer to a 128 bit GUID.
3970499b37cSWarner Losh   @param  Guid2       A pointer to a 128 bit GUID.
3980499b37cSWarner Losh 
3990499b37cSWarner Losh   @retval TRUE        Guid1 and Guid2 are identical.
4000499b37cSWarner Losh   @retval FALSE       Guid1 and Guid2 are not identical.
4010499b37cSWarner Losh 
4020499b37cSWarner Losh **/
4030499b37cSWarner Losh BOOLEAN
4040499b37cSWarner Losh EFIAPI
4050499b37cSWarner Losh CompareGuid (
4060499b37cSWarner Losh   IN CONST GUID  *Guid1,
4070499b37cSWarner Losh   IN CONST GUID  *Guid2
4080499b37cSWarner Losh   );
4090499b37cSWarner Losh 
4100499b37cSWarner Losh /**
4110499b37cSWarner Losh   Scans a target buffer for a GUID, and returns a pointer to the matching GUID
4120499b37cSWarner Losh   in the target buffer.
4130499b37cSWarner Losh 
4140499b37cSWarner Losh   This function searches target the buffer specified by Buffer and Length from
4150499b37cSWarner Losh   the lowest address to the highest address at 128-bit increments for the 128-bit
4160499b37cSWarner Losh   GUID value that matches Guid.  If a match is found, then a pointer to the matching
4170499b37cSWarner Losh   GUID in the target buffer is returned.  If no match is found, then NULL is returned.
4180499b37cSWarner Losh   If Length is 0, then NULL is returned.
4190499b37cSWarner Losh 
4200499b37cSWarner Losh   If Length > 0 and Buffer is NULL, then ASSERT().
4210499b37cSWarner Losh   If Buffer is not aligned on a 32-bit boundary, then ASSERT().
4220499b37cSWarner Losh   If Length is not aligned on a 128-bit boundary, then ASSERT().
4230499b37cSWarner Losh   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4240499b37cSWarner Losh 
4250499b37cSWarner Losh   @param  Buffer  The pointer to the target buffer to scan.
4260499b37cSWarner Losh   @param  Length  The number of bytes in Buffer to scan.
4270499b37cSWarner Losh   @param  Guid    The value to search for in the target buffer.
4280499b37cSWarner Losh 
4290499b37cSWarner Losh   @return A pointer to the matching Guid in the target buffer, otherwise NULL.
4300499b37cSWarner Losh 
4310499b37cSWarner Losh **/
4320499b37cSWarner Losh VOID *
4330499b37cSWarner Losh EFIAPI
4340499b37cSWarner Losh ScanGuid (
4350499b37cSWarner Losh   IN CONST VOID  *Buffer,
4360499b37cSWarner Losh   IN UINTN       Length,
4370499b37cSWarner Losh   IN CONST GUID  *Guid
4380499b37cSWarner Losh   );
4390499b37cSWarner Losh 
4400499b37cSWarner Losh /**
4410499b37cSWarner Losh   Checks if the given GUID is a zero GUID.
4420499b37cSWarner Losh 
4430499b37cSWarner Losh   This function checks whether the given GUID is a zero GUID. If the GUID is
4440499b37cSWarner Losh   identical to a zero GUID then TRUE is returned. Otherwise, FALSE is returned.
4450499b37cSWarner Losh 
4460499b37cSWarner Losh   If Guid is NULL, then ASSERT().
4470499b37cSWarner Losh 
4480499b37cSWarner Losh   @param  Guid        The pointer to a 128 bit GUID.
4490499b37cSWarner Losh 
4500499b37cSWarner Losh   @retval TRUE        Guid is a zero GUID.
4510499b37cSWarner Losh   @retval FALSE       Guid is not a zero GUID.
4520499b37cSWarner Losh 
4530499b37cSWarner Losh **/
4540499b37cSWarner Losh BOOLEAN
4550499b37cSWarner Losh EFIAPI
4560499b37cSWarner Losh IsZeroGuid (
4570499b37cSWarner Losh   IN CONST GUID  *Guid
4580499b37cSWarner Losh   );
4590499b37cSWarner Losh 
4600499b37cSWarner Losh /**
4610499b37cSWarner Losh   Checks if the contents of a buffer are all zeros.
4620499b37cSWarner Losh 
4630499b37cSWarner Losh   This function checks whether the contents of a buffer are all zeros. If the
4640499b37cSWarner Losh   contents are all zeros, return TRUE. Otherwise, return FALSE.
4650499b37cSWarner Losh 
4660499b37cSWarner Losh   If Length > 0 and Buffer is NULL, then ASSERT().
4670499b37cSWarner Losh   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4680499b37cSWarner Losh 
4690499b37cSWarner Losh   @param  Buffer      The pointer to the buffer to be checked.
4700499b37cSWarner Losh   @param  Length      The size of the buffer (in bytes) to be checked.
4710499b37cSWarner Losh 
4720499b37cSWarner Losh   @retval TRUE        Contents of the buffer are all zeros.
4730499b37cSWarner Losh   @retval FALSE       Contents of the buffer are not all zeros.
4740499b37cSWarner Losh 
4750499b37cSWarner Losh **/
4760499b37cSWarner Losh BOOLEAN
4770499b37cSWarner Losh EFIAPI
4780499b37cSWarner Losh IsZeroBuffer (
4790499b37cSWarner Losh   IN CONST VOID  *Buffer,
4800499b37cSWarner Losh   IN UINTN       Length
4810499b37cSWarner Losh   );
4820499b37cSWarner Losh 
4830499b37cSWarner Losh #endif
484