]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
MdeModulePkg UefiBootManagerLib: Update LoadFile boot description
[mirror_edk2.git] / MdeModulePkg / Library / UefiBootManagerLib / BmBootDescription.c
index 066ea80a47541a2e91e5b9d8e0dda78140244fb0..f086764f24da05c1da27727dd315d68783b8b2b1 100644 (file)
@@ -454,6 +454,52 @@ BmGetNetworkDescription (
   return Description;\r
 }\r
 \r
+/**\r
+  Return the boot description for LoadFile\r
+\r
+  @param Handle                Controller handle.\r
+\r
+  @return  The description string.\r
+**/\r
+CHAR16 *\r
+BmGetLoadFileDescription (\r
+  IN EFI_HANDLE                  Handle\r
+  )\r
+{\r
+  EFI_STATUS                            Status;\r
+  EFI_DEVICE_PATH_PROTOCOL              *FilePath;\r
+  EFI_DEVICE_PATH_PROTOCOL              *DevicePathNode;\r
+  CHAR16                                *Description;\r
+  EFI_LOAD_FILE_PROTOCOL                *LoadFile;\r
+\r
+  Status = gBS->HandleProtocol (Handle, &gEfiLoadFileProtocolGuid, (VOID **)&LoadFile);\r
+  if (EFI_ERROR (Status)) {\r
+    return NULL;\r
+  }\r
+\r
+  //\r
+  // Get the file name\r
+  //\r
+  Description = NULL;\r
+  Status = gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID **)&FilePath);\r
+  if (!EFI_ERROR (Status)) {\r
+    DevicePathNode = FilePath;\r
+    while (!IsDevicePathEnd (DevicePathNode)) {\r
+      if (DevicePathNode->Type == MEDIA_DEVICE_PATH && DevicePathNode->SubType == MEDIA_FILEPATH_DP) {\r
+        Description = (CHAR16 *)(DevicePathNode + 1);\r
+        break;\r
+      }\r
+      DevicePathNode = NextDevicePathNode (DevicePathNode);\r
+    }\r
+  }\r
+\r
+  if (Description != NULL) {\r
+    return AllocateCopyPool (StrSize (Description), Description);\r
+  }\r
+\r
+  return NULL;\r
+}\r
+\r
 /**\r
   Return the boot description for the controller based on the type.\r
 \r
@@ -559,6 +605,7 @@ BM_GET_BOOT_DESCRIPTION mBmBootDescriptionHandlers[] = {
   BmGetUsbDescription,\r
   BmGetDescriptionFromDiskInfo,\r
   BmGetNetworkDescription,\r
+  BmGetLoadFileDescription,\r
   BmGetMiscDescription\r
 };\r
 \r