]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/Bds/BootMenu.c
ArmPlatformPkg/Bds: Added support to detect if the binary is a EFI image
[mirror_edk2.git] / ArmPlatformPkg / Bds / BootMenu.c
index 9ca703842f2996d22d8c6bca4d68c5ee8a83e569..e00d06e39442a84d252516c832b0f104276c8b12 100644 (file)
@@ -134,6 +134,7 @@ BootMenuAddBootOption (
   UINTN                     InitrdSize;\r
   UINT8*                    OptionalData;\r
   UINTN                     OptionalDataSize;\r
+  BOOLEAN                   RequestBootType;\r
 \r
   Attributes                = 0;\r
   SupportedBootDevice = NULL;\r
@@ -146,7 +147,8 @@ BootMenuAddBootOption (
   }\r
 \r
   // Create the specific device path node\r
-  Status = SupportedBootDevice->Support->CreateDevicePathNode (L"EFI Application or the kernel", &DevicePathNodes, &BootType, &Attributes);\r
+  RequestBootType = TRUE;\r
+  Status = SupportedBootDevice->Support->CreateDevicePathNode (L"EFI Application or the kernel", &DevicePathNodes, &RequestBootType);\r
   if (EFI_ERROR(Status)) {\r
     Status = EFI_ABORTED;\r
     goto EXIT;\r
@@ -158,6 +160,16 @@ BootMenuAddBootOption (
     goto EXIT;\r
   }\r
 \r
+  if (RequestBootType) {\r
+    Status = BootDeviceGetType (DevicePath, &BootType, &Attributes);\r
+    if (EFI_ERROR(Status)) {\r
+      Status = EFI_ABORTED;\r
+      goto EXIT;\r
+    }\r
+  } else {\r
+    BootType = BDS_LOADER_EFI_APPLICATION;\r
+  }\r
+\r
   if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {\r
     Print(L"Add an initrd: ");\r
     Status = GetHIInputBoolean (&InitrdSupport);\r
@@ -168,7 +180,7 @@ BootMenuAddBootOption (
 \r
     if (InitrdSupport) {\r
       // Create the specific device path node\r
-      Status = SupportedBootDevice->Support->CreateDevicePathNode (L"initrd", &InitrdPathNodes, NULL, NULL);\r
+      Status = SupportedBootDevice->Support->CreateDevicePathNode (L"initrd", &InitrdPathNodes, NULL);\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
@@ -390,6 +402,7 @@ BootMenuUpdateBootOption (
   BOOLEAN                       InitrdSupport;\r
   UINT8*                        OptionalData;\r
   UINTN                         OptionalDataSize;\r
+  BOOLEAN                       RequestBootType;\r
 \r
   Status = BootMenuSelectBootOption (BootOptionsList, UPDATE_BOOT_ENTRY, TRUE, &BootOptionEntry);\r
   if (EFI_ERROR(Status)) {\r
@@ -404,12 +417,21 @@ BootMenuUpdateBootOption (
     return EFI_UNSUPPORTED;\r
   }\r
 \r
-  Status = DeviceSupport->UpdateDevicePathNode (BootOption->FilePathList, L"EFI Application or the kernel", &DevicePath, NULL, NULL);\r
+  RequestBootType = TRUE;\r
+  Status = DeviceSupport->UpdateDevicePathNode (BootOption->FilePathList, L"EFI Application or the kernel", &DevicePath, &RequestBootType);\r
   if (EFI_ERROR(Status)) {\r
     Status = EFI_ABORTED;\r
     goto EXIT;\r
   }\r
 \r
+  if (RequestBootType) {\r
+    Status = BootDeviceGetType (DevicePath, &BootType, &BootOption->Attributes);\r
+    if (EFI_ERROR(Status)) {\r
+      Status = EFI_ABORTED;\r
+      goto EXIT;\r
+    }\r
+  }\r
+\r
   LoaderOptionalData = BootOption->OptionalData;\r
   BootType = (ARM_BDS_LOADER_TYPE)ReadUnaligned32 ((UINT32 *)(&LoaderOptionalData->Header.LoaderType));\r
 \r
@@ -433,7 +455,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, NULL);\r
+        Status = DeviceSupport->UpdateDevicePathNode ((EFI_DEVICE_PATH*)((UINTN)(LinuxArguments + 1) + CmdLineSize), L"initrd", &InitrdPath, NULL);\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
@@ -442,7 +464,7 @@ BootMenuUpdateBootOption (
       } else {\r
         // Case we create the initrd device path\r
 \r
-        Status = DeviceSupport->CreateDevicePathNode (L"initrd", &InitrdPathNodes, NULL, NULL);\r
+        Status = DeviceSupport->CreateDevicePathNode (L"initrd", &InitrdPathNodes, NULL);\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
@@ -535,7 +557,7 @@ UpdateFdtPath (
   }\r
 \r
   // Create the specific device path node\r
-  Status = SupportedBootDevice->Support->CreateDevicePathNode (L"FDT blob", &FdtDevicePathNodes, NULL, NULL);\r
+  Status = SupportedBootDevice->Support->CreateDevicePathNode (L"FDT blob", &FdtDevicePathNodes, NULL);\r
   if (EFI_ERROR(Status)) {\r
     Status = EFI_ABORTED;\r
     goto EXIT;\r