]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c
Nt32Pkg: Keep boot behavior using new BDS almost same as that using old BDS
[mirror_edk2.git] / Nt32Pkg / Library / PlatformBootManagerLib / PlatformBootManager.c
index 7964b2b8082cb3f1eeb3c6c60105f315585d3765..3f634fcff98181051de718b22dce4d017543e2c8 100644 (file)
@@ -19,92 +19,47 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 EFI_GUID mUefiShellFileGuid = { 0x7C04A583, 0x9E3E, 0x4f1c, 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 };\r
 \r
 /**\r
-  Perform the memory test base on the memory test intensive level,\r
-  and update the memory resource.\r
+  Perform the platform diagnostic, such like test memory. OEM/IBV also\r
+  can customize this function to support specific platform diagnostic.\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
+  @param MemoryTestLevel  The memory test intensive level\r
+  @param QuietBoot        Indicate if need to enable the quiet boot\r
 \r
 **/\r
-EFI_STATUS\r
-PlatformBootManagerMemoryTest (\r
-  IN EXTENDMEM_COVERAGE_LEVEL Level\r
+VOID\r
+PlatformBootManagerDiagnostics (\r
+  IN EXTENDMEM_COVERAGE_LEVEL    MemoryTestLevel,\r
+  IN BOOLEAN                     QuietBoot\r
   )\r
 {\r
-  EFI_STATUS                        Status;\r
-  BOOLEAN                           RequireSoftECCInit;\r
-  EFI_GENERIC_MEMORY_TEST_PROTOCOL  *GenMemoryTest;\r
-  UINT64                            TestedMemorySize;\r
-  UINT64                            TotalMemorySize;\r
-  UINTN                             TestPercent;\r
-  UINT64                            PreviousValue;\r
-  BOOLEAN                           ErrorOut;\r
-  UINT32                            TempData;\r
-\r
-  TestedMemorySize  = 0;\r
-  TotalMemorySize   = 0;\r
-  PreviousValue     = 0;\r
-\r
-  RequireSoftECCInit = FALSE;\r
-\r
-  Status = gBS->LocateProtocol (\r
-                  &gEfiGenericMemTestProtocolGuid,\r
-                  NULL,\r
-                  (VOID **) &GenMemoryTest\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_SUCCESS;\r
-  }\r
+  EFI_STATUS                     Status;\r
+\r
+  //\r
+  // Here we can decide if we need to show\r
+  // the diagnostics screen\r
+  // Notes: this quiet boot code should be remove\r
+  // from the graphic lib\r
+  //\r
+  if (QuietBoot) {\r
+    PlatformBootManagerEnableQuietBoot (PcdGetPtr(PcdLogoFile));\r
 \r
-  Status = GenMemoryTest->MemoryTestInit (\r
-                            GenMemoryTest,\r
-                            Level,\r
-                            &RequireSoftECCInit\r
-                            );\r
-  if (Status == EFI_NO_MEDIA) {\r
     //\r
-    // The PEI codes also have the relevant memory test code to check the memory,\r
-    // it can select to test some range of the memory or all of them. If PEI code\r
-    // checks all the memory, this BDS memory test will has no not-test memory to\r
-    // do the test, and then the status of EFI_NO_MEDIA will be returned by\r
-    // "MemoryTestInit". So it does not need to test memory again, just return.\r
+    // Perform system diagnostic\r
     //\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  do {\r
-    Status = GenMemoryTest->PerformMemoryTest (\r
-                              GenMemoryTest,\r
-                              &TestedMemorySize,\r
-                              &TotalMemorySize,\r
-                              &ErrorOut,\r
-                              FALSE\r
-                              );\r
-    if (ErrorOut && (Status == EFI_DEVICE_ERROR)) {\r
-      Print (L"System encounters memory errors!");\r
-      CpuDeadLoop ();\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
-      Print (L"Perform memory test: %d/100", TestPercent);\r
-      PreviousValue = TestPercent;\r
+    Status = PlatformBootManagerMemoryTest (MemoryTestLevel);\r
+    if (EFI_ERROR (Status)) {\r
+      PlatformBootManagerDisableQuietBoot ();\r
     }\r
-  } while (Status != EFI_NOT_FOUND);\r
 \r
-  Status = GenMemoryTest->Finished (GenMemoryTest);\r
+    return;\r
+  }\r
 \r
-  Print (L"\r%dM bytes of system memory tested OK\n", (UINT32) DivU64x32 (TotalMemorySize, 1024 * 1024));\r
-  return EFI_SUCCESS;\r
+  //\r
+  // Perform system diagnostic\r
+  //\r
+  Status = PlatformBootManagerMemoryTest (MemoryTestLevel);\r
 }\r
 \r
-\r
 /**\r
   Return the index of the load option in the load option array.\r
 \r
@@ -284,15 +239,19 @@ PlatformBootManagerAfterConsole (
   VOID\r
   )\r
 {\r
-  PlatformBootManagerMemoryTest (QUICK);\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL  Black;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL  White;\r
+\r
+  Black.Blue = Black.Green = Black.Red = Black.Reserved = 0;\r
+  White.Blue = White.Green = White.Red = White.Reserved = 0xFF;\r
+\r
   EfiBootManagerConnectAll ();\r
   EfiBootManagerRefreshAllBootOption ();\r
-  Print (\r
-    L"\n"\r
-    L"F2    to enter Boot Manager Menu.\n"\r
-    L"Enter to boot directly.\n"\r
-    L"\n"\r
-    );\r
+\r
+  PlatformBootManagerDiagnostics (QUICK, TRUE);\r
+  \r
+  PrintXY (10, 10, &White, &Black, L"F2    to enter Boot Manager Menu.                                            ");\r
+  PrintXY (10, 30, &White, &Black, L"Enter to boot directly.");\r
 }\r
 \r
 /**\r
@@ -306,5 +265,21 @@ PlatformBootManagerWaitCallback (
   UINT16          TimeoutRemain\r
   )\r
 {\r
-  Print (L"\r%-2d seconds remained...", TimeoutRemain);\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL Black;\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL White;\r
+  UINT16                        Timeout;\r
+\r
+  Timeout = PcdGet16 (PcdPlatformBootTimeOut);\r
+\r
+  Black.Blue = Black.Green = Black.Red = Black.Reserved = 0;\r
+  White.Blue = White.Green = White.Red = White.Reserved = 0xFF;\r
+\r
+  PlatformBootManagerShowProgress (\r
+    White,\r
+    Black,\r
+    L"Start boot option",\r
+    White,\r
+    (Timeout - TimeoutRemain) * 100 / Timeout,\r
+    0\r
+    );\r
 }\r