]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Universal/BdsDxe/MemoryTest.c
Correct a typo: Change the type of the 4th parameter of EFI_DRIVER_HEALTH_PROTOCOL...
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / BdsDxe / MemoryTest.c
index 854f8952c44bf340a2088e94c3561913e38b425f..410d4f1db66d75f3b3c54a42abc8c5362f6c3c40 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   Perform the platform memory test\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation. <BR>\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>\r
+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
@@ -193,18 +193,17 @@ PlatformBdsShowProgress (
 }\r
 \r
 /**\r
-\r
   Perform the memory test base on the memory test intensive level,\r
   and update the memory resource.\r
 \r
+  @param  Level         The memory test intensive level.\r
 \r
-  @param Level           The memory test intensive level.\r
-\r
-  @retval  EFI_STATUS       Success test all the system memory and update\r
-                            the memory resource\r
+  @retval EFI_STATUS    Success test all the system memory and update\r
+                        the memory resource\r
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 BdsMemoryTest (\r
   IN EXTENDMEM_COVERAGE_LEVEL Level\r
   )\r
@@ -222,7 +221,7 @@ BdsMemoryTest (
   BOOLEAN                           ErrorOut;\r
   BOOLEAN                           TestAbort;\r
   EFI_INPUT_KEY                     Key;\r
-  CHAR16                            StrPercent[16];\r
+  CHAR16                            StrPercent[80];\r
   CHAR16                            *StrTotalMemory;\r
   CHAR16                            *Pos;\r
   CHAR16                            *TmpStr;\r
@@ -255,10 +254,6 @@ BdsMemoryTest (
 \r
   RequireSoftECCInit = FALSE;\r
 \r
-  gST->ConOut->ClearScreen (gST->ConOut);\r
-  gST->ConOut->SetAttribute (gST->ConOut, EFI_YELLOW | EFI_BRIGHT);\r
-  gST->ConOut->EnableCursor (gST->ConOut, FALSE);\r
-\r
   Status = gBS->LocateProtocol (\r
                   &gEfiGenericMemTestProtocolGuid,\r
                   NULL,\r
@@ -285,15 +280,17 @@ BdsMemoryTest (
     FreePool (Pos);\r
     return EFI_SUCCESS;\r
   }\r
+  \r
+  if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) {\r
+    TmpStr = GetStringById (STRING_TOKEN (STR_ESC_TO_SKIP_MEM_TEST));\r
 \r
-  gST->ConOut->SetCursorPosition (gST->ConOut, 0, 2);\r
-  TmpStr = GetStringById (STRING_TOKEN (STR_ESC_TO_SKIP_MEM_TEST));\r
-\r
-  if (TmpStr != NULL) {\r
-    gST->ConOut->OutputString (gST->ConOut, TmpStr);\r
-    FreePool (TmpStr);\r
+    if (TmpStr != NULL) {\r
+      PrintXY (10, 10, NULL, NULL, TmpStr);\r
+      FreePool (TmpStr);\r
+    }\r
+  } else {\r
+    DEBUG ((EFI_D_INFO, "Enter memory test.\n"));\r
   }\r
-\r
   do {\r
     Status = GenMemoryTest->PerformMemoryTest (\r
                               GenMemoryTest,\r
@@ -306,47 +303,30 @@ BdsMemoryTest (
       TmpStr = GetStringById (STRING_TOKEN (STR_SYSTEM_MEM_ERROR));\r
       if (TmpStr != NULL) {\r
         PrintXY (10, 10, NULL, NULL, TmpStr);\r
-        gST->ConOut->SetCursorPosition (gST->ConOut, 0, 4);\r
-        gST->ConOut->OutputString (gST->ConOut, TmpStr);\r
         FreePool (TmpStr);\r
       }\r
 \r
       ASSERT (0);\r
     }\r
+    \r
+    if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) {\r
+      TempData = (UINT32) DivU64x32 (TotalMemorySize, 16);\r
+      TestPercent = (UINTN) DivU64x32 (\r
+                              DivU64x32 (MultU64x32 (TestedMemorySize, 100), 16),\r
+                              TempData\r
+                              );\r
+      if (TestPercent != PreviousValue) {\r
+        UnicodeValueToString (StrPercent, 0, TestPercent, 0);\r
+        TmpStr = GetStringById (STRING_TOKEN (STR_MEMORY_TEST_PERCENT));\r
+        if (TmpStr != NULL) {\r
+          //\r
+          // TmpStr size is 64, StrPercent is reserved to 16.\r
+          //\r
+          StrCat (StrPercent, TmpStr);\r
+          PrintXY (10, 10, NULL, NULL, StrPercent);\r
+          FreePool (TmpStr);\r
+        }\r
 \r
-    TempData = (UINT32) DivU64x32 (TotalMemorySize, 16);\r
-    TestPercent = (UINTN) DivU64x32 (\r
-                            DivU64x32 (MultU64x32 (TestedMemorySize, 100), 16),\r
-                            TempData\r
-                            );\r
-    if (TestPercent != PreviousValue) {\r
-      UnicodeValueToString (StrPercent, 0, TestPercent, 0);\r
-      gST->ConOut->SetCursorPosition (gST->ConOut, 0, 0);\r
-      TmpStr = GetStringById (STRING_TOKEN (STR_MEMORY_TEST_PERCENT));\r
-      if (TmpStr != NULL) {\r
-        BdsLibOutputStrings (gST->ConOut, StrPercent, TmpStr, NULL);\r
-        FreePool (TmpStr);\r
-      }\r
-\r
-      TmpStr = GetStringById (STRING_TOKEN (STR_PERFORM_MEM_TEST));\r
-      if (TmpStr != NULL) {\r
-        PlatformBdsShowProgress (\r
-          Foreground,\r
-          Background,\r
-          TmpStr,\r
-          Color,\r
-          TestPercent,\r
-          (UINTN) PreviousValue\r
-          );\r
-        FreePool (TmpStr);\r
-      }\r
-    }\r
-\r
-    PreviousValue = TestPercent;\r
-\r
-    KeyStatus     = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
-    if (!EFI_ERROR (KeyStatus) && (Key.ScanCode == SCAN_ESC)) {\r
-      if (!RequireSoftECCInit) {\r
         TmpStr = GetStringById (STRING_TOKEN (STR_PERFORM_MEM_TEST));\r
         if (TmpStr != NULL) {\r
           PlatformBdsShowProgress (\r
@@ -354,51 +334,79 @@ BdsMemoryTest (
             Background,\r
             TmpStr,\r
             Color,\r
-            100,\r
+            TestPercent,\r
             (UINTN) PreviousValue\r
             );\r
           FreePool (TmpStr);\r
         }\r
-\r
-        gST->ConOut->SetCursorPosition (gST->ConOut, 0, 0);\r
-        gST->ConOut->OutputString (gST->ConOut, L"100");\r
-        Status = GenMemoryTest->Finished (GenMemoryTest);\r
-        goto Done;\r
       }\r
 \r
-      TestAbort = TRUE;\r
+      PreviousValue = TestPercent;\r
+    } else {\r
+      DEBUG ((EFI_D_INFO, "Perform memory test (ESC to skip).\n"));\r
+    }\r
+\r
+    if (!PcdGetBool (PcdConInConnectOnDemand)) {\r
+      KeyStatus     = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
+      if (!EFI_ERROR (KeyStatus) && (Key.ScanCode == SCAN_ESC)) {\r
+        if (!RequireSoftECCInit) {\r
+          if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) {\r
+            TmpStr = GetStringById (STRING_TOKEN (STR_PERFORM_MEM_TEST));\r
+            if (TmpStr != NULL) {\r
+              PlatformBdsShowProgress (\r
+                Foreground,\r
+                Background,\r
+                TmpStr,\r
+                Color,\r
+                100,\r
+                (UINTN) PreviousValue\r
+                );\r
+              FreePool (TmpStr);\r
+            }\r
+\r
+            PrintXY (10, 10, NULL, NULL, L"100");\r
+          }\r
+          Status = GenMemoryTest->Finished (GenMemoryTest);\r
+          goto Done;\r
+        }\r
+\r
+        TestAbort = TRUE;\r
+      }\r
     }\r
   } while (Status != EFI_NOT_FOUND);\r
 \r
   Status = GenMemoryTest->Finished (GenMemoryTest);\r
 \r
 Done:\r
-  UnicodeValueToString (StrTotalMemory, COMMA_TYPE, TotalMemorySize, 0);\r
-  if (StrTotalMemory[0] == L',') {\r
-    StrTotalMemory++;\r
-  }\r
-\r
-  TmpStr = GetStringById (STRING_TOKEN (STR_MEM_TEST_COMPLETED));\r
-  if (TmpStr != NULL) {\r
-    StrCat (StrTotalMemory, TmpStr);\r
-    FreePool (TmpStr);\r
-  }\r
+  if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) {\r
+    UnicodeValueToString (StrTotalMemory, COMMA_TYPE, TotalMemorySize, 0);\r
+    if (StrTotalMemory[0] == L',') {\r
+      StrTotalMemory++;\r
+    }\r
 \r
-  gST->ConOut->ClearScreen (gST->ConOut);\r
-  gST->ConOut->SetAttribute (gST->ConOut, EFI_YELLOW | EFI_BRIGHT);\r
-  gST->ConOut->EnableCursor (gST->ConOut, FALSE);\r
-  gST->ConOut->OutputString (gST->ConOut, StrTotalMemory);\r
-  PlatformBdsShowProgress (\r
-    Foreground,\r
-    Background,\r
-    StrTotalMemory,\r
-    Color,\r
-    100,\r
-    (UINTN) PreviousValue\r
-    );\r
+    TmpStr = GetStringById (STRING_TOKEN (STR_MEM_TEST_COMPLETED));\r
+    if (TmpStr != NULL) {\r
+      StrCat (StrTotalMemory, TmpStr);\r
+      FreePool (TmpStr);\r
+    }\r
 \r
+    PrintXY (10, 10, NULL, NULL, StrTotalMemory);\r
+    PlatformBdsShowProgress (\r
+      Foreground,\r
+      Background,\r
+      StrTotalMemory,\r
+      Color,\r
+      100,\r
+      (UINTN) PreviousValue\r
+      );\r
+    \r
+  } else {\r
+    DEBUG ((EFI_D_INFO, "%d bytes of system memory tested OK\r\n", TotalMemorySize));\r
+  }\r
+  \r
   FreePool (Pos);\r
 \r
+\r
   //\r
   // Use a DynamicHii type pcd to save the boot status, which is used to\r
   // control configuration mode, such as FULL/MINIMAL/NO_CHANGES configuration.\r