]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Refine BaseMemoryTestLib and add instance with full functionality.
authorxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 6 Mar 2009 03:34:25 +0000 (03:34 +0000)
committerxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 6 Mar 2009 03:34:25 +0000 (03:34 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7831 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Include/Library/BaseMemoryTestLib.h
MdeModulePkg/Library/BaseMemoryTestLib/BaseMemoryTestLib.c [new file with mode: 0644]
MdeModulePkg/Library/BaseMemoryTestLib/BaseMemoryTestLib.inf [new file with mode: 0644]
MdeModulePkg/Library/BaseMemoryTestLibNull/BaseMemoryTestLibNull.c
MdeModulePkg/Library/BaseMemoryTestLibNull/BaseMemoryTestLibNull.inf
MdeModulePkg/MdeModulePkg.dec
MdeModulePkg/MdeModulePkg.dsc

index ec384de83e9ceb262adb07afcca52cee9bd19f3f..0dad0b2d165aae5c169673ad9b247d5ef1577057 100644 (file)
@@ -28,12 +28,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   @param  ErrorAddress           Address of the memory where error is encountered.\r
 \r
   @retval RETURN_SUCCESS         The memory range passes test.\r
-  @retval RETURNEFI_DEVICE_ERROR The memory range does not pass test.\r
+  @retval RETURN_DEVICE_ERROR    The memory range does not pass test.\r
 \r
 **/\r
 RETURN_STATUS\r
 EFIAPI\r
-SparseMemoryTest (\r
+QuickMemoryTest (\r
   IN  VOID      *StartAddress,\r
   IN  UINT64    Length,\r
   OUT VOID      **ErrorAddress\r
@@ -51,38 +51,51 @@ SparseMemoryTest (
   @param  ErrorAddress           Address of the memory where error is encountered.\r
 \r
   @retval RETURN_SUCCESS         The memory range passes test.\r
-  @retval RETURNEFI_DEVICE_ERROR The memory range does not pass test.\r
+  @retval RETURN_DEVICE_ERROR    The memory range does not pass test.\r
 \r
 **/\r
 RETURN_STATUS\r
 EFIAPI\r
-ExtensiveMemoryTest (\r
+SparseMemoryTest (\r
   IN  VOID      *StartAddress,\r
   IN  UINT64    Length,\r
   OUT VOID      **ErrorAddress\r
   );\r
 \r
 /**\r
-  Test a system memory range with every memory unit checked.\r
+  Test a system memory range with extensively sampled memory units.\r
 \r
   This function tests a system memory range, whose memory units\r
-  are fully checked. It leads to complete reliability with the\r
-  cost of performance.\r
+  are sampled extensively. Compared with SparseMemoryTest, it achieves\r
+  more reliability and less performance.\r
 \r
   @param  StartAddress           Start address of the memory range to test.\r
   @param  Length                 Length of the memory range to test.\r
   @param  ErrorAddress           Address of the memory where error is encountered.\r
 \r
   @retval RETURN_SUCCESS         The memory range passes test.\r
-  @retval RETURNEFI_DEVICE_ERROR The memory range does not pass test.\r
+  @retval RETURN_DEVICE_ERROR    The memory range does not pass test.\r
 \r
 **/\r
 RETURN_STATUS\r
 EFIAPI\r
-FullMemoryTest (\r
+ExtensiveMemoryTest (\r
   IN  VOID      *StartAddress,\r
   IN  UINT64    Length,\r
   OUT VOID      **ErrorAddress\r
   );\r
 \r
+/**\r
+  Check if soft ECC initialzation is needed for system\r
+\r
+  @retval TRUE         Soft ECC initialzation is needed.\r
+  @retval FALSE        Soft ECC initialzation is not needed.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+IsSoftEccInitRequired (\r
+  VOID\r
+  );\r
+\r
 #endif\r
diff --git a/MdeModulePkg/Library/BaseMemoryTestLib/BaseMemoryTestLib.c b/MdeModulePkg/Library/BaseMemoryTestLib/BaseMemoryTestLib.c
new file mode 100644 (file)
index 0000000..0b89d59
--- /dev/null
@@ -0,0 +1,227 @@
+/** @file\r
+  Null instance of Memory Test Library.\r
+  \r
+Copyright (c) 2009, Intel Corporation.<BR>\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\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
+\r
+#include <Base.h>\r
+#include <Library/BaseMemoryTestLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/CacheMaintenanceLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/ReportStatusCodeLib.h>\r
+\r
+\r
+UINT32 TestPattern[] = {\r
+  0x5a5a5a5a,\r
+  0xa5a5a5a5,\r
+  0x5a5a5a5a,\r
+  0xa5a5a5a5,\r
+  0x5a5a5a5a,\r
+  0xa5a5a5a5,\r
+  0x5a5a5a5a,\r
+  0xa5a5a5a5,\r
+  0x5a5a5a5a,\r
+  0xa5a5a5a5,\r
+  0x5a5a5a5a,\r
+  0xa5a5a5a5,\r
+  0x5a5a5a5a,\r
+  0xa5a5a5a5,\r
+  0x5a5a5a5a,\r
+  0xa5a5a5a5\r
+};\r
+\r
+/**\r
+  Internal worker function for system memory range test.\r
+\r
+  This function is the internal worker function for system memory range test.\r
+  It writes test pattern to memory range and then reads back to check if memory\r
+  works well.\r
+\r
+  @param  StartAddress           Start address of the memory range to test.\r
+  @param  Length                 Length of the memory range to test.\r
+  @param  ErrorAddress           Address of the memory where error is encountered.\r
+\r
+  @retval RETURN_SUCCESS         The memory range passes test.\r
+  @retval RETURN_DEVICE_ERROR    The memory range does not pass test.\r
+\r
+**/\r
+RETURN_STATUS\r
+MemoryTestWorker (\r
+  IN  VOID              *StartAddress,\r
+  IN  UINT64            Length,\r
+  IN  UINTN             SpanSize,\r
+  OUT VOID              **ErrorAddress\r
+  )\r
+{\r
+  VOID   *TempAddress;\r
+\r
+  //\r
+  // Make sure we don't try and test anything above the max physical address range\r
+  //\r
+  ASSERT ((UINTN) StartAddress + Length < MAX_ADDRESS);\r
+\r
+  REPORT_STATUS_CODE (EFI_PROGRESS_CODE,  PcdGet32 (PcdStatusCodeValueMemoryTestStarted));\r
+\r
+  //\r
+  // Write the test pattern into memory range\r
+  //\r
+  TempAddress = StartAddress;\r
+  while ((UINTN) TempAddress < (UINTN) StartAddress + Length) {\r
+    CopyMem (TempAddress, TestPattern, sizeof (TestPattern));\r
+    TempAddress = (VOID *) ((UINTN) TempAddress + SpanSize);\r
+  }\r
+\r
+  //\r
+  // Write back and invalidate cache to make sure data is in memory\r
+  //\r
+  WriteBackInvalidateDataCacheRange (StartAddress, (UINTN) Length);\r
+\r
+  //\r
+  // Read pattern from memory and compare it\r
+  //\r
+  TempAddress = StartAddress;\r
+  while ((UINTN) TempAddress < (UINTN) StartAddress + Length) {\r
+    if (CompareMem (TempAddress, TestPattern, sizeof (TestPattern)) != 0) {\r
+      //\r
+      // Value read back does not equal to the value written, so error is detected.\r
+      //\r
+      *ErrorAddress = TempAddress;\r
+      REPORT_STATUS_CODE (EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED, PcdGet32 (PcdStatusCodeValueUncorrectableMemoryError));\r
+\r
+      return RETURN_DEVICE_ERROR;\r
+    }\r
+\r
+    TempAddress = (VOID *) ((UINTN) TempAddress + SpanSize);\r
+  }\r
+\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
+/**\r
+  Perform a quick system memory range test.\r
+\r
+  This function performs a quick system memory range test. It leads to quick performance\r
+  but least reliability.\r
+\r
+  @param  StartAddress           Start address of the memory range to test.\r
+  @param  Length                 Length of the memory range to test.\r
+  @param  ErrorAddress           Address of the memory where error is encountered.\r
+\r
+  @retval RETURN_SUCCESS         The memory range passes test.\r
+  @retval RETURN_DEVICE_ERROR    The memory range does not pass test.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+QuickMemoryTest (\r
+  IN  VOID      *StartAddress,\r
+  IN  UINT64    Length,\r
+  OUT VOID      **ErrorAddress\r
+  )\r
+{\r
+  RETURN_STATUS   Status;\r
+\r
+  Status = MemoryTestWorker (\r
+             StartAddress,\r
+             Length,\r
+             sizeof (TestPattern) * 0x20000,\r
+             ErrorAddress\r
+             );\r
+\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Test a system memory range with sparsely sampled memory units.\r
+\r
+  This function tests a system memory range, whose memory units\r
+  are sampled sparsely. It leads to relatively good performance\r
+  and partial reliability.\r
+\r
+  @param  StartAddress           Start address of the memory range to test.\r
+  @param  Length                 Length of the memory range to test.\r
+  @param  ErrorAddress           Address of the memory where error is encountered.\r
+\r
+  @retval RETURN_SUCCESS         The memory range passes test.\r
+  @retval RETURN_DEVICE_ERROR    The memory range does not pass test.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+SparseMemoryTest (\r
+  IN  VOID      *StartAddress,\r
+  IN  UINT64    Length,\r
+  OUT VOID      **ErrorAddress\r
+  )\r
+{\r
+  RETURN_STATUS   Status;\r
+\r
+  Status = MemoryTestWorker (\r
+             StartAddress,\r
+             Length,\r
+             sizeof (TestPattern) * 0x8000,\r
+             ErrorAddress\r
+             );\r
+\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Test a system memory range with extensively sampled memory units.\r
+\r
+  This function tests a system memory range, whose memory units\r
+  are sampled extensively. Compared with SparseMemoryTest, it achieves\r
+  more reliability and less performance.\r
+\r
+  @param  StartAddress           Start address of the memory range to test.\r
+  @param  Length                 Length of the memory range to test.\r
+  @param  ErrorAddress           Address of the memory where error is encountered.\r
+\r
+  @retval RETURN_SUCCESS         The memory range passes test.\r
+  @retval RETURN_DEVICE_ERROR    The memory range does not pass test.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+ExtensiveMemoryTest (\r
+  IN  VOID      *StartAddress,\r
+  IN  UINT64    Length,\r
+  OUT VOID      **ErrorAddress\r
+  )\r
+{\r
+  RETURN_STATUS   Status;\r
+\r
+  Status = MemoryTestWorker (\r
+             StartAddress,\r
+             Length,\r
+             sizeof (TestPattern),\r
+             ErrorAddress\r
+             );\r
+\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Check if soft ECC initialzation is needed for system\r
+\r
+  @retval TRUE         Soft ECC initialzation is needed.\r
+  @retval FALSE        Soft ECC initialzation is not needed.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+IsSoftEccInitRequired (\r
+  VOID\r
+  )\r
+{\r
+  return FALSE;\r
+}\r
diff --git a/MdeModulePkg/Library/BaseMemoryTestLib/BaseMemoryTestLib.inf b/MdeModulePkg/Library/BaseMemoryTestLib/BaseMemoryTestLib.inf
new file mode 100644 (file)
index 0000000..f1bd888
--- /dev/null
@@ -0,0 +1,46 @@
+/** @file\r
+  Instance of Memory Test Library.\r
+\r
+Copyright (c) 2009, Intel Corporation.<BR>\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\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
+**/\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = BaseMemoryTestLib\r
+  FILE_GUID                      = 216CAA56-AF75-4BBB-9D74-CC0960E92ECB\r
+  MODULE_TYPE                    = BASE\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = BaseMemoryTestLib\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources.common]\r
+  BaseMemoryTestLib.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+\r
+[LibraryClasses]\r
+  BaseMemoryTestLib\r
+  BaseMemoryLib\r
+  CacheMaintenanceLib\r
+  DebugLib\r
+  PcdLib\r
+  ReportStatusCodeLib\r
+\r
+[FixedPcd]\r
+  gEfiMdePkgTokenSpaceGuid.PcdStatusCodeValueMemoryTestStarted\r
+  gEfiMdePkgTokenSpaceGuid.PcdStatusCodeValueUncorrectableMemoryError\r
index 4163e61bb3994a1e37d025f11ed0bb42e0202c3c..e88a22536aeb25fae092e336feb44cf1b9a260c7 100644 (file)
@@ -15,23 +15,22 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/BaseMemoryTestLib.h>\r
 \r
 /**\r
-  Test a system memory range with sparsely sampled memory units.\r
+  Perform a quick system memory range test.\r
 \r
-  This function tests a system memory range, whose memory units\r
-  are sampled sparsely. It leads to quick performance but less\r
-  reliability.\r
+  This function performs a quick system memory range test. It leads to quick performance\r
+  but least reliability.\r
 \r
   @param  StartAddress           Start address of the memory range to test.\r
   @param  Length                 Length of the memory range to test.\r
   @param  ErrorAddress           Address of the memory where error is encountered.\r
 \r
   @retval RETURN_SUCCESS         The memory range passes test.\r
-  @retval RETURNEFI_DEVICE_ERROR The memory range does not pass test.\r
+  @retval RETURN_DEVICE_ERROR    The memory range does not pass test.\r
 \r
 **/\r
 RETURN_STATUS\r
 EFIAPI\r
-SparseMemoryTest (\r
+QuickMemoryTest (\r
   IN  VOID      *StartAddress,\r
   IN  UINT64    Length,\r
   OUT VOID      **ErrorAddress\r
@@ -41,23 +40,23 @@ SparseMemoryTest (
 }\r
 \r
 /**\r
-  Test a system memory range with extensively sampled memory units.\r
+  Test a system memory range with sparsely sampled memory units.\r
 \r
   This function tests a system memory range, whose memory units\r
-  are sampled extensively. Compared with SparseMemoryTest, it achieves\r
-  more reliability and less performance.\r
+  are sampled sparsely. It leads to relatively good performance\r
+  and partial reliability.\r
 \r
   @param  StartAddress           Start address of the memory range to test.\r
   @param  Length                 Length of the memory range to test.\r
   @param  ErrorAddress           Address of the memory where error is encountered.\r
 \r
   @retval RETURN_SUCCESS         The memory range passes test.\r
-  @retval RETURNEFI_DEVICE_ERROR The memory range does not pass test.\r
+  @retval RETURN_DEVICE_ERROR    The memory range does not pass test.\r
 \r
 **/\r
 RETURN_STATUS\r
 EFIAPI\r
-ExtensiveMemoryTest (\r
+SparseMemoryTest (\r
   IN  VOID      *StartAddress,\r
   IN  UINT64    Length,\r
   OUT VOID      **ErrorAddress\r
@@ -67,23 +66,23 @@ ExtensiveMemoryTest (
 }\r
 \r
 /**\r
-  Test a system memory range with every memory unit checked.\r
+  Test a system memory range with extensively sampled memory units.\r
 \r
   This function tests a system memory range, whose memory units\r
-  are fully checked. It leads to complete reliability with the\r
-  cost of performance.\r
+  are sampled extensively. Compared with SparseMemoryTest, it achieves\r
+  more reliability and less performance.\r
 \r
   @param  StartAddress           Start address of the memory range to test.\r
   @param  Length                 Length of the memory range to test.\r
   @param  ErrorAddress           Address of the memory where error is encountered.\r
 \r
   @retval RETURN_SUCCESS         The memory range passes test.\r
-  @retval RETURNEFI_DEVICE_ERROR The memory range does not pass test.\r
+  @retval RETURN_DEVICE_ERROR    The memory range does not pass test.\r
 \r
 **/\r
 RETURN_STATUS\r
 EFIAPI\r
-FullMemoryTest (\r
+ExtensiveMemoryTest (\r
   IN  VOID      *StartAddress,\r
   IN  UINT64    Length,\r
   OUT VOID      **ErrorAddress\r
@@ -91,3 +90,19 @@ FullMemoryTest (
 {\r
   return RETURN_SUCCESS;\r
 }\r
+\r
+/**\r
+  Check if soft ECC initialzation is needed for system\r
+\r
+  @retval TRUE         Soft ECC initialzation is needed.\r
+  @retval FALSE        Soft ECC initialzation is not needed.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+IsSoftEccInitRequired (\r
+  VOID\r
+  )\r
+{\r
+  return FALSE;\r
+}\r
index 3587516daf12cec411396cdeb54bcdd0c2262b43..79f1395f2643416525000a1d986a30bf5ec13783 100644 (file)
@@ -18,7 +18,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   FILE_GUID                      = D519E511-9C1C-47F5-AE01-FD216E779269\r
   MODULE_TYPE                    = BASE\r
   VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = MemoryTestLib\r
+  LIBRARY_CLASS                  = BaseMemoryTestLib\r
 \r
 #\r
 # The following information is for reference only and not required by the build tools.\r
@@ -34,4 +34,4 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   MdeModulePkg/MdeModulePkg.dec\r
 \r
 [LibraryClasses]\r
-  MemoryTestLib\r
+  BaseMemoryTestLib\r
index b15c94254ea3a13770247cfe8191eb18c99c6ad0..eed4e4a319327b74dbf2971e8115a219a448b9e3 100644 (file)
@@ -83,7 +83,7 @@
 \r
   ##  @libraryclass  Provides APIs for system memory test.\r
   ##\r
-  MemoryTestLib|Include/Library/BaseMemoryTestLib.h\r
+  BaseMemoryTestLib|Include/Library/BaseMemoryTestLib.h\r
 \r
 [Guids.common]\r
   ## MdeModule package token space guid\r
index 01473d07432a202f805c768794e6feb33d94e80c..e4e77fff13154b63a356a69f3bf7095184ec55ae 100644 (file)
@@ -79,7 +79,7 @@
   OemHookStatusCodeLib|IntelFrameworkModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf\r
   HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf\r
   ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf\r
-  MemoryTestLib|MdeModulePkg/Library/BaseMemoryTestLibNull/BaseMemoryTestLibNull.inf\r
+  BaseMemoryTestLib|MdeModulePkg/Library/BaseMemoryTestLibNull/BaseMemoryTestLibNull.inf\r
 \r
 [LibraryClasses.IA32]\r
   IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf\r
   MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf\r
   MdeModulePkg/Library/UefiIfrSupportLib/UefiIfrSupportLib.inf\r
   MdeModulePkg/Library/BaseMemoryTestLibNull/BaseMemoryTestLibNull.inf\r
+  MdeModulePkg/Library/BaseMemoryTestLib/BaseMemoryTestLib.inf\r
 \r
   MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf\r
   MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf\r