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
//\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