/** @file\r
- Memory-only library functions with no library constructor/destructor\r
+ Memory-only library functions with no library constructor/destructor\r
\r
- Copyright (c) 2006, Intel Corporation\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
+ Copyright (c) 2006, Intel Corporation\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
-\r
- Module Name: BaseMemoryLib.h\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
\r
**/\r
\r
#define __BASE_MEMORY_LIB__\r
\r
/**\r
- Copy Length bytes from Source to Destination.\r
-\r
- This function copies Length bytes from SourceBuffer to DestinationBuffer, and\r
- returns DestinationBuffer. The implementation must be reentrant, and it must\r
- handle the case where SourceBuffer overlaps DestinationBuffer.\r
+ Copies a source buffer to a destination buffer, and returns the destination buffer.\r
\r
- If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then\r
- ASSERT().\r
+ This function copies Length bytes from SourceBuffer to DestinationBuffer, and returns\r
+ DestinationBuffer. The implementation must be reentrant, and it must handle the case\r
+ where SourceBuffer overlaps DestinationBuffer.\r
+ If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT().\r
If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().\r
\r
- @param Destination Target of copy\r
- @param Source Place to copy from\r
- @param Length Number of bytes to copy\r
+ @param DestinationBuffer Pointer to the destination buffer of the memory copy.\r
+ @param SourceBuffer Pointer to the source buffer of the memory copy.\r
+ @param Length Number of bytes to copy from SourceBuffer to DestinationBuffer.\r
\r
- @return Destination\r
+ @return DestinationBuffer.\r
\r
**/\r
VOID *\r
EFIAPI\r
CopyMem (\r
- OUT VOID *DestinationBuffer,\r
- IN CONST VOID *SourceBuffer,\r
- IN UINTN Length\r
+ OUT VOID *DestinationBuffer,\r
+ IN CONST VOID *SourceBuffer,\r
+ IN UINTN Length\r
);\r
\r
/**\r
- Set Buffer to Value for Size bytes.\r
+ Fills a target buffer with a byte value, and returns the target buffer.\r
\r
This function fills Length bytes of Buffer with Value, and returns Buffer.\r
+ If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().\r
\r
- If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
-\r
- @param Buffer Memory to set.\r
- @param Size Number of bytes to set\r
- @param Value Value of the set operation.\r
+ @param Buffer Memory to set.\r
+ @param Length Number of bytes to set.\r
+ @param Value Value of the set operation.\r
\r
- @return Buffer\r
+ @return Buffer.\r
\r
**/\r
VOID *\r
EFIAPI\r
SetMem (\r
- OUT VOID *Buffer,\r
- IN UINTN Length,\r
- IN UINT8 Value\r
+ OUT VOID *Buffer,\r
+ IN UINTN Length,\r
+ IN UINT8 Value\r
);\r
\r
/**\r
Value, and returns Buffer. Value is repeated every 16-bits in for Length\r
bytes of Buffer.\r
\r
- If Buffer is NULL and Length > 0, then ASSERT().\r
+ If Length > 0 and Buffer is NULL, then ASSERT().\r
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r
If Length is not aligned on a 16-bit boundary, then ASSERT().\r
@param Length Number of bytes in Buffer to fill.\r
@param Value Value with which to fill Length bytes of Buffer.\r
\r
- @return Buffer\r
+ @return Buffer.\r
\r
**/\r
VOID *\r
EFIAPI\r
SetMem16 (\r
- OUT VOID *Buffer,\r
- IN UINTN Length,\r
- IN UINT16 Value\r
+ OUT VOID *Buffer,\r
+ IN UINTN Length,\r
+ IN UINT16 Value\r
);\r
\r
/**\r
Value, and returns Buffer. Value is repeated every 32-bits in for Length\r
bytes of Buffer.\r
\r
- If Buffer is NULL and Length > 0, then ASSERT().\r
+ If Length > 0 and Buffer is NULL, then ASSERT().\r
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r
If Length is not aligned on a 32-bit boundary, then ASSERT().\r
@param Length Number of bytes in Buffer to fill.\r
@param Value Value with which to fill Length bytes of Buffer.\r
\r
- @return Buffer\r
+ @return Buffer.\r
\r
**/\r
VOID *\r
EFIAPI\r
SetMem32 (\r
- OUT VOID *Buffer,\r
- IN UINTN Length,\r
- IN UINT32 Value\r
+ OUT VOID *Buffer,\r
+ IN UINTN Length,\r
+ IN UINT32 Value\r
);\r
\r
/**\r
Value, and returns Buffer. Value is repeated every 64-bits in for Length\r
bytes of Buffer.\r
\r
- If Buffer is NULL and Length > 0, then ASSERT().\r
+ If Length > 0 and Buffer is NULL, then ASSERT().\r
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r
If Length is not aligned on a 64-bit boundary, then ASSERT().\r
@param Length Number of bytes in Buffer to fill.\r
@param Value Value with which to fill Length bytes of Buffer.\r
\r
- @return Buffer\r
+ @return Buffer.\r
\r
**/\r
VOID *\r
EFIAPI\r
SetMem64 (\r
- OUT VOID *Buffer,\r
- IN UINTN Length,\r
- IN UINT64 Value\r
+ OUT VOID *Buffer,\r
+ IN UINTN Length,\r
+ IN UINT64 Value\r
);\r
\r
/**\r
- Set Buffer to 0 for Size bytes.\r
+ Fills a target buffer with zeros, and returns the target buffer.\r
\r
This function fills Length bytes of Buffer with zeros, and returns Buffer.\r
+ If Length > 0 and Buffer is NULL, then ASSERT().\r
+ If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().\r
\r
- If Buffer is NULL and Length > 0, then ASSERT().\r
- If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
-\r
- @param Buffer Memory to set.\r
- @param Size Number of bytes to set\r
+ @param Buffer Pointer to the target buffer to fill with zeros.\r
+ @param Length Number of bytes in Buffer to fill with zeros.\r
\r
- @return Buffer\r
+ @return Buffer.\r
\r
**/\r
VOID *\r
EFIAPI\r
ZeroMem (\r
- OUT VOID *Buffer,\r
- IN UINTN Length\r
+ OUT VOID *Buffer,\r
+ IN UINTN Length\r
);\r
\r
/**\r
- Compares two memory buffers of a given length.\r
-\r
- This function compares Length bytes of SourceBuffer to Length bytes of\r
- DestinationBuffer. If all Length bytes of the two buffers are identical, then\r
- 0 is returned. Otherwise, the value returned is the first mismatched byte in\r
- SourceBuffer subtracted from the first mismatched byte in DestinationBuffer.\r
-\r
- If DestinationBuffer is NULL and Length > 0, then ASSERT().\r
- If SourceBuffer is NULL and Length > 0, then ASSERT().\r
- If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then\r
- ASSERT().\r
+ Compares the contents of two buffers.\r
+\r
+ This function compares Length bytes of SourceBuffer to Length bytes of DestinationBuffer.\r
+ If all Length bytes of the two buffers are identical, then 0 is returned. Otherwise, the\r
+ value returned is the first mismatched byte in SourceBuffer subtracted from the first\r
+ mismatched byte in DestinationBuffer.\r
+ If Length > 0 and DestinationBuffer is NULL and Length > 0, then ASSERT().\r
+ If Length > 0 and SourceBuffer is NULL and Length > 0, then ASSERT().\r
+ If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT().\r
If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().\r
\r
- @param DestinationBuffer First memory buffer\r
- @param SourceBuffer Second memory buffer\r
- @param Length Length of DestinationBuffer and SourceBuffer memory\r
- regions to compare\r
+ @param DestinationBuffer Pointer to the destination buffer to compare.\r
+ @param SourceBuffer Pointer to the source buffer to compare.\r
+ @param Length Number of bytes to compare.\r
\r
- @retval 0 if DestinationBuffer == SourceBuffer\r
- @retval Non-zero if DestinationBuffer != SourceBuffer\r
+ @return 0 All Length bytes of the two buffers are identical.\r
+ @retval Non-zero The first mismatched byte in SourceBuffer subtracted from the first\r
+ mismatched byte in DestinationBuffer.\r
\r
**/\r
INTN\r
EFIAPI\r
CompareMem (\r
- IN CONST VOID *DestinationBuffer,\r
- IN CONST VOID *SourceBuffer,\r
- IN UINTN Length\r
+ IN CONST VOID *DestinationBuffer,\r
+ IN CONST VOID *SourceBuffer,\r
+ IN UINTN Length\r
);\r
\r
/**\r
- Scans a target buffer for an 8-bit value, and returns a pointer to the\r
- matching 8-bit value in the target buffer.\r
+ Scans a target buffer for an 8-bit value, and returns a pointer to the matching 8-bit value\r
+ in the target buffer.\r
\r
- This function searches target the buffer specified by Buffer and Length from\r
- the lowest address to the highest address for an 8-bit value that matches\r
- Value. If a match is found, then a pointer to the matching byte in the target\r
- buffer is returned. If no match is found, then NULL is returned. If Length is\r
- 0, then NULL is returned.\r
+ This function searches target the buffer specified by Buffer and Length from the lowest\r
+ address to the highest address for an 8-bit value that matches Value. If a match is found,\r
+ then a pointer to the matching byte in the target buffer is returned. If no match is found,\r
+ then NULL is returned. If Length is 0, then NULL is returned.\r
+ If Length > 0 and Buffer is NULL, then ASSERT().\r
+ If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().\r
\r
- If Buffer is NULL, then ASSERT().\r
- If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+ @param Buffer Pointer to the target buffer to scan.\r
+ @param Length Number of bytes in Buffer to scan.\r
+ @param Value Value to search for in the target buffer.\r
\r
- @param Buffer Pointer to the target buffer to scan.\r
- @param Length Number of bytes in Buffer to scan.\r
- @param Value Value to search for in the target buffer.\r
-\r
- @return Pointer to the first occurrence or NULL if not found.\r
- @retval NULL if Length == 0 or Value was not found.\r
+ @return A pointer to the matching byte in the target buffer or NULL otherwise.\r
\r
**/\r
VOID *\r
EFIAPI\r
ScanMem8 (\r
- IN CONST VOID *Buffer,\r
- IN UINTN Length,\r
- IN UINT8 Value\r
+ IN CONST VOID *Buffer,\r
+ IN UINTN Length,\r
+ IN UINT8 Value\r
);\r
\r
/**\r
- Scans a target buffer for a 16-bit value, and returns a pointer to the\r
- matching 16-bit value in the target buffer.\r
-\r
- This function searches target the buffer specified by Buffer and Length from\r
- the lowest address to the highest address at 16-bit increments for a 16-bit\r
- value that matches Value. If a match is found, then a pointer to the matching\r
- value in the target buffer is returned. If no match is found, then NULL is\r
- returned. If Length is 0, then NULL is returned.\r
+ Scans a target buffer for a 16-bit value, and returns a pointer to the matching 16-bit value\r
+ in the target buffer.\r
\r
- If Buffer is NULL, then ASSERT().\r
+ This function searches target the buffer specified by Buffer and Length from the lowest\r
+ address to the highest address for a 16-bit value that matches Value. If a match is found,\r
+ then a pointer to the matching byte in the target buffer is returned. If no match is found,\r
+ then NULL is returned. If Length is 0, then NULL is returned.\r
+ If Length > 0 and Buffer is NULL, then ASSERT().\r
If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r
- If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+ If Length is not aligned on a 16-bit boundary, then ASSERT().\r
+ If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().\r
\r
- @param Buffer Pointer to the target buffer to scan.\r
- @param Length Number of bytes in Buffer to scan.\r
- @param Value Value to search for in the target buffer.\r
+ @param Buffer Pointer to the target buffer to scan.\r
+ @param Length Number of bytes in Buffer to scan.\r
+ @param Value Value to search for in the target buffer.\r
\r
- @return Pointer to the first occurrence.\r
- @retval NULL if Length == 0 or Value was not found.\r
+ @return A pointer to the matching byte in the target buffer or NULL otherwise.\r
\r
**/\r
VOID *\r
EFIAPI\r
ScanMem16 (\r
- IN CONST VOID *Buffer,\r
- IN UINTN Length,\r
- IN UINT16 Value\r
+ IN CONST VOID *Buffer,\r
+ IN UINTN Length,\r
+ IN UINT16 Value\r
);\r
\r
/**\r
- Scans a target buffer for a 32-bit value, and returns a pointer to the\r
- matching 32-bit value in the target buffer.\r
-\r
- This function searches target the buffer specified by Buffer and Length from\r
- the lowest address to the highest address at 32-bit increments for a 32-bit\r
- value that matches Value. If a match is found, then a pointer to the matching\r
- value in the target buffer is returned. If no match is found, then NULL is\r
- returned. If Length is 0, then NULL is returned.\r
+ Scans a target buffer for a 32-bit value, and returns a pointer to the matching 32-bit value\r
+ in the target buffer.\r
\r
- If Buffer is NULL, then ASSERT().\r
+ This function searches target the buffer specified by Buffer and Length from the lowest\r
+ address to the highest address for a 32-bit value that matches Value. If a match is found,\r
+ then a pointer to the matching byte in the target buffer is returned. If no match is found,\r
+ then NULL is returned. If Length is 0, then NULL is returned.\r
+ If Length > 0 and Buffer is NULL, then ASSERT().\r
If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r
- If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+ If Length is not aligned on a 32-bit boundary, then ASSERT().\r
+ If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().\r
\r
- @param Buffer Pointer to the target buffer to scan.\r
- @param Length Number of bytes in Buffer to scan.\r
- @param Value Value to search for in the target buffer.\r
+ @param Buffer Pointer to the target buffer to scan.\r
+ @param Length Number of bytes in Buffer to scan.\r
+ @param Value Value to search for in the target buffer.\r
\r
- @return Pointer to the first occurrence or NULL if not found.\r
- @retval NULL if Length == 0 or Value was not found.\r
+ @return A pointer to the matching byte in the target buffer or NULL otherwise.\r
\r
**/\r
VOID *\r
EFIAPI\r
ScanMem32 (\r
- IN CONST VOID *Buffer,\r
- IN UINTN Length,\r
- IN UINT32 Value\r
+ IN CONST VOID *Buffer,\r
+ IN UINTN Length,\r
+ IN UINT32 Value\r
);\r
\r
/**\r
- Scans a target buffer for a 64-bit value, and returns a pointer to the\r
- matching 64-bit value in the target buffer.\r
-\r
- This function searches target the buffer specified by Buffer and Length from\r
- the lowest address to the highest address at 64-bit increments for a 64-bit\r
- value that matches Value. If a match is found, then a pointer to the matching\r
- value in the target buffer is returned. If no match is found, then NULL is\r
- returned. If Length is 0, then NULL is returned.\r
+ Scans a target buffer for a 64-bit value, and returns a pointer to the matching 64-bit value\r
+ in the target buffer.\r
\r
- If Buffer is NULL, then ASSERT().\r
+ This function searches target the buffer specified by Buffer and Length from the lowest\r
+ address to the highest address for a 64-bit value that matches Value. If a match is found,\r
+ then a pointer to the matching byte in the target buffer is returned. If no match is found,\r
+ then NULL is returned. If Length is 0, then NULL is returned.\r
+ If Length > 0 and Buffer is NULL, then ASSERT().\r
If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r
- If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+ If Length is not aligned on a 64-bit boundary, then ASSERT().\r
+ If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().\r
\r
- @param Buffer Pointer to the target buffer to scan.\r
- @param Length Number of bytes in Buffer to scan.\r
- @param Value Value to search for in the target buffer.\r
+ @param Buffer Pointer to the target buffer to scan.\r
+ @param Length Number of bytes in Buffer to scan.\r
+ @param Value Value to search for in the target buffer.\r
\r
- @return Pointer to the first occurrence or NULL if not found.\r
- @retval NULL if Length == 0 or Value was not found.\r
+ @return A pointer to the matching byte in the target buffer or NULL otherwise.\r
\r
**/\r
VOID *\r
EFIAPI\r
ScanMem64 (\r
- IN CONST VOID *Buffer,\r
- IN UINTN Length,\r
- IN UINT64 Value\r
+ IN CONST VOID *Buffer,\r
+ IN UINTN Length,\r
+ IN UINT64 Value\r
);\r
\r
/**\r
- This function copies a source GUID to a destination GUID.\r
-\r
- This function copies the contents of the 128-bit GUID specified by SourceGuid\r
- to DestinationGuid, and returns DestinationGuid.\r
+ Copies a source GUID to a destination GUID.\r
\r
+ This function copies the contents of the 128-bit GUID specified by SourceGuid to\r
+ DestinationGuid, and returns DestinationGuid.\r
If DestinationGuid is NULL, then ASSERT().\r
If SourceGuid is NULL, then ASSERT().\r
\r
- @param DestinationGuid Pointer to the destination GUID.\r
- @param SourceGuid Pointer to the source GUID.\r
+ @param DestinationGuid Pointer to the destination GUID.\r
+ @param SourceGuid Pointer to the source GUID.\r
\r
- @return DestinationGuid\r
+ @return DestinationGuid.\r
\r
**/\r
GUID *\r
EFIAPI\r
CopyGuid (\r
- OUT GUID *DestinationGuid,\r
- IN CONST GUID *SourceGuid\r
+ OUT GUID *DestinationGuid,\r
+ IN CONST GUID *SourceGuid\r
);\r
\r
/**\r
- Compares two GUIDs\r
-\r
- This function compares Guid1 to Guid2. If the GUIDs are identical then TRUE\r
- is returned. If there are any bit differences in the two GUIDs, then FALSE is\r
- returned.\r
+ Compares two GUIDs.\r
\r
+ This function compares Guid1 to Guid2. If the GUIDs are identical then TRUE is returned.\r
+ If there are any bit differences in the two GUIDs, then FALSE is returned.\r
If Guid1 is NULL, then ASSERT().\r
If Guid2 is NULL, then ASSERT().\r
\r
- @param Guid1 guid to compare\r
- @param Guid2 guid to compare\r
+ @param Guid1 A pointer to a 128 bit GUID.\r
+ @param Guid2 A pointer to a 128 bit GUID.\r
\r
- @retval TRUE if Guid1 == Guid2\r
- @retval FALSE if Guid1 != Guid2\r
+ @retval TRUE Guid1 and Guid2 are identical.\r
+ @retval FALSE Guid1 and Guid2 are not identical.\r
\r
**/\r
BOOLEAN\r
EFIAPI\r
CompareGuid (\r
- IN CONST GUID *Guid1,\r
- IN CONST GUID *Guid2\r
+ IN CONST GUID *Guid1,\r
+ IN CONST GUID *Guid2\r
);\r
\r
/**\r
in the target buffer.\r
\r
This function searches target the buffer specified by Buffer and Length from\r
- the lowest address to the highest address at 128-bit increments for the\r
- 128-bit GUID value that matches Guid. If a match is found, then a pointer to\r
- the matching GUID in the target buffer is returned. If no match is found,\r
- then NULL is returned. If Length is 0, then NULL is returned.\r
-\r
- If Buffer is NULL, then ASSERT().\r
- If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r
- If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+ the lowest address to the highest address at 128-bit increments for the 128-bit\r
+ GUID value that matches Guid. If a match is found, then a pointer to the matching\r
+ GUID in the target buffer is returned. If no match is found, then NULL is returned.\r
+ If Length is 0, then NULL is returned.\r
+ If Length > 0 and Buffer is NULL, then ASSERT().\r
+ If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r
+ If Length is not aligned on a 128-bit boundary, then ASSERT().\r
+ If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().\r
\r
@param Buffer Pointer to the target buffer to scan.\r
@param Length Number of bytes in Buffer to scan.\r
@param Guid Value to search for in the target buffer.\r
\r
- @return Pointer to the first occurrence.\r
- @retval NULL if Length == 0 or Guid was not found.\r
+ @return A pointer to the matching Guid in the target buffer or NULL otherwise.\r
+\r
**/\r
VOID *\r
EFIAPI\r
ScanGuid (\r
- IN CONST VOID *Buffer,\r
- IN UINTN Length,\r
- IN CONST GUID *Guid\r
+ IN CONST VOID *Buffer,\r
+ IN UINTN Length,\r
+ IN CONST GUID *Guid\r
);\r
\r
#endif\r