]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/BaseMemoryTestLib/BaseMemoryTestLib.c
update the usage help text on variable statistic information.
[mirror_edk2.git] / MdeModulePkg / Library / BaseMemoryTestLib / BaseMemoryTestLib.c
index 0b89d5960f5c41aafa4a60b289a6489f0d93d41e..878b7558b64871619371e057b53ec09edbbea67b 100644 (file)
@@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 **/\r
 \r
 #include <Base.h>\r
-#include <Library/BaseMemoryTestLib.h>\r
+#include <Library/MemoryTestLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/CacheMaintenanceLib.h>\r
 #include <Library/DebugLib.h>\r
@@ -39,6 +39,38 @@ UINT32 TestPattern[] = {
   0xa5a5a5a5\r
 };\r
 \r
+/**\r
+  Internal function to compare two memory buffers of a given length.\r
+\r
+  This is the internal function to compare two memory buffers. We cannot\r
+  use CompareMem() in BaseLib, for that function ASSERT when buffer address\r
+  is zero.\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
+\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
+CompareMemoryWorker (\r
+  IN      CONST VOID                *DestinationBuffer,\r
+  IN      CONST VOID                *SourceBuffer,\r
+  IN      UINTN                     Length\r
+  )\r
+{\r
+  while ((--Length != 0) &&\r
+         (*(INT8*)DestinationBuffer == *(INT8*)SourceBuffer)) {\r
+    DestinationBuffer = (INT8*)DestinationBuffer + 1;\r
+    SourceBuffer = (INT8*)SourceBuffer + 1;\r
+  }\r
+  return (INTN)*(UINT8*)DestinationBuffer - (INTN)*(UINT8*)SourceBuffer;\r
+}\r
+\r
 /**\r
   Internal worker function for system memory range test.\r
 \r
@@ -90,7 +122,7 @@ MemoryTestWorker (
   //\r
   TempAddress = StartAddress;\r
   while ((UINTN) TempAddress < (UINTN) StartAddress + Length) {\r
-    if (CompareMem (TempAddress, TestPattern, sizeof (TestPattern)) != 0) {\r
+    if (CompareMemoryWorker (TempAddress, TestPattern, sizeof (TestPattern)) != 0) {\r
       //\r
       // Value read back does not equal to the value written, so error is detected.\r
       //\r