]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c
Do not create boot option for logical block io device.
[mirror_edk2.git] / IntelFrameworkModulePkg / Library / GenericBdsLib / BdsBoot.c
index 508bd6e9acc93a4bd084070e51c16a4d00e6c990..f816d4c39eda8b055c6fb553d7b3a2b92b0d86b5 100644 (file)
@@ -2524,11 +2524,28 @@ BdsExpandPartitionPartialDevicePathToFull (
   // If exist, search the front path which point to partition node in the variable instants.\r
   // If fail to find or HD_BOOT_DEVICE_PATH_VARIABLE_NAME not exist, reconnect all and search in all system\r
   //\r
-  CachedDevicePath = BdsLibGetVariableAndSize (\r
-                      HD_BOOT_DEVICE_PATH_VARIABLE_NAME,\r
-                      &gHdBootDevicePathVariablGuid,\r
-                      &CachedDevicePathSize\r
-                      );\r
+  GetVariable2 (\r
+    HD_BOOT_DEVICE_PATH_VARIABLE_NAME,\r
+    &gHdBootDevicePathVariablGuid,\r
+    (VOID **) &CachedDevicePath,\r
+    &CachedDevicePathSize\r
+    );\r
+\r
+  //\r
+  // Delete the invalid HD_BOOT_DEVICE_PATH_VARIABLE_NAME variable.\r
+  //\r
+  if ((CachedDevicePath != NULL) && !IsDevicePathValid (CachedDevicePath, CachedDevicePathSize)) {\r
+    FreePool (CachedDevicePath);\r
+    CachedDevicePath = NULL;\r
+    Status = gRT->SetVariable (\r
+                    HD_BOOT_DEVICE_PATH_VARIABLE_NAME,\r
+                    &gHdBootDevicePathVariablGuid,\r
+                    0,\r
+                    0,\r
+                    NULL\r
+                    );\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
 \r
   if (CachedDevicePath != NULL) {\r
     TempNewDevicePath = CachedDevicePath;\r
@@ -2591,7 +2608,7 @@ BdsExpandPartitionPartialDevicePathToFull (
         Status = gRT->SetVariable (\r
                         HD_BOOT_DEVICE_PATH_VARIABLE_NAME,\r
                         &gHdBootDevicePathVariablGuid,\r
-                        EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
+                        EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
                         GetDevicePathSize (CachedDevicePath),\r
                         CachedDevicePath\r
                         );\r
@@ -2690,7 +2707,7 @@ BdsExpandPartitionPartialDevicePathToFull (
       Status = gRT->SetVariable (\r
                       HD_BOOT_DEVICE_PATH_VARIABLE_NAME,\r
                       &gHdBootDevicePathVariablGuid,\r
-                      EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
+                      EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
                       GetDevicePathSize (CachedDevicePath),\r
                       CachedDevicePath\r
                       );\r
@@ -3202,9 +3219,16 @@ BdsLibEnumerateAllBootOption (
                       (VOID **) &BlkIo\r
                       );\r
       //\r
-      // skip the fixed block io then the removable block io\r
+      // skip the logical partition\r
+      //\r
+      if (EFI_ERROR (Status) || BlkIo->Media->LogicalPartition) {\r
+        continue;\r
+      }\r
+\r
+      //\r
+      // firstly fixed block io then the removable block io\r
       //\r
-      if (EFI_ERROR (Status) || (BlkIo->Media->RemovableMedia == Removable[RemovableIndex])) {\r
+      if (BlkIo->Media->RemovableMedia == Removable[RemovableIndex]) {\r
         continue;\r
       }\r
       DevicePath  = DevicePathFromHandle (BlockIoHandles[Index]);\r
@@ -3266,6 +3290,7 @@ BdsLibEnumerateAllBootOption (
         break;\r
 \r
       case BDS_EFI_MESSAGE_MISC_BOOT:\r
+      default:\r
         if (MiscNumber != 0) {\r
           UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_MISC)), MiscNumber);\r
         } else {\r
@@ -3274,9 +3299,6 @@ BdsLibEnumerateAllBootOption (
         BdsLibBuildOptionFromHandle (BlockIoHandles[Index], BdsBootOptionList, Buffer);\r
         MiscNumber++;\r
         break;\r
-\r
-      default:\r
-        break;\r
       }\r
     }\r
   }\r