VirtualBox

Ignore:
Timestamp:
Aug 14, 2024 1:16:30 PM (4 months ago)
Author:
vboxsync
Message:

Devices/EFI/FirmwareNew: Merge edk2-stable-202405 and make it build on aarch64, bugref:4643

Location:
trunk/src/VBox/Devices/EFI/FirmwareNew
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/FirmwareNew

  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c

    r101291 r105670  
    881881  EFI_DEVICE_PATH_PROTOCOL  *Instance;
    882882  UINTN                     Size;
     883  BOOLEAN                   MatchFound;
     884  BOOLEAN                   ConnectAllAttempted;
    883885
    884886  //
     
    975977  // to search all devices in the system for a matched partition
    976978  //
    977   EfiBootManagerConnectAll ();
    978   Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiBlockIoProtocolGuid, NULL, &BlockIoHandleCount, &BlockIoBuffer);
    979   if (EFI_ERROR (Status)) {
    980     BlockIoHandleCount = 0;
    981     BlockIoBuffer      = NULL;
    982   }
    983 
    984   //
    985   // Loop through all the device handles that support the BLOCK_IO Protocol
    986   //
    987   for (Index = 0; Index < BlockIoHandleCount; Index++) {
    988     BlockIoDevicePath = DevicePathFromHandle (BlockIoBuffer[Index]);
    989     if (BlockIoDevicePath == NULL) {
    990       continue;
    991     }
    992 
    993     if (BmMatchPartitionDevicePathNode (BlockIoDevicePath, (HARDDRIVE_DEVICE_PATH *)FilePath)) {
    994       //
    995       // Find the matched partition device path
    996       //
    997       TempDevicePath = AppendDevicePath (BlockIoDevicePath, NextDevicePathNode (FilePath));
    998       FullPath       = BmGetNextLoadOptionDevicePath (TempDevicePath, NULL);
    999       FreePool (TempDevicePath);
    1000 
    1001       if (FullPath != NULL) {
    1002         BmCachePartitionDevicePath (&CachedDevicePath, BlockIoDevicePath);
    1003 
     979  BlockIoBuffer       = NULL;
     980  MatchFound          = FALSE;
     981  ConnectAllAttempted = FALSE;
     982  do {
     983    if (BlockIoBuffer != NULL) {
     984      FreePool (BlockIoBuffer);
     985    }
     986
     987    Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiBlockIoProtocolGuid, NULL, &BlockIoHandleCount, &BlockIoBuffer);
     988    if (EFI_ERROR (Status)) {
     989      BlockIoHandleCount = 0;
     990      BlockIoBuffer      = NULL;
     991    }
     992
     993    //
     994    // Loop through all the device handles that support the BLOCK_IO Protocol
     995    //
     996    for (Index = 0; Index < BlockIoHandleCount; Index++) {
     997      BlockIoDevicePath = DevicePathFromHandle (BlockIoBuffer[Index]);
     998      if (BlockIoDevicePath == NULL) {
     999        continue;
     1000      }
     1001
     1002      if (BmMatchPartitionDevicePathNode (BlockIoDevicePath, (HARDDRIVE_DEVICE_PATH *)FilePath)) {
    10041003        //
    1005         // Save the matching Device Path so we don't need to do a connect all next time
    1006         // Failing to save only impacts performance next time expanding the short-form device path
     1004        // Find the matched partition device path
    10071005        //
    1008         Status = gRT->SetVariable (
    1009                         L"HDDP",
    1010                         &mBmHardDriveBootVariableGuid,
    1011                         EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,
    1012                         GetDevicePathSize (CachedDevicePath),
    1013                         CachedDevicePath
    1014                         );
    1015 
    1016         break;
     1006        TempDevicePath = AppendDevicePath (BlockIoDevicePath, NextDevicePathNode (FilePath));
     1007        FullPath       = BmGetNextLoadOptionDevicePath (TempDevicePath, NULL);
     1008        FreePool (TempDevicePath);
     1009
     1010        if (FullPath != NULL) {
     1011          BmCachePartitionDevicePath (&CachedDevicePath, BlockIoDevicePath);
     1012
     1013          //
     1014          // Save the matching Device Path so we don't need to do a connect all next time
     1015          // Failing to save only impacts performance next time expanding the short-form device path
     1016          //
     1017          Status = gRT->SetVariable (
     1018                          L"HDDP",
     1019                          &mBmHardDriveBootVariableGuid,
     1020                          EFI_VARIABLE_BOOTSERVICE_ACCESS |
     1021                          EFI_VARIABLE_NON_VOLATILE,
     1022                          GetDevicePathSize (CachedDevicePath),
     1023                          CachedDevicePath
     1024                          );
     1025          MatchFound = TRUE;
     1026          break;
     1027        }
    10171028      }
    10181029    }
    1019   }
     1030
     1031    //
     1032    // If we found a matching BLOCK_IO handle or we've already
     1033    // tried a ConnectAll, we are done searching.
     1034    //
     1035    if (MatchFound || ConnectAllAttempted) {
     1036      break;
     1037    }
     1038
     1039    EfiBootManagerConnectAll ();
     1040    ConnectAllAttempted = TRUE;
     1041  } while (1);
    10201042
    10211043  if (CachedDevicePath != NULL) {
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette