]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/BdsDxe/BdsEntry.c
MdeModulePkg/BdsDxe: Also call PlatformBootManagerWaitCallback on 0
[mirror_edk2.git] / MdeModulePkg / Universal / BdsDxe / BdsEntry.c
index 2a4ae9f488c36568048868b23b01762dbd5a0596..7968a58f3454dd6a19c9dac049ea4cbc7e7a08e8 100644 (file)
@@ -341,6 +341,7 @@ BdsWait (
       TimeoutRemain--;\r
     }\r
   }\r
+  PlatformBootManagerWaitCallback (0);\r
   DEBUG ((EFI_D_INFO, "[Bds]Exit the waiting!\n"));\r
 }\r
 \r
@@ -546,10 +547,14 @@ BdsFormalizeOSIndicationVariable (
   //\r
   Status = EfiBootManagerGetBootManagerMenu (&BootManagerMenu);\r
   if (Status != EFI_NOT_FOUND) {\r
-    OsIndicationSupport = EFI_OS_INDICATIONS_BOOT_TO_FW_UI | EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY;\r
+    OsIndicationSupport = EFI_OS_INDICATIONS_BOOT_TO_FW_UI;\r
     EfiBootManagerFreeLoadOption (&BootManagerMenu);\r
   } else {\r
-    OsIndicationSupport = EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY;\r
+    OsIndicationSupport = 0;\r
+  }\r
+\r
+  if (PcdGetBool (PcdPlatformRecoverySupport)) {\r
+    OsIndicationSupport |= EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY;\r
   }\r
 \r
   if (PcdGetBool(PcdCapsuleOnDiskSupport)) {\r
@@ -666,6 +671,7 @@ BdsEntry (
   BOOLEAN                         BootSuccess;\r
   EFI_DEVICE_PATH_PROTOCOL        *FilePath;\r
   EFI_STATUS                      BootManagerMenuStatus;\r
+  EFI_BOOT_MANAGER_LOAD_OPTION    PlatformDefaultBootOption;\r
 \r
   HotkeyTriggered = NULL;\r
   Status          = EFI_SUCCESS;\r
@@ -767,14 +773,13 @@ BdsEntry (
   //\r
   InitializeLanguage (TRUE);\r
 \r
-  //\r
-  // System firmware must include a PlatformRecovery#### variable specifying\r
-  // a short-form File Path Media Device Path containing the platform default\r
-  // file path for removable media\r
-  //\r
   FilePath = FileDevicePath (NULL, EFI_REMOVABLE_MEDIA_FILE_NAME);\r
+  if (FilePath == NULL) {\r
+    DEBUG ((DEBUG_ERROR, "Fail to allocate memory for defualt boot file path. Unable to boot.\n"));\r
+    CpuDeadLoop ();\r
+  }\r
   Status = EfiBootManagerInitializeLoadOption (\r
-             &LoadOption,\r
+             &PlatformDefaultBootOption,\r
              LoadOptionNumberUnassigned,\r
              LoadOptionTypePlatformRecovery,\r
              LOAD_OPTION_ACTIVE,\r
@@ -784,24 +789,31 @@ BdsEntry (
              0\r
              );\r
   ASSERT_EFI_ERROR (Status);\r
-  LoadOptions = EfiBootManagerGetLoadOptions (&LoadOptionCount, LoadOptionTypePlatformRecovery);\r
-  if (EfiBootManagerFindLoadOption (&LoadOption, LoadOptions, LoadOptionCount) == -1) {\r
-    for (Index = 0; Index < LoadOptionCount; Index++) {\r
-      //\r
-      // The PlatformRecovery#### options are sorted by OptionNumber.\r
-      // Find the the smallest unused number as the new OptionNumber.\r
-      //\r
-      if (LoadOptions[Index].OptionNumber != Index) {\r
-        break;\r
+\r
+  //\r
+  // System firmware must include a PlatformRecovery#### variable specifying\r
+  // a short-form File Path Media Device Path containing the platform default\r
+  // file path for removable media if the platform supports Platform Recovery.\r
+  //\r
+  if (PcdGetBool (PcdPlatformRecoverySupport)) {\r
+    LoadOptions = EfiBootManagerGetLoadOptions (&LoadOptionCount, LoadOptionTypePlatformRecovery);\r
+    if (EfiBootManagerFindLoadOption (&PlatformDefaultBootOption, LoadOptions, LoadOptionCount) == -1) {\r
+      for (Index = 0; Index < LoadOptionCount; Index++) {\r
+        //\r
+        // The PlatformRecovery#### options are sorted by OptionNumber.\r
+        // Find the the smallest unused number as the new OptionNumber.\r
+        //\r
+        if (LoadOptions[Index].OptionNumber != Index) {\r
+          break;\r
+        }\r
       }\r
+      PlatformDefaultBootOption.OptionNumber = Index;\r
+      Status = EfiBootManagerLoadOptionToVariable (&PlatformDefaultBootOption);\r
+      ASSERT_EFI_ERROR (Status);\r
     }\r
-    LoadOption.OptionNumber = Index;\r
-    Status = EfiBootManagerLoadOptionToVariable (&LoadOption);\r
-    ASSERT_EFI_ERROR (Status);\r
+    EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount);\r
   }\r
-  EfiBootManagerFreeLoadOption (&LoadOption);\r
   FreePool (FilePath);\r
-  EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount);\r
 \r
   //\r
   // Report Status Code to indicate connecting drivers will happen\r
@@ -1047,10 +1059,18 @@ BdsEntry (
   }\r
 \r
   if (!BootSuccess) {\r
-    LoadOptions = EfiBootManagerGetLoadOptions (&LoadOptionCount, LoadOptionTypePlatformRecovery);\r
-    ProcessLoadOptions (LoadOptions, LoadOptionCount);\r
-    EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount);\r
+    if (PlatformRecovery) {\r
+      LoadOptions = EfiBootManagerGetLoadOptions (&LoadOptionCount, LoadOptionTypePlatformRecovery);\r
+      ProcessLoadOptions (LoadOptions, LoadOptionCount);\r
+      EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount);\r
+    } else {\r
+      //\r
+      // When platform recovery is not enabled, still boot to platform default file path.\r
+      //\r
+      EfiBootManagerProcessLoadOption (&PlatformDefaultBootOption);\r
+    }\r
   }\r
+  EfiBootManagerFreeLoadOption (&PlatformDefaultBootOption);\r
 \r
   DEBUG ((EFI_D_ERROR, "[Bds] Unable to boot!\n"));\r
   PlatformBootManagerUnableToBoot ();\r