]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/MemoryTest/BaseMemoryTestPei/BaseMemoryTest.c
Clean up to update the reference of the these macros:
[mirror_edk2.git] / MdeModulePkg / Universal / MemoryTest / BaseMemoryTestPei / BaseMemoryTest.c
index df6b95547ba3b6b84db1f6cf437bd4c983fe34d4..0f9ddb9b7250fb243fc03ad8f32679420cf232bb 100644 (file)
@@ -1,5 +1,5 @@
 /** @file\r
-  The PEI memory test support\r
+  Support of memory test in PEI Phase.\r
 \r
 Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
 All rights reserved. This program and the accompanying materials\r
@@ -12,74 +12,66 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 \r
-#include <BaseMemoryTest.h>\r
-#include <Library/PeiServicesLib.h>\r
+#include "BaseMemoryTest.h"\r
 \r
-static PEI_BASE_MEMORY_TEST_PPI mPeiBaseMemoryTestPpi = { BaseMemoryTest };\r
+PEI_BASE_MEMORY_TEST_PPI mPeiBaseMemoryTestPpi = {\r
+  BaseMemoryTest\r
+};\r
 \r
-static EFI_PEI_PPI_DESCRIPTOR   PpiListPeiBaseMemoryTest = {\r
+EFI_PEI_PPI_DESCRIPTOR   PpiListPeiBaseMemoryTest = {\r
   (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
   &gPeiBaseMemoryTestPpiGuid,\r
   &mPeiBaseMemoryTestPpi\r
 };\r
 \r
-EFI_STATUS\r
-EFIAPI\r
-PeiBaseMemoryTestInit (\r
-  IN EFI_FFS_FILE_HEADER       *FfsHeader,\r
-  IN EFI_PEI_SERVICES          **PeiServices\r
-  )\r
-/*++\r
-Description:\r
-\r
-  Entry point function of BaseMemoryTestInit Peim.\r
+/**\r
+  Entry point of BaseMemoryTestPei PEIM.\r
 \r
-Arguments:\r
+  This function is the entry point of BaseMemoryTestPei PEIM.\r
+  It installs the PEI_BASE_MEMORY_TEST_PPI.\r
 \r
-  PeiServices           - General purpose services available to every PEIM.\r
-  FfsHeader             - Ffs header pointer\r
+  @param  FileHandle  Handle of the file being invoked.\r
+  @param  PeiServices Describes the list of possible PEI Services.\r
 \r
-Returns:\r
+  @retval EFI_SUCCESS    PEI_BASE_MEMORY_TEST_PPI is successfully installed.\r
+  @retval Others         PEI_BASE_MEMORY_TEST_PPI is not successfully installed.\r
 \r
-  Status                - Result of InstallPpi\r
-\r
---*/  \r
+**/  \r
+EFI_STATUS\r
+EFIAPI\r
+PeiBaseMemoryTestInit (\r
+  IN       EFI_PEI_FILE_HANDLE  FileHandle,\r
+  IN CONST EFI_PEI_SERVICES     **PeiServices\r
+  )\r
 {\r
-\r
   return PeiServicesInstallPpi (&PpiListPeiBaseMemoryTest);\r
-  \r
\r
 }\r
 \r
+/**\r
+  Test base memory.\r
+\r
+  @param  PeiServices      An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
+  @param  This             Pointer to this PPI instance.\r
+  @param  BeginAddress     Beginning of the memory address to be checked.\r
+  @param  MemoryLength     Bytes of memory range to be checked.\r
+  @param  Operation        Type of memory check operation to be performed.\r
+  @param  ErrorAddress     Pointer to address of the error memory returned.\r
+\r
+  @retval EFI_SUCCESS      Memory test passed.\r
+  @retval EFI_DEVICE_ERROR Memory test failed.\r
+\r
+**/    \r
 EFI_STATUS\r
 EFIAPI\r
 BaseMemoryTest (\r
   IN  EFI_PEI_SERVICES                   **PeiServices,\r
-  IN PEI_BASE_MEMORY_TEST_PPI            *This,\r
+  IN  PEI_BASE_MEMORY_TEST_PPI           *This,\r
   IN  EFI_PHYSICAL_ADDRESS               BeginAddress,\r
   IN  UINT64                             MemoryLength,\r
   IN  PEI_MEMORY_TEST_OP                 Operation,\r
   OUT EFI_PHYSICAL_ADDRESS               *ErrorAddress\r
   )\r
-/*++\r
-Description:\r
-\r
-  Test base memory.\r
-\r
-Arguments:\r
-\r
-  PeiServices   - General purpose services available to every PEIM.\r
-  This          - Pei memory test PPI pointer.\r
-  BeginAddress  - Beginning of the memory address to be checked.\r
-  MemoryLength  - Bytes of memory range to be checked.\r
-  Operation     - Type of memory check operation to be performed.\r
-  ErrorAddress  - Return the address of the error memory address.\r
-  ErrorAddress  - Address which has error when checked.\r
-\r
-Returns:\r
-\r
-  Status        - Result of InstallPpi\r
-\r
---*/    \r
 {\r
   UINT32                TestPattern;\r
   EFI_PHYSICAL_ADDRESS  TempAddress;\r
@@ -93,19 +85,30 @@ Returns:
   //\r
   // Make sure we don't try and test anything above the max physical address range\r
   //\r
-  ASSERT (BeginAddress + MemoryLength < EFI_MAX_ADDRESS);\r
+  ASSERT (BeginAddress + MemoryLength < MAX_ADDRESS);\r
 \r
   switch (Operation) {\r
   case Extensive:\r
+    //\r
+    // Extensive means full and detailed check,\r
+    // so use small span size to cover the entire test range.\r
+    //\r
     SpanSize = 0x4;\r
     break;\r
 \r
   case Sparse:\r
   case Quick:\r
+    //\r
+    // Sparse and Quick indicates quick test,\r
+    // so use large span size for sample test.\r
+    //\r
     SpanSize = COVER_SPAN;\r
     break;\r
 \r
   case Ignore:\r
+    //\r
+    // Ignore means no test.\r
+    //\r
     goto Done;\r
     break;\r
   }\r
@@ -123,6 +126,9 @@ Returns:
   TempAddress = BeginAddress;\r
   while (TempAddress < BeginAddress + MemoryLength) {\r
     if ((*(UINT32 *) (UINTN) TempAddress) != TestPattern) {\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