]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
MdeModulePkg/CapsuleLib: Free the buffer returned by GetVariable2 API
[mirror_edk2.git] / MdeModulePkg / Library / UefiBootManagerLib / BmBootDescription.c
index 066ea80a47541a2e91e5b9d8e0dda78140244fb0..050647d8f186e09eb9ad861898e801d76705f06a 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
@@ -585,7 +632,7 @@ BmGetBootDescription (
   // Firstly get the default boot description\r
   //\r
   DefaultDescription = NULL;\r
-  for (Index = 0; Index < sizeof (mBmBootDescriptionHandlers) / sizeof (mBmBootDescriptionHandlers[0]); Index++) {\r
+  for (Index = 0; Index < ARRAY_SIZE (mBmBootDescriptionHandlers); Index++) {\r
     DefaultDescription = mBmBootDescriptionHandlers[Index] (Handle);\r
     if (DefaultDescription != NULL) {\r
       //\r