1*1370a723SSascha Wildner /** @file 2*1370a723SSascha Wildner Provides copy memory, fill memory, zero memory, and GUID functions. 3*1370a723SSascha Wildner 4*1370a723SSascha Wildner The Base Memory Library provides optimized implementations for common memory-based operations. 5*1370a723SSascha Wildner These functions should be used in place of coding your own loops to do equivalent common functions. 6*1370a723SSascha Wildner This allows optimized library implementations to help increase performance. 7*1370a723SSascha Wildner 8*1370a723SSascha Wildner Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR> 9*1370a723SSascha Wildner SPDX-License-Identifier: BSD-2-Clause-Patent 10*1370a723SSascha Wildner 11*1370a723SSascha Wildner **/ 12*1370a723SSascha Wildner 13*1370a723SSascha Wildner #ifndef __BASE_MEMORY_LIB__ 14*1370a723SSascha Wildner #define __BASE_MEMORY_LIB__ 15*1370a723SSascha Wildner 16*1370a723SSascha Wildner /** 17*1370a723SSascha Wildner Copies a source buffer to a destination buffer, and returns the destination buffer. 18*1370a723SSascha Wildner 19*1370a723SSascha Wildner This function copies Length bytes from SourceBuffer to DestinationBuffer, and returns 20*1370a723SSascha Wildner DestinationBuffer. The implementation must be reentrant, and it must handle the case 21*1370a723SSascha Wildner where SourceBuffer overlaps DestinationBuffer. 22*1370a723SSascha Wildner 23*1370a723SSascha Wildner If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT(). 24*1370a723SSascha Wildner If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT(). 25*1370a723SSascha Wildner 26*1370a723SSascha Wildner @param DestinationBuffer The pointer to the destination buffer of the memory copy. 27*1370a723SSascha Wildner @param SourceBuffer The pointer to the source buffer of the memory copy. 28*1370a723SSascha Wildner @param Length The number of bytes to copy from SourceBuffer to DestinationBuffer. 29*1370a723SSascha Wildner 30*1370a723SSascha Wildner @return DestinationBuffer. 31*1370a723SSascha Wildner 32*1370a723SSascha Wildner **/ 33*1370a723SSascha Wildner VOID * 34*1370a723SSascha Wildner EFIAPI 35*1370a723SSascha Wildner CopyMem ( 36*1370a723SSascha Wildner OUT VOID *DestinationBuffer, 37*1370a723SSascha Wildner IN CONST VOID *SourceBuffer, 38*1370a723SSascha Wildner IN UINTN Length 39*1370a723SSascha Wildner ); 40*1370a723SSascha Wildner 41*1370a723SSascha Wildner /** 42*1370a723SSascha Wildner Fills a target buffer with a byte value, and returns the target buffer. 43*1370a723SSascha Wildner 44*1370a723SSascha Wildner This function fills Length bytes of Buffer with Value, and returns Buffer. 45*1370a723SSascha Wildner 46*1370a723SSascha Wildner If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). 47*1370a723SSascha Wildner 48*1370a723SSascha Wildner @param Buffer The memory to set. 49*1370a723SSascha Wildner @param Length The number of bytes to set. 50*1370a723SSascha Wildner @param Value The value with which to fill Length bytes of Buffer. 51*1370a723SSascha Wildner 52*1370a723SSascha Wildner @return Buffer. 53*1370a723SSascha Wildner 54*1370a723SSascha Wildner **/ 55*1370a723SSascha Wildner VOID * 56*1370a723SSascha Wildner EFIAPI 57*1370a723SSascha Wildner SetMem ( 58*1370a723SSascha Wildner OUT VOID *Buffer, 59*1370a723SSascha Wildner IN UINTN Length, 60*1370a723SSascha Wildner IN UINT8 Value 61*1370a723SSascha Wildner ); 62*1370a723SSascha Wildner 63*1370a723SSascha Wildner /** 64*1370a723SSascha Wildner Fills a target buffer with a 16-bit value, and returns the target buffer. 65*1370a723SSascha Wildner 66*1370a723SSascha Wildner This function fills Length bytes of Buffer with the 16-bit value specified by 67*1370a723SSascha Wildner Value, and returns Buffer. Value is repeated every 16-bits in for Length 68*1370a723SSascha Wildner bytes of Buffer. 69*1370a723SSascha Wildner 70*1370a723SSascha Wildner If Length > 0 and Buffer is NULL, then ASSERT(). 71*1370a723SSascha Wildner If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). 72*1370a723SSascha Wildner If Buffer is not aligned on a 16-bit boundary, then ASSERT(). 73*1370a723SSascha Wildner If Length is not aligned on a 16-bit boundary, then ASSERT(). 74*1370a723SSascha Wildner 75*1370a723SSascha Wildner @param Buffer The pointer to the target buffer to fill. 76*1370a723SSascha Wildner @param Length The number of bytes in Buffer to fill. 77*1370a723SSascha Wildner @param Value The value with which to fill Length bytes of Buffer. 78*1370a723SSascha Wildner 79*1370a723SSascha Wildner @return Buffer. 80*1370a723SSascha Wildner 81*1370a723SSascha Wildner **/ 82*1370a723SSascha Wildner VOID * 83*1370a723SSascha Wildner EFIAPI 84*1370a723SSascha Wildner SetMem16 ( 85*1370a723SSascha Wildner OUT VOID *Buffer, 86*1370a723SSascha Wildner IN UINTN Length, 87*1370a723SSascha Wildner IN UINT16 Value 88*1370a723SSascha Wildner ); 89*1370a723SSascha Wildner 90*1370a723SSascha Wildner /** 91*1370a723SSascha Wildner Fills a target buffer with a 32-bit value, and returns the target buffer. 92*1370a723SSascha Wildner 93*1370a723SSascha Wildner This function fills Length bytes of Buffer with the 32-bit value specified by 94*1370a723SSascha Wildner Value, and returns Buffer. Value is repeated every 32-bits in for Length 95*1370a723SSascha Wildner bytes of Buffer. 96*1370a723SSascha Wildner 97*1370a723SSascha Wildner If Length > 0 and Buffer is NULL, then ASSERT(). 98*1370a723SSascha Wildner If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). 99*1370a723SSascha Wildner If Buffer is not aligned on a 32-bit boundary, then ASSERT(). 100*1370a723SSascha Wildner If Length is not aligned on a 32-bit boundary, then ASSERT(). 101*1370a723SSascha Wildner 102*1370a723SSascha Wildner @param Buffer The pointer to the target buffer to fill. 103*1370a723SSascha Wildner @param Length The number of bytes in Buffer to fill. 104*1370a723SSascha Wildner @param Value The value with which to fill Length bytes of Buffer. 105*1370a723SSascha Wildner 106*1370a723SSascha Wildner @return Buffer. 107*1370a723SSascha Wildner 108*1370a723SSascha Wildner **/ 109*1370a723SSascha Wildner VOID * 110*1370a723SSascha Wildner EFIAPI 111*1370a723SSascha Wildner SetMem32 ( 112*1370a723SSascha Wildner OUT VOID *Buffer, 113*1370a723SSascha Wildner IN UINTN Length, 114*1370a723SSascha Wildner IN UINT32 Value 115*1370a723SSascha Wildner ); 116*1370a723SSascha Wildner 117*1370a723SSascha Wildner /** 118*1370a723SSascha Wildner Fills a target buffer with a 64-bit value, and returns the target buffer. 119*1370a723SSascha Wildner 120*1370a723SSascha Wildner This function fills Length bytes of Buffer with the 64-bit value specified by 121*1370a723SSascha Wildner Value, and returns Buffer. Value is repeated every 64-bits in for Length 122*1370a723SSascha Wildner bytes of Buffer. 123*1370a723SSascha Wildner 124*1370a723SSascha Wildner If Length > 0 and Buffer is NULL, then ASSERT(). 125*1370a723SSascha Wildner If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). 126*1370a723SSascha Wildner If Buffer is not aligned on a 64-bit boundary, then ASSERT(). 127*1370a723SSascha Wildner If Length is not aligned on a 64-bit boundary, then ASSERT(). 128*1370a723SSascha Wildner 129*1370a723SSascha Wildner @param Buffer The pointer to the target buffer to fill. 130*1370a723SSascha Wildner @param Length The number of bytes in Buffer to fill. 131*1370a723SSascha Wildner @param Value The value with which to fill Length bytes of Buffer. 132*1370a723SSascha Wildner 133*1370a723SSascha Wildner @return Buffer. 134*1370a723SSascha Wildner 135*1370a723SSascha Wildner **/ 136*1370a723SSascha Wildner VOID * 137*1370a723SSascha Wildner EFIAPI 138*1370a723SSascha Wildner SetMem64 ( 139*1370a723SSascha Wildner OUT VOID *Buffer, 140*1370a723SSascha Wildner IN UINTN Length, 141*1370a723SSascha Wildner IN UINT64 Value 142*1370a723SSascha Wildner ); 143*1370a723SSascha Wildner 144*1370a723SSascha Wildner /** 145*1370a723SSascha Wildner Fills a target buffer with a value that is size UINTN, and returns the target buffer. 146*1370a723SSascha Wildner 147*1370a723SSascha Wildner This function fills Length bytes of Buffer with the UINTN sized value specified by 148*1370a723SSascha Wildner Value, and returns Buffer. Value is repeated every sizeof(UINTN) bytes for Length 149*1370a723SSascha Wildner bytes of Buffer. 150*1370a723SSascha Wildner 151*1370a723SSascha Wildner If Length > 0 and Buffer is NULL, then ASSERT(). 152*1370a723SSascha Wildner If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). 153*1370a723SSascha Wildner If Buffer is not aligned on a UINTN boundary, then ASSERT(). 154*1370a723SSascha Wildner If Length is not aligned on a UINTN boundary, then ASSERT(). 155*1370a723SSascha Wildner 156*1370a723SSascha Wildner @param Buffer The pointer to the target buffer to fill. 157*1370a723SSascha Wildner @param Length The number of bytes in Buffer to fill. 158*1370a723SSascha Wildner @param Value The value with which to fill Length bytes of Buffer. 159*1370a723SSascha Wildner 160*1370a723SSascha Wildner @return Buffer. 161*1370a723SSascha Wildner 162*1370a723SSascha Wildner **/ 163*1370a723SSascha Wildner VOID * 164*1370a723SSascha Wildner EFIAPI 165*1370a723SSascha Wildner SetMemN ( 166*1370a723SSascha Wildner OUT VOID *Buffer, 167*1370a723SSascha Wildner IN UINTN Length, 168*1370a723SSascha Wildner IN UINTN Value 169*1370a723SSascha Wildner ); 170*1370a723SSascha Wildner 171*1370a723SSascha Wildner /** 172*1370a723SSascha Wildner Fills a target buffer with zeros, and returns the target buffer. 173*1370a723SSascha Wildner 174*1370a723SSascha Wildner This function fills Length bytes of Buffer with zeros, and returns Buffer. 175*1370a723SSascha Wildner 176*1370a723SSascha Wildner If Length > 0 and Buffer is NULL, then ASSERT(). 177*1370a723SSascha Wildner If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). 178*1370a723SSascha Wildner 179*1370a723SSascha Wildner @param Buffer The pointer to the target buffer to fill with zeros. 180*1370a723SSascha Wildner @param Length The number of bytes in Buffer to fill with zeros. 181*1370a723SSascha Wildner 182*1370a723SSascha Wildner @return Buffer. 183*1370a723SSascha Wildner 184*1370a723SSascha Wildner **/ 185*1370a723SSascha Wildner VOID * 186*1370a723SSascha Wildner EFIAPI 187*1370a723SSascha Wildner ZeroMem ( 188*1370a723SSascha Wildner OUT VOID *Buffer, 189*1370a723SSascha Wildner IN UINTN Length 190*1370a723SSascha Wildner ); 191*1370a723SSascha Wildner 192*1370a723SSascha Wildner /** 193*1370a723SSascha Wildner Compares the contents of two buffers. 194*1370a723SSascha Wildner 195*1370a723SSascha Wildner This function compares Length bytes of SourceBuffer to Length bytes of DestinationBuffer. 196*1370a723SSascha Wildner If all Length bytes of the two buffers are identical, then 0 is returned. Otherwise, the 197*1370a723SSascha Wildner value returned is the first mismatched byte in SourceBuffer subtracted from the first 198*1370a723SSascha Wildner mismatched byte in DestinationBuffer. 199*1370a723SSascha Wildner 200*1370a723SSascha Wildner If Length > 0 and DestinationBuffer is NULL, then ASSERT(). 201*1370a723SSascha Wildner If Length > 0 and SourceBuffer is NULL, then ASSERT(). 202*1370a723SSascha Wildner If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT(). 203*1370a723SSascha Wildner If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT(). 204*1370a723SSascha Wildner 205*1370a723SSascha Wildner @param DestinationBuffer The pointer to the destination buffer to compare. 206*1370a723SSascha Wildner @param SourceBuffer The pointer to the source buffer to compare. 207*1370a723SSascha Wildner @param Length The number of bytes to compare. 208*1370a723SSascha Wildner 209*1370a723SSascha Wildner @return 0 All Length bytes of the two buffers are identical. 210*1370a723SSascha Wildner @retval Non-zero The first mismatched byte in SourceBuffer subtracted from the first 211*1370a723SSascha Wildner mismatched byte in DestinationBuffer. 212*1370a723SSascha Wildner 213*1370a723SSascha Wildner **/ 214*1370a723SSascha Wildner INTN 215*1370a723SSascha Wildner EFIAPI 216*1370a723SSascha Wildner CompareMem ( 217*1370a723SSascha Wildner IN CONST VOID *DestinationBuffer, 218*1370a723SSascha Wildner IN CONST VOID *SourceBuffer, 219*1370a723SSascha Wildner IN UINTN Length 220*1370a723SSascha Wildner ); 221*1370a723SSascha Wildner 222*1370a723SSascha Wildner /** 223*1370a723SSascha Wildner Scans a target buffer for an 8-bit value, and returns a pointer to the matching 8-bit value 224*1370a723SSascha Wildner in the target buffer. 225*1370a723SSascha Wildner 226*1370a723SSascha Wildner This function searches target the buffer specified by Buffer and Length from the lowest 227*1370a723SSascha Wildner address to the highest address for an 8-bit value that matches Value. If a match is found, 228*1370a723SSascha Wildner then a pointer to the matching byte in the target buffer is returned. If no match is found, 229*1370a723SSascha Wildner then NULL is returned. If Length is 0, then NULL is returned. 230*1370a723SSascha Wildner 231*1370a723SSascha Wildner If Length > 0 and Buffer is NULL, then ASSERT(). 232*1370a723SSascha Wildner If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). 233*1370a723SSascha Wildner 234*1370a723SSascha Wildner @param Buffer The pointer to the target buffer to scan. 235*1370a723SSascha Wildner @param Length The number of bytes in Buffer to scan. 236*1370a723SSascha Wildner @param Value The value to search for in the target buffer. 237*1370a723SSascha Wildner 238*1370a723SSascha Wildner @return A pointer to the matching byte in the target buffer, otherwise NULL. 239*1370a723SSascha Wildner 240*1370a723SSascha Wildner **/ 241*1370a723SSascha Wildner VOID * 242*1370a723SSascha Wildner EFIAPI 243*1370a723SSascha Wildner ScanMem8 ( 244*1370a723SSascha Wildner IN CONST VOID *Buffer, 245*1370a723SSascha Wildner IN UINTN Length, 246*1370a723SSascha Wildner IN UINT8 Value 247*1370a723SSascha Wildner ); 248*1370a723SSascha Wildner 249*1370a723SSascha Wildner /** 250*1370a723SSascha Wildner Scans a target buffer for a 16-bit value, and returns a pointer to the matching 16-bit value 251*1370a723SSascha Wildner in the target buffer. 252*1370a723SSascha Wildner 253*1370a723SSascha Wildner This function searches target the buffer specified by Buffer and Length from the lowest 254*1370a723SSascha Wildner address to the highest address for a 16-bit value that matches Value. If a match is found, 255*1370a723SSascha Wildner then a pointer to the matching byte in the target buffer is returned. If no match is found, 256*1370a723SSascha Wildner then NULL is returned. If Length is 0, then NULL is returned. 257*1370a723SSascha Wildner 258*1370a723SSascha Wildner If Length > 0 and Buffer is NULL, then ASSERT(). 259*1370a723SSascha Wildner If Buffer is not aligned on a 16-bit boundary, then ASSERT(). 260*1370a723SSascha Wildner If Length is not aligned on a 16-bit boundary, then ASSERT(). 261*1370a723SSascha Wildner If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). 262*1370a723SSascha Wildner 263*1370a723SSascha Wildner @param Buffer The pointer to the target buffer to scan. 264*1370a723SSascha Wildner @param Length The number of bytes in Buffer to scan. 265*1370a723SSascha Wildner @param Value The value to search for in the target buffer. 266*1370a723SSascha Wildner 267*1370a723SSascha Wildner @return A pointer to the matching byte in the target buffer, otherwise NULL. 268*1370a723SSascha Wildner 269*1370a723SSascha Wildner **/ 270*1370a723SSascha Wildner VOID * 271*1370a723SSascha Wildner EFIAPI 272*1370a723SSascha Wildner ScanMem16 ( 273*1370a723SSascha Wildner IN CONST VOID *Buffer, 274*1370a723SSascha Wildner IN UINTN Length, 275*1370a723SSascha Wildner IN UINT16 Value 276*1370a723SSascha Wildner ); 277*1370a723SSascha Wildner 278*1370a723SSascha Wildner /** 279*1370a723SSascha Wildner Scans a target buffer for a 32-bit value, and returns a pointer to the matching 32-bit value 280*1370a723SSascha Wildner in the target buffer. 281*1370a723SSascha Wildner 282*1370a723SSascha Wildner This function searches target the buffer specified by Buffer and Length from the lowest 283*1370a723SSascha Wildner address to the highest address for a 32-bit value that matches Value. If a match is found, 284*1370a723SSascha Wildner then a pointer to the matching byte in the target buffer is returned. If no match is found, 285*1370a723SSascha Wildner then NULL is returned. If Length is 0, then NULL is returned. 286*1370a723SSascha Wildner 287*1370a723SSascha Wildner If Length > 0 and Buffer is NULL, then ASSERT(). 288*1370a723SSascha Wildner If Buffer is not aligned on a 32-bit boundary, then ASSERT(). 289*1370a723SSascha Wildner If Length is not aligned on a 32-bit boundary, then ASSERT(). 290*1370a723SSascha Wildner If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). 291*1370a723SSascha Wildner 292*1370a723SSascha Wildner @param Buffer The pointer to the target buffer to scan. 293*1370a723SSascha Wildner @param Length The number of bytes in Buffer to scan. 294*1370a723SSascha Wildner @param Value The value to search for in the target buffer. 295*1370a723SSascha Wildner 296*1370a723SSascha Wildner @return A pointer to the matching byte in the target buffer, otherwise NULL. 297*1370a723SSascha Wildner 298*1370a723SSascha Wildner **/ 299*1370a723SSascha Wildner VOID * 300*1370a723SSascha Wildner EFIAPI 301*1370a723SSascha Wildner ScanMem32 ( 302*1370a723SSascha Wildner IN CONST VOID *Buffer, 303*1370a723SSascha Wildner IN UINTN Length, 304*1370a723SSascha Wildner IN UINT32 Value 305*1370a723SSascha Wildner ); 306*1370a723SSascha Wildner 307*1370a723SSascha Wildner /** 308*1370a723SSascha Wildner Scans a target buffer for a 64-bit value, and returns a pointer to the matching 64-bit value 309*1370a723SSascha Wildner in the target buffer. 310*1370a723SSascha Wildner 311*1370a723SSascha Wildner This function searches target the buffer specified by Buffer and Length from the lowest 312*1370a723SSascha Wildner address to the highest address for a 64-bit value that matches Value. If a match is found, 313*1370a723SSascha Wildner then a pointer to the matching byte in the target buffer is returned. If no match is found, 314*1370a723SSascha Wildner then NULL is returned. If Length is 0, then NULL is returned. 315*1370a723SSascha Wildner 316*1370a723SSascha Wildner If Length > 0 and Buffer is NULL, then ASSERT(). 317*1370a723SSascha Wildner If Buffer is not aligned on a 64-bit boundary, then ASSERT(). 318*1370a723SSascha Wildner If Length is not aligned on a 64-bit boundary, then ASSERT(). 319*1370a723SSascha Wildner If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). 320*1370a723SSascha Wildner 321*1370a723SSascha Wildner @param Buffer The pointer to the target buffer to scan. 322*1370a723SSascha Wildner @param Length The number of bytes in Buffer to scan. 323*1370a723SSascha Wildner @param Value The value to search for in the target buffer. 324*1370a723SSascha Wildner 325*1370a723SSascha Wildner @return A pointer to the matching byte in the target buffer, otherwise NULL. 326*1370a723SSascha Wildner 327*1370a723SSascha Wildner **/ 328*1370a723SSascha Wildner VOID * 329*1370a723SSascha Wildner EFIAPI 330*1370a723SSascha Wildner ScanMem64 ( 331*1370a723SSascha Wildner IN CONST VOID *Buffer, 332*1370a723SSascha Wildner IN UINTN Length, 333*1370a723SSascha Wildner IN UINT64 Value 334*1370a723SSascha Wildner ); 335*1370a723SSascha Wildner 336*1370a723SSascha Wildner /** 337*1370a723SSascha Wildner Scans a target buffer for a UINTN sized value, and returns a pointer to the matching 338*1370a723SSascha Wildner UINTN sized value in the target buffer. 339*1370a723SSascha Wildner 340*1370a723SSascha Wildner This function searches target the buffer specified by Buffer and Length from the lowest 341*1370a723SSascha Wildner address to the highest address for a UINTN sized value that matches Value. If a match is found, 342*1370a723SSascha Wildner then a pointer to the matching byte in the target buffer is returned. If no match is found, 343*1370a723SSascha Wildner then NULL is returned. If Length is 0, then NULL is returned. 344*1370a723SSascha Wildner 345*1370a723SSascha Wildner If Length > 0 and Buffer is NULL, then ASSERT(). 346*1370a723SSascha Wildner If Buffer is not aligned on a UINTN boundary, then ASSERT(). 347*1370a723SSascha Wildner If Length is not aligned on a UINTN boundary, then ASSERT(). 348*1370a723SSascha Wildner If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). 349*1370a723SSascha Wildner 350*1370a723SSascha Wildner @param Buffer The pointer to the target buffer to scan. 351*1370a723SSascha Wildner @param Length The number of bytes in Buffer to scan. 352*1370a723SSascha Wildner @param Value The value to search for in the target buffer. 353*1370a723SSascha Wildner 354*1370a723SSascha Wildner @return A pointer to the matching byte in the target buffer, otherwise NULL. 355*1370a723SSascha Wildner 356*1370a723SSascha Wildner **/ 357*1370a723SSascha Wildner VOID * 358*1370a723SSascha Wildner EFIAPI 359*1370a723SSascha Wildner ScanMemN ( 360*1370a723SSascha Wildner IN CONST VOID *Buffer, 361*1370a723SSascha Wildner IN UINTN Length, 362*1370a723SSascha Wildner IN UINTN Value 363*1370a723SSascha Wildner ); 364*1370a723SSascha Wildner 365*1370a723SSascha Wildner /** 366*1370a723SSascha Wildner Copies a source GUID to a destination GUID. 367*1370a723SSascha Wildner 368*1370a723SSascha Wildner This function copies the contents of the 128-bit GUID specified by SourceGuid to 369*1370a723SSascha Wildner DestinationGuid, and returns DestinationGuid. 370*1370a723SSascha Wildner 371*1370a723SSascha Wildner If DestinationGuid is NULL, then ASSERT(). 372*1370a723SSascha Wildner If SourceGuid is NULL, then ASSERT(). 373*1370a723SSascha Wildner 374*1370a723SSascha Wildner @param DestinationGuid The pointer to the destination GUID. 375*1370a723SSascha Wildner @param SourceGuid The pointer to the source GUID. 376*1370a723SSascha Wildner 377*1370a723SSascha Wildner @return DestinationGuid. 378*1370a723SSascha Wildner 379*1370a723SSascha Wildner **/ 380*1370a723SSascha Wildner GUID * 381*1370a723SSascha Wildner EFIAPI 382*1370a723SSascha Wildner CopyGuid ( 383*1370a723SSascha Wildner OUT GUID *DestinationGuid, 384*1370a723SSascha Wildner IN CONST GUID *SourceGuid 385*1370a723SSascha Wildner ); 386*1370a723SSascha Wildner 387*1370a723SSascha Wildner /** 388*1370a723SSascha Wildner Compares two GUIDs. 389*1370a723SSascha Wildner 390*1370a723SSascha Wildner This function compares Guid1 to Guid2. If the GUIDs are identical then TRUE is returned. 391*1370a723SSascha Wildner If there are any bit differences in the two GUIDs, then FALSE is returned. 392*1370a723SSascha Wildner 393*1370a723SSascha Wildner If Guid1 is NULL, then ASSERT(). 394*1370a723SSascha Wildner If Guid2 is NULL, then ASSERT(). 395*1370a723SSascha Wildner 396*1370a723SSascha Wildner @param Guid1 A pointer to a 128 bit GUID. 397*1370a723SSascha Wildner @param Guid2 A pointer to a 128 bit GUID. 398*1370a723SSascha Wildner 399*1370a723SSascha Wildner @retval TRUE Guid1 and Guid2 are identical. 400*1370a723SSascha Wildner @retval FALSE Guid1 and Guid2 are not identical. 401*1370a723SSascha Wildner 402*1370a723SSascha Wildner **/ 403*1370a723SSascha Wildner BOOLEAN 404*1370a723SSascha Wildner EFIAPI 405*1370a723SSascha Wildner CompareGuid ( 406*1370a723SSascha Wildner IN CONST GUID *Guid1, 407*1370a723SSascha Wildner IN CONST GUID *Guid2 408*1370a723SSascha Wildner ); 409*1370a723SSascha Wildner 410*1370a723SSascha Wildner /** 411*1370a723SSascha Wildner Scans a target buffer for a GUID, and returns a pointer to the matching GUID 412*1370a723SSascha Wildner in the target buffer. 413*1370a723SSascha Wildner 414*1370a723SSascha Wildner This function searches target the buffer specified by Buffer and Length from 415*1370a723SSascha Wildner the lowest address to the highest address at 128-bit increments for the 128-bit 416*1370a723SSascha Wildner GUID value that matches Guid. If a match is found, then a pointer to the matching 417*1370a723SSascha Wildner GUID in the target buffer is returned. If no match is found, then NULL is returned. 418*1370a723SSascha Wildner If Length is 0, then NULL is returned. 419*1370a723SSascha Wildner 420*1370a723SSascha Wildner If Length > 0 and Buffer is NULL, then ASSERT(). 421*1370a723SSascha Wildner If Buffer is not aligned on a 32-bit boundary, then ASSERT(). 422*1370a723SSascha Wildner If Length is not aligned on a 128-bit boundary, then ASSERT(). 423*1370a723SSascha Wildner If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). 424*1370a723SSascha Wildner 425*1370a723SSascha Wildner @param Buffer The pointer to the target buffer to scan. 426*1370a723SSascha Wildner @param Length The number of bytes in Buffer to scan. 427*1370a723SSascha Wildner @param Guid The value to search for in the target buffer. 428*1370a723SSascha Wildner 429*1370a723SSascha Wildner @return A pointer to the matching Guid in the target buffer, otherwise NULL. 430*1370a723SSascha Wildner 431*1370a723SSascha Wildner **/ 432*1370a723SSascha Wildner VOID * 433*1370a723SSascha Wildner EFIAPI 434*1370a723SSascha Wildner ScanGuid ( 435*1370a723SSascha Wildner IN CONST VOID *Buffer, 436*1370a723SSascha Wildner IN UINTN Length, 437*1370a723SSascha Wildner IN CONST GUID *Guid 438*1370a723SSascha Wildner ); 439*1370a723SSascha Wildner 440*1370a723SSascha Wildner /** 441*1370a723SSascha Wildner Checks if the given GUID is a zero GUID. 442*1370a723SSascha Wildner 443*1370a723SSascha Wildner This function checks whether the given GUID is a zero GUID. If the GUID is 444*1370a723SSascha Wildner identical to a zero GUID then TRUE is returned. Otherwise, FALSE is returned. 445*1370a723SSascha Wildner 446*1370a723SSascha Wildner If Guid is NULL, then ASSERT(). 447*1370a723SSascha Wildner 448*1370a723SSascha Wildner @param Guid The pointer to a 128 bit GUID. 449*1370a723SSascha Wildner 450*1370a723SSascha Wildner @retval TRUE Guid is a zero GUID. 451*1370a723SSascha Wildner @retval FALSE Guid is not a zero GUID. 452*1370a723SSascha Wildner 453*1370a723SSascha Wildner **/ 454*1370a723SSascha Wildner BOOLEAN 455*1370a723SSascha Wildner EFIAPI 456*1370a723SSascha Wildner IsZeroGuid ( 457*1370a723SSascha Wildner IN CONST GUID *Guid 458*1370a723SSascha Wildner ); 459*1370a723SSascha Wildner 460*1370a723SSascha Wildner /** 461*1370a723SSascha Wildner Checks if the contents of a buffer are all zeros. 462*1370a723SSascha Wildner 463*1370a723SSascha Wildner This function checks whether the contents of a buffer are all zeros. If the 464*1370a723SSascha Wildner contents are all zeros, return TRUE. Otherwise, return FALSE. 465*1370a723SSascha Wildner 466*1370a723SSascha Wildner If Length > 0 and Buffer is NULL, then ASSERT(). 467*1370a723SSascha Wildner If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). 468*1370a723SSascha Wildner 469*1370a723SSascha Wildner @param Buffer The pointer to the buffer to be checked. 470*1370a723SSascha Wildner @param Length The size of the buffer (in bytes) to be checked. 471*1370a723SSascha Wildner 472*1370a723SSascha Wildner @retval TRUE Contents of the buffer are all zeros. 473*1370a723SSascha Wildner @retval FALSE Contents of the buffer are not all zeros. 474*1370a723SSascha Wildner 475*1370a723SSascha Wildner **/ 476*1370a723SSascha Wildner BOOLEAN 477*1370a723SSascha Wildner EFIAPI 478*1370a723SSascha Wildner IsZeroBuffer ( 479*1370a723SSascha Wildner IN CONST VOID *Buffer, 480*1370a723SSascha Wildner IN UINTN Length 481*1370a723SSascha Wildner ); 482*1370a723SSascha Wildner 483*1370a723SSascha Wildner #endif 484