]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BaseMemoryLibSse2/MemLibGuid.c
Fix a bug to print correct message to ConOut and StdErr as they accept unicode string...
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibSse2 / MemLibGuid.c
index 351e370c2cc8d63e028ad4a9fcffe7373bff7b76..c13cd462e4ef92c42a6e52d0bade16bae2cb1d07 100644 (file)
@@ -10,8 +10,6 @@
   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
   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:  MemLibGuid.c\r
-\r
   The following BaseMemoryLib instances share the same version of this file:\r
 \r
     BaseMemoryLib\r
   The following BaseMemoryLib instances share the same version of this file:\r
 \r
     BaseMemoryLib\r
     BaseMemoryLibSse2\r
     BaseMemoryLibRepStr\r
     PeiMemoryLib\r
     BaseMemoryLibSse2\r
     BaseMemoryLibRepStr\r
     PeiMemoryLib\r
-    UefiMemoryLib\r
+    DxeMemoryLib\r
 \r
 **/\r
 \r
 \r
 **/\r
 \r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "MemLibInternals.h"\r
+\r
 /**\r
   Copies a source GUID to a destination GUID.\r
 \r
 /**\r
   Copies a source GUID to a destination GUID.\r
 \r
@@ -77,11 +80,21 @@ CompareGuid (
   IN CONST GUID  *Guid2\r
   )\r
 {\r
   IN CONST GUID  *Guid2\r
   )\r
 {\r
-  return (BOOLEAN)(\r
-           ReadUnaligned64 ((CONST UINT64*)Guid1)\r
-             == ReadUnaligned64 ((CONST UINT64*)Guid2) &&\r
-           ReadUnaligned64 ((CONST UINT64*)Guid1 + 1)\r
-             == ReadUnaligned64 ((CONST UINT64*)Guid2 + 1)\r
+  UINT64 Guid1ValueLo;\r
+  UINT64 Guid1ValueHi;\r
+  UINT64 Guid2ValueLo;\r
+  UINT64 Guid2ValueHi;\r
+\r
+  Guid1ValueLo = ReadUnaligned64 ((CONST UINT64*)Guid1);\r
+  Guid2ValueLo = ReadUnaligned64 ((CONST UINT64*)Guid2);\r
+\r
+  Guid1ValueHi = ReadUnaligned64 ((CONST UINT64*)Guid1 + 1);\r
+  Guid2ValueHi = ReadUnaligned64 ((CONST UINT64*)Guid2 + 1);\r
+\r
+\r
+  return (BOOLEAN)\r
+           ((Guid1ValueLo == Guid2ValueLo) &&\r
+            (Guid1ValueHi == Guid2ValueHi)\r
            );\r
 }\r
 \r
            );\r
 }\r
 \r
@@ -95,8 +108,9 @@ CompareGuid (
   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
   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 64-bit boundary, then ASSERT().\r
-  If Length is greater than (MAX_ADDRESS \96 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 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
 \r
   @param  Buffer  Pointer to the target buffer to scan.\r
   @param  Length  Number of bytes in Buffer to scan.\r
@@ -115,16 +129,12 @@ ScanGuid (
 {\r
   CONST GUID                        *GuidPtr;\r
 \r
 {\r
   CONST GUID                        *GuidPtr;\r
 \r
-  ASSERT (Buffer != NULL);\r
-  //\r
-  // Make sure Buffer is aligned on a 64-bit boundary.\r
-  //\r
-  ASSERT (((UINTN) Buffer & 7) == 0);\r
-\r
+  ASSERT (((UINTN)Buffer & (sizeof (Guid->Data1) - 1)) == 0);\r
   ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));\r
   ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));\r
+  ASSERT ((Length & (sizeof (*GuidPtr) - 1)) == 0);\r
 \r
   GuidPtr = (GUID*)Buffer;\r
 \r
   GuidPtr = (GUID*)Buffer;\r
-  Buffer = GuidPtr + Length / sizeof (*GuidPtr);\r
+  Buffer  = GuidPtr + Length / sizeof (*GuidPtr);\r
   while (GuidPtr < (CONST GUID*)Buffer) {\r
     if (CompareGuid (GuidPtr, Guid)) {\r
       return (VOID*)GuidPtr;\r
   while (GuidPtr < (CONST GUID*)Buffer) {\r
     if (CompareGuid (GuidPtr, Guid)) {\r
       return (VOID*)GuidPtr;\r