From 313831d9333d66f311b18c671ae5ae0e755435f1 Mon Sep 17 00:00:00 2001 From: Hao Wu Date: Wed, 3 Aug 2016 15:29:50 +0800 Subject: [PATCH] MdePkg BaseMemoryLib: Add implementation of API IsZeroGuid() Cc: Michael D Kinney Cc: Liming Gao Cc: Jiewen Yao Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu Reviewed-by: Liming Gao --- MdePkg/Include/Library/BaseMemoryLib.h | 22 ++++++++++++- MdePkg/Library/BaseMemoryLib/MemLibGuid.c | 31 ++++++++++++++++++- MdePkg/Library/BaseMemoryLibMmx/MemLibGuid.c | 31 ++++++++++++++++++- .../Library/BaseMemoryLibOptDxe/MemLibGuid.c | 31 ++++++++++++++++++- .../Library/BaseMemoryLibOptPei/MemLibGuid.c | 31 ++++++++++++++++++- .../Library/BaseMemoryLibRepStr/MemLibGuid.c | 31 ++++++++++++++++++- MdePkg/Library/BaseMemoryLibSse2/MemLibGuid.c | 31 ++++++++++++++++++- MdePkg/Library/PeiMemoryLib/MemLibGuid.c | 31 ++++++++++++++++++- MdePkg/Library/UefiMemoryLib/MemLibGuid.c | 31 ++++++++++++++++++- 9 files changed, 261 insertions(+), 9 deletions(-) diff --git a/MdePkg/Include/Library/BaseMemoryLib.h b/MdePkg/Include/Library/BaseMemoryLib.h index e3a46d0b49..ed7fa00d49 100644 --- a/MdePkg/Include/Library/BaseMemoryLib.h +++ b/MdePkg/Include/Library/BaseMemoryLib.h @@ -5,7 +5,7 @@ These functions should be used in place of coding your own loops to do equivalent common functions. This allows optimized library implementations to help increase performance. -Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License that accompanies this distribution. The full text of the license may be found at @@ -443,4 +443,24 @@ ScanGuid ( IN CONST GUID *Guid ); +/** + Checks if the given GUID is a zero GUID. + + This function checks whether the given GUID is a zero GUID. If the GUID is + identical to a zero GUID then TRUE is returned. Otherwise, FALSE is returned. + + If Guid is NULL, then ASSERT(). + + @param Guid The pointer to a 128 bit GUID. + + @retval TRUE Guid is a zero GUID. + @retval FALSE Guid is not a zero GUID. + +**/ +BOOLEAN +EFIAPI +IsZeroGuid ( + IN CONST GUID *Guid + ); + #endif diff --git a/MdePkg/Library/BaseMemoryLib/MemLibGuid.c b/MdePkg/Library/BaseMemoryLib/MemLibGuid.c index dc16bd5cdd..b2590f83ca 100644 --- a/MdePkg/Library/BaseMemoryLib/MemLibGuid.c +++ b/MdePkg/Library/BaseMemoryLib/MemLibGuid.c @@ -12,7 +12,7 @@ PeiMemoryLib UefiMemoryLib - Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -140,3 +140,32 @@ ScanGuid ( } return NULL; } + +/** + Checks if the given GUID is a zero GUID. + + This function checks whether the given GUID is a zero GUID. If the GUID is + identical to a zero GUID then TRUE is returned. Otherwise, FALSE is returned. + + If Guid is NULL, then ASSERT(). + + @param Guid The pointer to a 128 bit GUID. + + @retval TRUE Guid is a zero GUID. + @retval FALSE Guid is not a zero GUID. + +**/ +BOOLEAN +EFIAPI +IsZeroGuid ( + IN CONST GUID *Guid + ) +{ + UINT64 LowPartOfGuid; + UINT64 HighPartOfGuid; + + LowPartOfGuid = ReadUnaligned64 ((CONST UINT64*) Guid); + HighPartOfGuid = ReadUnaligned64 ((CONST UINT64*) Guid + 1); + + return (BOOLEAN) (LowPartOfGuid == 0 && HighPartOfGuid == 0); +} diff --git a/MdePkg/Library/BaseMemoryLibMmx/MemLibGuid.c b/MdePkg/Library/BaseMemoryLibMmx/MemLibGuid.c index c04af6e112..cbb385fddf 100644 --- a/MdePkg/Library/BaseMemoryLibMmx/MemLibGuid.c +++ b/MdePkg/Library/BaseMemoryLibMmx/MemLibGuid.c @@ -12,7 +12,7 @@ PeiMemoryLib UefiMemoryLib - Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -140,3 +140,32 @@ ScanGuid ( } return NULL; } + +/** + Checks if the given GUID is a zero GUID. + + This function checks whether the given GUID is a zero GUID. If the GUID is + identical to a zero GUID then TRUE is returned. Otherwise, FALSE is returned. + + If Guid is NULL, then ASSERT(). + + @param Guid The pointer to a 128 bit GUID. + + @retval TRUE Guid is a zero GUID. + @retval FALSE Guid is not a zero GUID. + +**/ +BOOLEAN +EFIAPI +IsZeroGuid ( + IN CONST GUID *Guid + ) +{ + UINT64 LowPartOfGuid; + UINT64 HighPartOfGuid; + + LowPartOfGuid = ReadUnaligned64 ((CONST UINT64*) Guid); + HighPartOfGuid = ReadUnaligned64 ((CONST UINT64*) Guid + 1); + + return (BOOLEAN) (LowPartOfGuid == 0 && HighPartOfGuid == 0); +} diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/MemLibGuid.c b/MdePkg/Library/BaseMemoryLibOptDxe/MemLibGuid.c index c04af6e112..cbb385fddf 100644 --- a/MdePkg/Library/BaseMemoryLibOptDxe/MemLibGuid.c +++ b/MdePkg/Library/BaseMemoryLibOptDxe/MemLibGuid.c @@ -12,7 +12,7 @@ PeiMemoryLib UefiMemoryLib - Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -140,3 +140,32 @@ ScanGuid ( } return NULL; } + +/** + Checks if the given GUID is a zero GUID. + + This function checks whether the given GUID is a zero GUID. If the GUID is + identical to a zero GUID then TRUE is returned. Otherwise, FALSE is returned. + + If Guid is NULL, then ASSERT(). + + @param Guid The pointer to a 128 bit GUID. + + @retval TRUE Guid is a zero GUID. + @retval FALSE Guid is not a zero GUID. + +**/ +BOOLEAN +EFIAPI +IsZeroGuid ( + IN CONST GUID *Guid + ) +{ + UINT64 LowPartOfGuid; + UINT64 HighPartOfGuid; + + LowPartOfGuid = ReadUnaligned64 ((CONST UINT64*) Guid); + HighPartOfGuid = ReadUnaligned64 ((CONST UINT64*) Guid + 1); + + return (BOOLEAN) (LowPartOfGuid == 0 && HighPartOfGuid == 0); +} diff --git a/MdePkg/Library/BaseMemoryLibOptPei/MemLibGuid.c b/MdePkg/Library/BaseMemoryLibOptPei/MemLibGuid.c index 6f6edd0d8f..cbb385fddf 100644 --- a/MdePkg/Library/BaseMemoryLibOptPei/MemLibGuid.c +++ b/MdePkg/Library/BaseMemoryLibOptPei/MemLibGuid.c @@ -12,7 +12,7 @@ PeiMemoryLib UefiMemoryLib - Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -140,3 +140,32 @@ ScanGuid ( } return NULL; } + +/** + Checks if the given GUID is a zero GUID. + + This function checks whether the given GUID is a zero GUID. If the GUID is + identical to a zero GUID then TRUE is returned. Otherwise, FALSE is returned. + + If Guid is NULL, then ASSERT(). + + @param Guid The pointer to a 128 bit GUID. + + @retval TRUE Guid is a zero GUID. + @retval FALSE Guid is not a zero GUID. + +**/ +BOOLEAN +EFIAPI +IsZeroGuid ( + IN CONST GUID *Guid + ) +{ + UINT64 LowPartOfGuid; + UINT64 HighPartOfGuid; + + LowPartOfGuid = ReadUnaligned64 ((CONST UINT64*) Guid); + HighPartOfGuid = ReadUnaligned64 ((CONST UINT64*) Guid + 1); + + return (BOOLEAN) (LowPartOfGuid == 0 && HighPartOfGuid == 0); +} diff --git a/MdePkg/Library/BaseMemoryLibRepStr/MemLibGuid.c b/MdePkg/Library/BaseMemoryLibRepStr/MemLibGuid.c index 6f6edd0d8f..cbb385fddf 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/MemLibGuid.c +++ b/MdePkg/Library/BaseMemoryLibRepStr/MemLibGuid.c @@ -12,7 +12,7 @@ PeiMemoryLib UefiMemoryLib - Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -140,3 +140,32 @@ ScanGuid ( } return NULL; } + +/** + Checks if the given GUID is a zero GUID. + + This function checks whether the given GUID is a zero GUID. If the GUID is + identical to a zero GUID then TRUE is returned. Otherwise, FALSE is returned. + + If Guid is NULL, then ASSERT(). + + @param Guid The pointer to a 128 bit GUID. + + @retval TRUE Guid is a zero GUID. + @retval FALSE Guid is not a zero GUID. + +**/ +BOOLEAN +EFIAPI +IsZeroGuid ( + IN CONST GUID *Guid + ) +{ + UINT64 LowPartOfGuid; + UINT64 HighPartOfGuid; + + LowPartOfGuid = ReadUnaligned64 ((CONST UINT64*) Guid); + HighPartOfGuid = ReadUnaligned64 ((CONST UINT64*) Guid + 1); + + return (BOOLEAN) (LowPartOfGuid == 0 && HighPartOfGuid == 0); +} diff --git a/MdePkg/Library/BaseMemoryLibSse2/MemLibGuid.c b/MdePkg/Library/BaseMemoryLibSse2/MemLibGuid.c index c04af6e112..cbb385fddf 100644 --- a/MdePkg/Library/BaseMemoryLibSse2/MemLibGuid.c +++ b/MdePkg/Library/BaseMemoryLibSse2/MemLibGuid.c @@ -12,7 +12,7 @@ PeiMemoryLib UefiMemoryLib - Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -140,3 +140,32 @@ ScanGuid ( } return NULL; } + +/** + Checks if the given GUID is a zero GUID. + + This function checks whether the given GUID is a zero GUID. If the GUID is + identical to a zero GUID then TRUE is returned. Otherwise, FALSE is returned. + + If Guid is NULL, then ASSERT(). + + @param Guid The pointer to a 128 bit GUID. + + @retval TRUE Guid is a zero GUID. + @retval FALSE Guid is not a zero GUID. + +**/ +BOOLEAN +EFIAPI +IsZeroGuid ( + IN CONST GUID *Guid + ) +{ + UINT64 LowPartOfGuid; + UINT64 HighPartOfGuid; + + LowPartOfGuid = ReadUnaligned64 ((CONST UINT64*) Guid); + HighPartOfGuid = ReadUnaligned64 ((CONST UINT64*) Guid + 1); + + return (BOOLEAN) (LowPartOfGuid == 0 && HighPartOfGuid == 0); +} diff --git a/MdePkg/Library/PeiMemoryLib/MemLibGuid.c b/MdePkg/Library/PeiMemoryLib/MemLibGuid.c index c04af6e112..cbb385fddf 100644 --- a/MdePkg/Library/PeiMemoryLib/MemLibGuid.c +++ b/MdePkg/Library/PeiMemoryLib/MemLibGuid.c @@ -12,7 +12,7 @@ PeiMemoryLib UefiMemoryLib - Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -140,3 +140,32 @@ ScanGuid ( } return NULL; } + +/** + Checks if the given GUID is a zero GUID. + + This function checks whether the given GUID is a zero GUID. If the GUID is + identical to a zero GUID then TRUE is returned. Otherwise, FALSE is returned. + + If Guid is NULL, then ASSERT(). + + @param Guid The pointer to a 128 bit GUID. + + @retval TRUE Guid is a zero GUID. + @retval FALSE Guid is not a zero GUID. + +**/ +BOOLEAN +EFIAPI +IsZeroGuid ( + IN CONST GUID *Guid + ) +{ + UINT64 LowPartOfGuid; + UINT64 HighPartOfGuid; + + LowPartOfGuid = ReadUnaligned64 ((CONST UINT64*) Guid); + HighPartOfGuid = ReadUnaligned64 ((CONST UINT64*) Guid + 1); + + return (BOOLEAN) (LowPartOfGuid == 0 && HighPartOfGuid == 0); +} diff --git a/MdePkg/Library/UefiMemoryLib/MemLibGuid.c b/MdePkg/Library/UefiMemoryLib/MemLibGuid.c index 6f6edd0d8f..cbb385fddf 100644 --- a/MdePkg/Library/UefiMemoryLib/MemLibGuid.c +++ b/MdePkg/Library/UefiMemoryLib/MemLibGuid.c @@ -12,7 +12,7 @@ PeiMemoryLib UefiMemoryLib - Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -140,3 +140,32 @@ ScanGuid ( } return NULL; } + +/** + Checks if the given GUID is a zero GUID. + + This function checks whether the given GUID is a zero GUID. If the GUID is + identical to a zero GUID then TRUE is returned. Otherwise, FALSE is returned. + + If Guid is NULL, then ASSERT(). + + @param Guid The pointer to a 128 bit GUID. + + @retval TRUE Guid is a zero GUID. + @retval FALSE Guid is not a zero GUID. + +**/ +BOOLEAN +EFIAPI +IsZeroGuid ( + IN CONST GUID *Guid + ) +{ + UINT64 LowPartOfGuid; + UINT64 HighPartOfGuid; + + LowPartOfGuid = ReadUnaligned64 ((CONST UINT64*) Guid); + HighPartOfGuid = ReadUnaligned64 ((CONST UINT64*) Guid + 1); + + return (BOOLEAN) (LowPartOfGuid == 0 && HighPartOfGuid == 0); +} -- 2.39.2