VirtualBox

Changeset 80901 in vbox for trunk


Ignore:
Timestamp:
Sep 18, 2019 8:59:08 PM (5 years ago)
Author:
vboxsync
Message:

EFI/FirmwareNew: Restore ability to load the Apple provided OS loader as it is stored in a non standard location

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

Legend:

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

    r80721 r80901  
    994994}
    995995
     996#ifdef VBOX
     997/**
     998 * Checks which filename to try loading by inspecting what is existing on the provided
     999 * simple filesystem protocol provider.
     1000 *
     1001 * This is required to support booting macOS as it stores the efi OS loader in a non standard location
     1002 * and we have to support both styles without rewriting half of the boot manager library.
     1003 */
     1004EFI_STATUS VBoxBmQueryMediaFileNameForSFs(EFI_HANDLE hSFs, CHAR16 **ppwszFileName)
     1005{
     1006  EFI_STATUS                          Status = EFI_SUCCESS;
     1007  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL     *pSFs  = NULL;
     1008  EFI_FILE_PROTOCOL                   *pRoot = NULL;
     1009  EFI_FILE_PROTOCOL                   *pFile = NULL;
     1010
     1011  *ppwszFileName = EFI_REMOVABLE_MEDIA_FILE_NAME;
     1012
     1013  Status = gBS->HandleProtocol(hSFs, &gEfiSimpleFileSystemProtocolGuid, &pSFs);
     1014  if (!EFI_ERROR(Status))
     1015  {
     1016    Status = pSFs->OpenVolume(pSFs, &pRoot);
     1017    if (!EFI_ERROR(Status))
     1018    {
     1019      Status = pRoot->Open(pRoot, &pFile, VBOX_EFI_APPLE_MEDIA_FILE_NAME, EFI_FILE_MODE_READ,
     1020                           EFI_FILE_READ_ONLY | EFI_FILE_HIDDEN | EFI_FILE_SYSTEM);
     1021      if (!EFI_ERROR(Status))
     1022      {
     1023        *ppwszFileName = VBOX_EFI_APPLE_MEDIA_FILE_NAME;
     1024        pFile->Close(pFile);
     1025      }
     1026
     1027      pRoot->Close(pRoot);
     1028    }
     1029  }
     1030
     1031  return EFI_SUCCESS;
     1032}
     1033#endif
     1034
    9961035/**
    9971036  Expand the media device path which points to a BlockIo or SimpleFileSystem instance
     
    10231062  UINTN                               Index;
    10241063  BOOLEAN                             GetNext;
     1064#ifdef VBOX
     1065  CHAR16                              *pwszFilename = NULL;
     1066#endif
    10251067
    10261068  GetNext = (BOOLEAN)(FullPath == NULL);
     1069
    10271070  //
    10281071  // Check whether the device is connected
     
    10331076    ASSERT (IsDevicePathEnd (TempDevicePath));
    10341077
     1078#ifndef VBOX
    10351079    NextFullPath = FileDevicePath (Handle, EFI_REMOVABLE_MEDIA_FILE_NAME);
     1080#else
     1081    Status = VBoxBmQueryMediaFileNameForSFs(Handle, &pwszFilename);
     1082    if (!EFI_ERROR(Status))
     1083      NextFullPath = FileDevicePath (Handle, pwszFilename);
     1084    else
     1085      return NULL;
     1086#endif
    10361087    //
    10371088    // For device path pointing to simple file system, it only expands to one full path.
     
    11011152    //
    11021153    if ((Size <= TempSize) && (CompareMem (TempDevicePath, DevicePath, Size) == 0)) {
     1154#ifndef VBOX
    11031155      NextFullPath = FileDevicePath (SimpleFileSystemHandles[Index], EFI_REMOVABLE_MEDIA_FILE_NAME);
     1156#else
     1157      Status = VBoxBmQueryMediaFileNameForSFs(SimpleFileSystemHandles[Index], &pwszFilename);
     1158      if (!EFI_ERROR(Status))
     1159        NextFullPath = FileDevicePath (SimpleFileSystemHandles[Index], pwszFilename);
     1160      else
     1161        return NULL;
     1162#endif
    11041163      if (GetNext) {
    11051164        break;
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h

    r80721 r80901  
    8282#endif
    8383
     84#ifdef VBOX
     85/* Support for booting Apple macOS. */
     86# define VBOX_EFI_APPLE_MEDIA_FILE_NAME L"\\System\\Library\\CoreServices\\boot.efi"
     87#endif
     88
    8489typedef enum {
    8590  BmAcpiFloppyBoot,
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