]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/Bds/BootOptionSupport.c
ArmPlatformPkg/Bds: Corrected boot type detection
[mirror_edk2.git] / ArmPlatformPkg / Bds / BootOptionSupport.c
index 3eab0da83bfd5aea535238d0eb3173bca95089aa..d54361af0428fd27710fd29df44d2f84c9554776 100644 (file)
@@ -458,16 +458,47 @@ BdsLoadOptionFileSystemUpdateDevicePath (
   return EFI_SUCCESS;\r
 }\r
 \r
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Check if a boot option path is a file system boot option path or not.\r
+\r
+  The device specified by the beginning of the path has to support the Simple File\r
+  System protocol. Furthermore, the remaining part of the path has to be composed of\r
+  a single node of type MEDIA_DEVICE_PATH and sub-type MEDIA_FILEPATH_DP.\r
+\r
+  @param[in]  DevicePath  Complete device path of a boot option.\r
+\r
+  @retval  FALSE  The boot option path has not been identified as that of a\r
+                  file system boot option.\r
+  @retval  TRUE   The boot option path is a file system boot option.\r
+**/\r
 BOOLEAN\r
 BdsLoadOptionFileSystemIsSupported (\r
 BOOLEAN\r
 BdsLoadOptionFileSystemIsSupported (\r
-  IN  EFI_DEVICE_PATH           *DevicePath\r
+  IN  EFI_DEVICE_PATH  *DevicePath\r
   )\r
 {\r
   )\r
 {\r
-  EFI_DEVICE_PATH*  DevicePathNode;\r
+  EFI_STATUS                        Status;\r
+  EFI_HANDLE                        Handle;\r
+  EFI_DEVICE_PATH                  *RemainingDevicePath;\r
+  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL  *FileProtocol;\r
 \r
 \r
-  DevicePathNode = GetLastDevicePathNode (DevicePath);\r
+  Status = BdsConnectDevicePath (DevicePath, &Handle, &RemainingDevicePath);\r
+  if (EFI_ERROR (Status)) {\r
+    return FALSE;\r
+  }\r
+\r
+  Status = gBS->HandleProtocol (\r
+                   Handle,\r
+                   &gEfiSimpleFileSystemProtocolGuid,\r
+                   (VOID **)(&FileProtocol)\r
+                   );\r
+  if (EFI_ERROR (Status)) {\r
+    return FALSE;\r
+  }\r
 \r
 \r
-  return IS_DEVICE_PATH_NODE(DevicePathNode,MEDIA_DEVICE_PATH,MEDIA_FILEPATH_DP);\r
+  if (!IS_DEVICE_PATH_NODE (RemainingDevicePath, MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP))\r
+    return FALSE;\r
+\r
+  return TRUE;\r
 }\r
 \r
 STATIC\r
 }\r
 \r
 STATIC\r
@@ -643,16 +674,47 @@ BdsLoadOptionMemMapUpdateDevicePath (
   return Status;\r
 }\r
 \r
   return Status;\r
 }\r
 \r
+/**\r
+  Check if a boot option path is a memory map boot option path or not.\r
+\r
+  The device specified by the beginning of the path has to support the BlockIo\r
+  protocol. Furthermore, the remaining part of the path has to be composed of\r
+  a single node of type HARDWARE_DEVICE_PATH and sub-type HW_MEMMAP_DP.\r
+\r
+  @param[in]  DevicePath  Complete device path of a boot option.\r
+\r
+  @retval  FALSE  The boot option path has not been identified as that of a\r
+                  memory map boot option.\r
+  @retval  TRUE   The boot option path is a a memory map boot option.\r
+**/\r
 BOOLEAN\r
 BdsLoadOptionMemMapIsSupported (\r
 BOOLEAN\r
 BdsLoadOptionMemMapIsSupported (\r
-  IN  EFI_DEVICE_PATH           *DevicePath\r
+  IN  EFI_DEVICE_PATH  *DevicePath\r
   )\r
 {\r
   )\r
 {\r
-  EFI_DEVICE_PATH*  DevicePathNode;\r
+  EFI_STATUS              Status;\r
+  EFI_HANDLE              Handle;\r
+  EFI_DEVICE_PATH        *RemainingDevicePath;\r
+  EFI_BLOCK_IO_PROTOCOL  *BlockIoProtocol;\r
+\r
+  Status = BdsConnectDevicePath (DevicePath, &Handle, &RemainingDevicePath);\r
+  if (EFI_ERROR (Status)) {\r
+    return FALSE;\r
+  }\r
 \r
 \r
-  DevicePathNode = GetLastDevicePathNode (DevicePath);\r
+  Status = gBS->HandleProtocol (\r
+                  Handle,\r
+                  &gEfiBlockIoProtocolGuid,\r
+                  (VOID **)(&BlockIoProtocol)\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return FALSE;\r
+  }\r
 \r
 \r
-  return IS_DEVICE_PATH_NODE(DevicePathNode,HARDWARE_DEVICE_PATH,HW_MEMMAP_DP);\r
+  if (!IS_DEVICE_PATH_NODE (RemainingDevicePath, HARDWARE_DEVICE_PATH, HW_MEMMAP_DP))\r
+    return FALSE;\r
+\r
+  return TRUE;\r
 }\r
 \r
 EFI_STATUS\r
 }\r
 \r
 EFI_STATUS\r
@@ -748,7 +810,7 @@ BdsLoadOptionPxeUpdateDevicePath (
 \r
 BOOLEAN\r
 BdsLoadOptionPxeIsSupported (\r
 \r
 BOOLEAN\r
 BdsLoadOptionPxeIsSupported (\r
-  IN  EFI_DEVICE_PATH           *DevicePath\r
+  IN  EFI_DEVICE_PATH  *DevicePath\r
   )\r
 {\r
   EFI_STATUS  Status;\r
   )\r
 {\r
   EFI_STATUS  Status;\r