diff options
author | xli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524> | 2009-03-10 05:49:58 +0000 |
---|---|---|
committer | xli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524> | 2009-03-10 05:49:58 +0000 |
commit | 07a2097acd1f62bd9613e739a4227653970ab247 (patch) | |
tree | 8313d819cd1dc7270afd3216eeba4a94ebd6044f /MdeModulePkg | |
parent | 28af9a489dc3038962915405fcd4db5bc2ba5d9b (diff) | |
download | edk2-07a2097acd1f62bd9613e739a4227653970ab247.zip edk2-07a2097acd1f62bd9613e739a4227653970ab247.tar.gz edk2-07a2097acd1f62bd9613e739a4227653970ab247.tar.bz2 |
Refine BaseMemoryTestLib to handle memory address at zero.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7844 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg')
-rw-r--r-- | MdeModulePkg/Library/BaseMemoryTestLib/BaseMemoryTestLib.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/MdeModulePkg/Library/BaseMemoryTestLib/BaseMemoryTestLib.c b/MdeModulePkg/Library/BaseMemoryTestLib/BaseMemoryTestLib.c index 0b89d59..c939450 100644 --- a/MdeModulePkg/Library/BaseMemoryTestLib/BaseMemoryTestLib.c +++ b/MdeModulePkg/Library/BaseMemoryTestLib/BaseMemoryTestLib.c @@ -40,6 +40,38 @@ UINT32 TestPattern[] = { };
/**
+ Internal function to compare two memory buffers of a given length.
+
+ This is the internal function to compare two memory buffers. We cannot
+ use CompareMem() in BaseLib, for that function ASSERT when buffer address
+ is zero.
+
+ @param DestinationBuffer First memory buffer
+ @param SourceBuffer Second memory buffer
+ @param Length Length of DestinationBuffer and SourceBuffer memory
+ regions to compare.
+
+ @return 0 All Length bytes of the two buffers are identical.
+ @retval Non-zero The first mismatched byte in SourceBuffer subtracted from the first
+ mismatched byte in DestinationBuffer.
+
+**/
+INTN
+CompareMemoryWorker (
+ IN CONST VOID *DestinationBuffer,
+ IN CONST VOID *SourceBuffer,
+ IN UINTN Length
+ )
+{
+ while ((--Length != 0) &&
+ (*(INT8*)DestinationBuffer == *(INT8*)SourceBuffer)) {
+ DestinationBuffer = (INT8*)DestinationBuffer + 1;
+ SourceBuffer = (INT8*)SourceBuffer + 1;
+ }
+ return (INTN)*(UINT8*)DestinationBuffer - (INTN)*(UINT8*)SourceBuffer;
+}
+
+/**
Internal worker function for system memory range test.
This function is the internal worker function for system memory range test.
@@ -90,7 +122,7 @@ MemoryTestWorker ( //
TempAddress = StartAddress;
while ((UINTN) TempAddress < (UINTN) StartAddress + Length) {
- if (CompareMem (TempAddress, TestPattern, sizeof (TestPattern)) != 0) {
+ if (CompareMemoryWorker (TempAddress, TestPattern, sizeof (TestPattern)) != 0) {
//
// Value read back does not equal to the value written, so error is detected.
//
|