]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/PeiMemoryLib/MemLibGuid.c
MdePkg UefiDevicePathLib: Validate before touch input buffer.
[mirror_edk2.git] / MdePkg / Library / PeiMemoryLib / MemLibGuid.c
index 737341023a0e3fe7b35fe361ba819a0573d7e0c4..cbb385fddfba8b4b7de2df526202264e8ce101f1 100644 (file)
     PeiMemoryLib\r
     UefiMemoryLib\r
 \r
-  Copyright (c) 2006 - 2009, Intel Corporation<BR>\r
-  All rights reserved. This program and the accompanying materials\r
+  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  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
+  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
@@ -34,8 +34,8 @@
   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   The pointer to the destination GUID.\r
+  @param  SourceGuid        The pointer to the source GUID.\r
 \r
   @return DestinationGuid.\r
 \r
@@ -109,9 +109,9 @@ CompareGuid (
   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
+  @param  Buffer  The pointer to the target buffer to scan.\r
+  @param  Length  The number of bytes in Buffer to scan.\r
+  @param  Guid    The value to search for in the target buffer.\r
 \r
   @return A pointer to the matching Guid in the target buffer or NULL otherwise.\r
 \r
@@ -140,3 +140,32 @@ ScanGuid (
   }\r
   return NULL;\r
 }\r
+\r
+/**\r
+  Checks if the given GUID is a zero GUID.\r
+\r
+  This function checks whether the given GUID is a zero GUID. If the GUID is\r
+  identical to a zero GUID then TRUE is returned. Otherwise, FALSE is returned.\r
+\r
+  If Guid is NULL, then ASSERT().\r
+\r
+  @param  Guid        The pointer to a 128 bit GUID.\r
+\r
+  @retval TRUE        Guid is a zero GUID.\r
+  @retval FALSE       Guid is not a zero GUID.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+IsZeroGuid (\r
+  IN CONST GUID  *Guid\r
+  )\r
+{\r
+  UINT64  LowPartOfGuid;\r
+  UINT64  HighPartOfGuid;\r
+\r
+  LowPartOfGuid  = ReadUnaligned64 ((CONST UINT64*) Guid);\r
+  HighPartOfGuid = ReadUnaligned64 ((CONST UINT64*) Guid + 1);\r
+\r
+  return (BOOLEAN) (LowPartOfGuid == 0 && HighPartOfGuid == 0);\r
+}\r