]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Code scrub for NullMemoryTest driver.
authorxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 7 Nov 2008 09:34:50 +0000 (09:34 +0000)
committerxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 7 Nov 2008 09:34:50 +0000 (09:34 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6429 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTest.c
MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTest.h
MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf

index 61e2d21d09692fe7fdb06bba610e7d83e576eb13..e392d08a7b8550acc9f06f5a4960498296495255 100644 (file)
@@ -1,5 +1,5 @@
 /** @file\r
-  Intall memory test protocol and bypass the real memory test procedure.\r
+  Implementation of Generic Memory Test Protocol which does not perform real memory test.\r
 \r
 Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
 All rights reserved. This program and the accompanying materials\r
@@ -15,16 +15,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include "NullMemoryTest.h"\r
 \r
-//\r
-// Module global members\r
-//\r
 UINT64                            mTestedSystemMemory = 0;\r
 UINT64                            mTotalSystemMemory  = 0;\r
 EFI_HANDLE                        mGenericMemoryTestHandle;\r
 \r
-//\r
-// Driver entry here\r
-//\r
 EFI_GENERIC_MEMORY_TEST_PROTOCOL  mGenericMemoryTest = {\r
   InitializeMemoryTest,\r
   GenPerformMemoryTest,\r
@@ -32,51 +26,55 @@ EFI_GENERIC_MEMORY_TEST_PROTOCOL  mGenericMemoryTest = {
   GenCompatibleRangeTest\r
 };\r
 \r
+/**\r
+  Entry point of the NULL memory test driver.\r
+  \r
+  This function is the entry point of the NULL memory test driver.\r
+  It simply installs the Generic Memory Test Protocol.\r
+\r
+  @param  ImageHandle    The firmware allocated handle for the EFI image.\r
+  @param  SystemTable    A pointer to the EFI System Table.\r
+\r
+  @retval EFI_SUCCESS    Generic Memory Test Protocol is successfully installed.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 GenericMemoryTestEntryPoint (\r
   IN  EFI_HANDLE           ImageHandle,\r
   IN  EFI_SYSTEM_TABLE     *SystemTable\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The generic memory test driver's entry point, it can initialize private data\r
-  to default value\r
-\r
-Arguments:\r
-\r
-  ImageHandle of the loaded driver\r
-  Pointer to the System Table\r
-\r
-Returns:\r
-\r
-  Status\r
-\r
-  EFI_SUCCESS           - Protocol successfully installed\r
-  EFI_OUT_OF_RESOURCES  - Can not allocate protocol data structure in base\r
-                          memory\r
-\r
---*/\r
 {\r
   EFI_STATUS  Status;\r
 \r
-  //\r
-  // Install the protocol\r
-  //\r
   Status = gBS->InstallProtocolInterface (\r
                   &mGenericMemoryTestHandle,\r
                   &gEfiGenericMemTestProtocolGuid,\r
                   EFI_NATIVE_INTERFACE,\r
                   &mGenericMemoryTest\r
                   );\r
+  ASSERT_EFI_ERROR (Status);\r
 \r
-  return Status;\r
+  return EFI_SUCCESS;\r
 }\r
-//\r
-// EFI_GENERIC_MEMORY_TEST_PROTOCOL implementation\r
-//\r
+\r
+/**\r
+  Initialize the generic memory test.\r
+\r
+  This function implements EFI_GENERIC_MEMORY_TEST_PROTOCOL.MemoryTestInit.\r
+  It simply promotes untested reserved memory to system memory without real test.\r
+\r
+  @param  This                Protocol instance pointer. \r
+  @param  Level               The coverage level of the memory test. \r
+  @param  RequireSoftECCInit  Indicate if the memory need software ECC init. \r
+\r
+  @retval EFI_SUCCESS         The generic memory test initialized correctly. \r
+  @retval EFI_NO_MEDIA        There is not any non-tested memory found, in this \r
+                              function if not any non-tesed memory found means  \r
+                              that the memory test driver have not detect any \r
+                              non-tested extended memory of current system. \r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 InitializeMemoryTest (\r
@@ -84,15 +82,6 @@ InitializeMemoryTest (
   IN  EXTENDMEM_COVERAGE_LEVEL                 Level,\r
   OUT BOOLEAN                                  *RequireSoftECCInit\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
---*/\r
 {\r
   UINTN                           NumberOfDescriptors;\r
   EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap;\r
@@ -104,6 +93,9 @@ Returns:
         (MemorySpaceMap[Index].Capabilities & (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED)) ==\r
           (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED)\r
           ) {\r
+      //\r
+      // For those reserved memory that have not been tested, simply promote to system memory.\r
+      //\r
       gDS->RemoveMemorySpace (\r
             MemorySpaceMap[Index].BaseAddress,\r
             MemorySpaceMap[Index].Length\r
@@ -130,6 +122,29 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Perform the memory test.\r
+\r
+  This function implements EFI_GENERIC_MEMORY_TEST_PROTOCOL.PerformMemoryTest.\r
+  It simply returns EFI_NOT_FOUND.\r
+\r
+  @param  This                Protocol instance pointer. \r
+  @param  TestedMemorySize    Return the tested extended memory size. \r
+  @param  TotalMemorySize     Return the whole system physical memory size, this  \r
+                              value may be changed if in some case some error  \r
+                              DIMMs be disabled. \r
+  @param  ErrorOut            Any time the memory error occurs, this will be \r
+                              TRUE. \r
+  @param  IfTestAbort         Indicate if the user press "ESC" to skip the memory \r
+                              test. \r
+\r
+  @retval EFI_SUCCESS         One block of memory test ok, the block size is hide \r
+                              internally. \r
+  @retval EFI_NOT_FOUND       Indicate all the non-tested memory blocks have  \r
+                              already go through. \r
+  @retval EFI_DEVICE_ERROR    Mis-compare error, and no agent can handle it\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 GenPerformMemoryTest (\r
@@ -139,15 +154,6 @@ GenPerformMemoryTest (
   OUT BOOLEAN                                  *ErrorOut,\r
   IN BOOLEAN                                   TestAbort\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
---*/\r
 {\r
   *ErrorOut         = FALSE;\r
   *TestedMemorySize = mTestedSystemMemory;\r
@@ -157,24 +163,43 @@ Returns:
 \r
 }\r
 \r
+/**\r
+  The memory test finished.\r
+\r
+  This function implements EFI_GENERIC_MEMORY_TEST_PROTOCOL.Finished.\r
+  It simply returns EFI_SUCCESS.\r
+\r
+  @param  This                Protocol instance pointer. \r
+\r
+  @retval EFI_SUCCESS         Successful free all the generic memory test driver \r
+                              allocated resource and notify to platform memory \r
+                              test driver that memory test finished. \r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 GenMemoryTestFinished (\r
   IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
---*/\r
 {\r
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Provide capability to test compatible range which used by some special\r
+  driver required using memory range before BDS perform memory test.\r
+\r
+  This function implements EFI_GENERIC_MEMORY_TEST_PROTOCOL.CompatibleRangeTest.\r
+  It simply sets the memory range to system memory.\r
+\r
+  @param  This                Protocol instance pointer. \r
+  @param  StartAddress        The start address of the memory range. \r
+  @param  Length              The memory range's length. \r
+  \r
+  @retval EFI_SUCCESS           The compatible memory range pass the memory test. \r
+  @retval EFI_INVALID_PARAMETER The compatible memory range must be below 16M.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 GenCompatibleRangeTest (\r
@@ -182,19 +207,10 @@ GenCompatibleRangeTest (
   IN  EFI_PHYSICAL_ADDRESS                     StartAddress,\r
   IN  UINT64                                   Length\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
---*/\r
 {\r
-  EFI_GCD_MEMORY_SPACE_DESCRIPTOR descriptor;\r
+  EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor;\r
 \r
-  gDS->GetMemorySpaceDescriptor (StartAddress, &descriptor);\r
+  gDS->GetMemorySpaceDescriptor (StartAddress, &Descriptor);\r
 \r
   gDS->RemoveMemorySpace (StartAddress, Length);\r
 \r
@@ -202,7 +218,7 @@ Returns:
         EfiGcdMemoryTypeSystemMemory,\r
         StartAddress,\r
         Length,\r
-        descriptor.Capabilities &~(EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED | EFI_MEMORY_RUNTIME)\r
+        Descriptor.Capabilities &~(EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED | EFI_MEMORY_RUNTIME)\r
         );\r
 \r
   return EFI_SUCCESS;\r
index 3bbc8261539ae0ed83c983a8e95f5fff4b2976f7..1863af5bd96243cbb9bda10d9c4de01802d72297 100644 (file)
@@ -1,5 +1,5 @@
 /** @file\r
-  The generic memory test driver definition\r
+  Include file of the NULL memory test driver.\r
 \r
 Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
 All rights reserved. This program and the accompanying materials\r
@@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 \r
-#ifndef _NULL_MEMORY_TEST_H\r
-#define _NULL_MEMORY_TEST_H\r
+#ifndef _NULL_MEMORY_TEST_H_\r
+#define _NULL_MEMORY_TEST_H_\r
 \r
 \r
 #include <PiDxe.h>\r
@@ -28,51 +28,29 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/MemoryAllocationLib.h>\r
 \r
 //\r
-// attributes for reserved memory before it is promoted to system memory\r
+// Definition of memory status.\r
 //\r
 #define EFI_MEMORY_PRESENT      0x0100000000000000ULL\r
 #define EFI_MEMORY_INITIALIZED  0x0200000000000000ULL\r
 #define EFI_MEMORY_TESTED       0x0400000000000000ULL\r
 \r
+/**\r
+  Initialize the generic memory test.\r
 \r
-//\r
-// Some global define\r
-//\r
-#define GENERIC_CACHELINE_SIZE  0x40\r
+  This function implements EFI_GENERIC_MEMORY_TEST_PROTOCOL.MemoryTestInit.\r
+  It simply promotes untested reserved memory to system memory without real test.\r
 \r
-//\r
-// The SPARSE_SPAN_SIZE size can not small then the MonoTestSize\r
-//\r
-#define TEST_BLOCK_SIZE   0x2000000\r
-#define QUICK_SPAN_SIZE   (TEST_BLOCK_SIZE >> 2)\r
-#define SPARSE_SPAN_SIZE  (TEST_BLOCK_SIZE >> 4)\r
+  @param  This                Protocol instance pointer. \r
+  @param  Level               The coverage level of the memory test. \r
+  @param  RequireSoftECCInit  Indicate if the memory need software ECC init. \r
 \r
-//\r
-// This structure records every nontested memory range parsed through GCD\r
-// service.\r
-//\r
-#define EFI_NONTESTED_MEMORY_RANGE_SIGNATURE  EFI_SIGNATURE_32 ('N', 'T', 'M', 'E')\r
-typedef struct {\r
-  UINTN                 Signature;\r
-  LIST_ENTRY            Link;\r
-  EFI_PHYSICAL_ADDRESS  StartAddress;\r
-  UINT64                Length;\r
-  UINT64                Capabilities;\r
-  BOOLEAN               Above4G;\r
-  BOOLEAN               AlreadyMapped;\r
-} NONTESTED_MEMORY_RANGE;\r
-\r
-#define NONTESTED_MEMORY_RANGE_FROM_LINK(link) \\r
-        CR(link, NONTESTED_MEMORY_RANGE, Link, EFI_NONTESTED_MEMORY_RANGE_SIGNATURE)\r
+  @retval EFI_SUCCESS         The generic memory test initialized correctly. \r
+  @retval EFI_NO_MEDIA        There is not any non-tested memory found, in this \r
+                              function if not any non-tesed memory found means  \r
+                              that the memory test driver have not detect any \r
+                              non-tested extended memory of current system. \r
 \r
-//\r
-// This is the memory test driver's structure definition\r
-//\r
-#define EFI_GENERIC_MEMORY_TEST_PRIVATE_SIGNATURE EFI_SIGNATURE_32 ('G', 'E', 'M', 'T')\r
-\r
-//\r
-// Function Prototypes\r
-//\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 InitializeMemoryTest (\r
@@ -81,6 +59,29 @@ InitializeMemoryTest (
   OUT BOOLEAN                                  *RequireSoftECCInit\r
   );\r
 \r
+/**\r
+  Perform the memory test.\r
+\r
+  This function implements EFI_GENERIC_MEMORY_TEST_PROTOCOL.PerformMemoryTest.\r
+  It simply returns EFI_NOT_FOUND.\r
+\r
+  @param  This                Protocol instance pointer. \r
+  @param  TestedMemorySize    Return the tested extended memory size. \r
+  @param  TotalMemorySize     Return the whole system physical memory size, this  \r
+                              value may be changed if in some case some error  \r
+                              DIMMs be disabled. \r
+  @param  ErrorOut            Any time the memory error occurs, this will be \r
+                              TRUE. \r
+  @param  IfTestAbort         Indicate if the user press "ESC" to skip the memory \r
+                              test. \r
+\r
+  @retval EFI_SUCCESS         One block of memory test ok, the block size is hide \r
+                              internally. \r
+  @retval EFI_NOT_FOUND       Indicate all the non-tested memory blocks have  \r
+                              already go through. \r
+  @retval EFI_DEVICE_ERROR    Mis-compare error, and no agent can handle it\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 GenPerformMemoryTest (\r
@@ -91,12 +92,40 @@ GenPerformMemoryTest (
   IN BOOLEAN                                   TestAbort\r
   );\r
 \r
+/**\r
+  The memory test finished.\r
+\r
+  This function implements EFI_GENERIC_MEMORY_TEST_PROTOCOL.Finished.\r
+  It simply returns EFI_SUCCESS.\r
+\r
+  @param  This                Protocol instance pointer. \r
+\r
+  @retval EFI_SUCCESS         Successful free all the generic memory test driver \r
+                              allocated resource and notify to platform memory \r
+                              test driver that memory test finished. \r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 GenMemoryTestFinished (\r
   IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This\r
   );\r
 \r
+/**\r
+  Provide capability to test compatible range which used by some special\r
+  driver required using memory range before BDS perform memory test.\r
+\r
+  This function implements EFI_GENERIC_MEMORY_TEST_PROTOCOL.CompatibleRangeTest.\r
+  It simply set the memory range to system memory.\r
+\r
+  @param  This                Protocol instance pointer. \r
+  @param  StartAddress        The start address of the memory range. \r
+  @param  Length              The memory range's length. \r
+  \r
+  @retval EFI_SUCCESS           The compatible memory range pass the memory test. \r
+  @retval EFI_INVALID_PARAMETER The compatible memory range must be below 16M.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 GenCompatibleRangeTest (\r
index cdceb9c0e9814e718f80a9d5e28d7e0cf29b13d9..cf3c39cf927779cad9c3ad90f82bfc2876c9d35b 100644 (file)
@@ -1,9 +1,5 @@
 #/** @file\r
-#  \r
-#    Component description file for NullMemoryTest module.\r
-#  \r
-#   This driver installs EFI_GENERIC_MEMORY_TEST_PROTOCOL to \r
-#    provide simple generic memory test functions.\r
+#   This driver installs Generic Memory Test Protocol which does not perform real memory test.\r
 #  \r
 #  Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
 #  All rights reserved. This program and the accompanying materials\r
@@ -52,4 +48,4 @@
   gEfiGenericMemTestProtocolGuid                # PROTOCOL ALWAYS_PRODUCED\r
 \r
 [Depex]\r
-  TRUE
\ No newline at end of file
+  TRUE\r