]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/Bds/BootMenu.c
ArmPlatformPkg/Bds: Corrected boot type detection
[mirror_edk2.git] / ArmPlatformPkg / Bds / BootMenu.c
index 62e7927defd6cc8eb291667f57b192520e619519..065e2ee9c1d48e149a1091673d78a613759d9831 100644 (file)
@@ -134,7 +134,6 @@ BootMenuAddBootOption (
   UINTN                     InitrdSize;\r
   UINT8*                    OptionalData;\r
   UINTN                     OptionalDataSize;\r
-  BOOLEAN                   RequestBootType;\r
 \r
   Attributes                = 0;\r
   SupportedBootDevice = NULL;\r
@@ -147,8 +146,7 @@ BootMenuAddBootOption (
   }\r
 \r
   // Create the specific device path node\r
-  RequestBootType = TRUE;\r
-  Status = SupportedBootDevice->Support->CreateDevicePathNode (L"EFI Application or the kernel", &DevicePathNodes, &RequestBootType);\r
+  Status = SupportedBootDevice->Support->CreateDevicePathNode (L"EFI Application or the kernel", &DevicePathNodes);\r
   if (EFI_ERROR(Status)) {\r
     Status = EFI_ABORTED;\r
     goto EXIT;\r
@@ -160,7 +158,7 @@ BootMenuAddBootOption (
     goto EXIT;\r
   }\r
 \r
-  if (RequestBootType) {\r
+  if (SupportedBootDevice->Support->RequestBootType) {\r
     Status = BootDeviceGetType (DevicePath, &BootType, &Attributes);\r
     if (EFI_ERROR(Status)) {\r
       Status = EFI_ABORTED;\r
@@ -180,7 +178,7 @@ BootMenuAddBootOption (
 \r
     if (InitrdSupport) {\r
       // Create the specific device path node\r
-      Status = SupportedBootDevice->Support->CreateDevicePathNode (L"initrd", &InitrdPathNodes, NULL);\r
+      Status = SupportedBootDevice->Support->CreateDevicePathNode (L"initrd", &InitrdPathNodes);\r
       if (EFI_ERROR(Status) && Status != EFI_NOT_FOUND) { // EFI_NOT_FOUND is returned on empty input string, but we can boot without an initrd\r
         Status = EFI_ABORTED;\r
         goto EXIT;\r
@@ -409,7 +407,6 @@ BootMenuUpdateBootOption (
   BOOLEAN                       InitrdSupport;\r
   UINT8*                        OptionalData;\r
   UINTN                         OptionalDataSize;\r
-  BOOLEAN                       RequestBootType;\r
   BOOLEAN                       IsPrintable;\r
   BOOLEAN                       IsUnicode;\r
 \r
@@ -426,14 +423,13 @@ BootMenuUpdateBootOption (
     return EFI_UNSUPPORTED;\r
   }\r
 \r
-  RequestBootType = TRUE;\r
-  Status = DeviceSupport->UpdateDevicePathNode (BootOption->FilePathList, L"EFI Application or the kernel", &DevicePath, &RequestBootType);\r
+  Status = DeviceSupport->UpdateDevicePathNode (BootOption->FilePathList, L"EFI Application or the kernel", &DevicePath);\r
   if (EFI_ERROR(Status)) {\r
     Status = EFI_ABORTED;\r
     goto EXIT;\r
   }\r
 \r
-  if (RequestBootType) {\r
+  if (DeviceSupport->RequestBootType) {\r
     Status = BootDeviceGetType (DevicePath, &BootType, &BootOption->Attributes);\r
     if (EFI_ERROR(Status)) {\r
       Status = EFI_ABORTED;\r
@@ -468,7 +464,7 @@ BootMenuUpdateBootOption (
     if (InitrdSupport) {\r
       if (InitrdSize > 0) {\r
         // Case we update the initrd device path\r
-        Status = DeviceSupport->UpdateDevicePathNode ((EFI_DEVICE_PATH*)((UINTN)(LinuxArguments + 1) + CmdLineSize), L"initrd", &InitrdPath, NULL);\r
+        Status = DeviceSupport->UpdateDevicePathNode ((EFI_DEVICE_PATH*)((UINTN)(LinuxArguments + 1) + CmdLineSize), L"initrd", &InitrdPath);\r
         if (EFI_ERROR(Status) && Status != EFI_NOT_FOUND) {// EFI_NOT_FOUND is returned on empty input string, but we can boot without an initrd\r
           Status = EFI_ABORTED;\r
           goto EXIT;\r
@@ -477,7 +473,7 @@ BootMenuUpdateBootOption (
       } else {\r
         // Case we create the initrd device path\r
 \r
-        Status = DeviceSupport->CreateDevicePathNode (L"initrd", &InitrdPathNodes, NULL);\r
+        Status = DeviceSupport->CreateDevicePathNode (L"initrd", &InitrdPathNodes);\r
         if (EFI_ERROR(Status) && Status != EFI_NOT_FOUND) { // EFI_NOT_FOUND is returned on empty input string, but we can boot without an initrd\r
           Status = EFI_ABORTED;\r
           goto EXIT;\r
@@ -611,7 +607,7 @@ UpdateFdtPath (
   }\r
 \r
   // Create the specific device path node\r
-  Status = SupportedBootDevice->Support->CreateDevicePathNode (L"FDT blob", &FdtDevicePathNodes, NULL);\r
+  Status = SupportedBootDevice->Support->CreateDevicePathNode (L"FDT blob", &FdtDevicePathNodes);\r
   if (EFI_ERROR(Status)) {\r
     Status = EFI_ABORTED;\r
     goto EXIT;\r
@@ -648,6 +644,54 @@ EXIT:
   return Status;\r
 }\r
 \r
+/**\r
+  Set boot timeout\r
+\r
+  Ask for the boot timeout in seconds and if the input succeeds assign the\r
+  input value to the UEFI global variable "Timeout". This function is called\r
+  when the user selects the "Set Boot Timeout" of the boot manager menu.\r
+\r
+  @param[in]  BootOptionsList  List of the boot devices, not used here\r
+\r
+  @retval  EFI_SUCCESS   Boot timeout in second retrieved from the standard\r
+                         input and assigned to the UEFI "Timeout" global\r
+                         variable\r
+  @retval  !EFI_SUCCESS  Either the input or the setting of the UEFI global\r
+                         variable "Timeout" has failed.\r
+**/\r
+EFI_STATUS\r
+STATIC\r
+BootMenuSetBootTimeout (\r
+  IN LIST_ENTRY *BootOptionsList\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+  UINTN       Input;\r
+  UINT16      Timeout;\r
+\r
+  Print (L"Timeout duration (in seconds): ");\r
+  Status = GetHIInputInteger (&Input);\r
+  if (EFI_ERROR (Status)) {\r
+    Print (L"\n");\r
+    goto ErrorExit;\r
+  }\r
+\r
+  Timeout = Input;\r
+  Status = gRT->SetVariable (\r
+                 (CHAR16*)L"Timeout",\r
+                 &gEfiGlobalVariableGuid,\r
+                 EFI_VARIABLE_NON_VOLATILE       |\r
+                 EFI_VARIABLE_BOOTSERVICE_ACCESS |\r
+                 EFI_VARIABLE_RUNTIME_ACCESS,\r
+                 sizeof (UINT16),\r
+                 &Timeout\r
+                 );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+ErrorExit:\r
+  return Status;\r
+}\r
+\r
 struct BOOT_MANAGER_ENTRY {\r
   CONST CHAR16* Description;\r
   EFI_STATUS (*Callback) (IN LIST_ENTRY *BootOptionsList);\r
@@ -656,6 +700,7 @@ struct BOOT_MANAGER_ENTRY {
     { L"Update Boot Device Entry", BootMenuUpdateBootOption },\r
     { L"Remove Boot Device Entry", BootMenuRemoveBootOption },\r
     { L"Update FDT path", UpdateFdtPath },\r
+    { L"Set Boot Timeout", BootMenuSetBootTimeout },\r
 };\r
 \r
 EFI_STATUS\r