VirtualBox

Changeset 24603 in vbox


Ignore:
Timestamp:
Nov 12, 2009 6:39:20 AM (15 years ago)
Author:
vboxsync
Message:

Main: remaining firmware selection bits

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/ConsoleImpl2.cpp

    r24583 r24603  
    4545# include <iprt/env.h>
    4646#endif
     47#include <iprt/file.h>
    4748
    4849#include <VBox/vmapi.h>
     
    6364#include <VBox/intnet.h>
    6465
     66#include <VBox/com/com.h>
    6567#include <VBox/com/string.h>
    6668#include <VBox/com/array.h>
     
    130132# pragma optimize("g", off)
    131133#endif
     134
     135static int findEfiRom(FirmwareType_T aFirmwareType, Utf8Str& aEfiRomFile)
     136{
     137    /** @todo: combine with similar table in VirtualBox::CheckFirmwarePresent */
     138    static const struct {
     139        FirmwareType_T type;
     140        const char*    fileName;
     141    } firmwareDesc[] = {
     142        {
     143            /* compiled-in firmware */
     144            FirmwareType_BIOS,    NULL,
     145        },
     146        {
     147            FirmwareType_EFI,     "vboxefi.fv"
     148        },
     149        {
     150            FirmwareType_EFI64,   "vboxefi64.fv"
     151        },
     152        {
     153            FirmwareType_EFIDUAL, "vboxefidual.fv"
     154        }
     155    };
     156
     157
     158     for (size_t i = 0; i < sizeof(firmwareDesc) / sizeof(firmwareDesc[0]); i++)
     159    {
     160        if (aFirmwareType != firmwareDesc[i].type)
     161            continue;
     162
     163        AssertRCReturn(firmwareDesc[i].fileName != NULL, E_INVALIDARG);
     164
     165        /* Search in ~/.VirtualBox/Firmware and RTPathAppPrivateArch() */
     166        char pszVBoxPath[RTPATH_MAX];
     167        int rc;
     168
     169        rc = com::GetVBoxUserHomeDirectory(pszVBoxPath, sizeof(pszVBoxPath)); AssertRCReturn(rc, rc);
     170        aEfiRomFile = Utf8StrFmt("%s%cFirmware%c%s",
     171                                 pszVBoxPath,
     172                                 RTPATH_DELIMITER,
     173                                 RTPATH_DELIMITER,
     174                                 firmwareDesc[i].fileName);
     175        if (RTFileExists(aEfiRomFile.raw()))
     176            return S_OK;
     177
     178        rc = RTPathExecDir(pszVBoxPath, RTPATH_MAX); AssertRCReturn(rc, rc);
     179        aEfiRomFile = Utf8StrFmt("%s%c%s",
     180                              pszVBoxPath,
     181                              RTPATH_DELIMITER,
     182                              firmwareDesc[i].fileName);
     183
     184        if (RTFileExists(aEfiRomFile.raw()))
     185            return S_OK;
     186
     187        aEfiRomFile = "";
     188        return VERR_FILE_NOT_FOUND;
     189    }
     190
     191     return E_INVALIDARG;
     192}
    132193
    133194/**
     
    695756     * Firmware.
    696757     */
     758    FirmwareType_T eFwType =  FirmwareType_BIOS;
     759    hrc = pMachine->COMGETTER(FirmwareType)(&eFwType);                                H();
     760
    697761#ifdef VBOX_WITH_EFI
    698     Bstr tmpStr1;
    699     hrc = pMachine->GetExtraData(Bstr("VBoxInternal2/UseEFI"), tmpStr1.asOutParam());    H();
    700     BOOL fEfiEnabled = !tmpStr1.isEmpty();
    701 
    702     /**
    703      * @todo: VBoxInternal2/UseEFI extradata will go away soon, and we'll
    704      *        just use this code
    705      */
    706     if (!fEfiEnabled)
    707     {
    708       FirmwareType_T eType =  FirmwareType_BIOS;
    709       hrc = pMachine->COMGETTER(FirmwareType)(&eType);                                H();
    710       fEfiEnabled = (eType == FirmwareType_EFI);
    711     }
     762    BOOL fEfiEnabled = (eFwType >= FirmwareType_EFI) && (eFwType <= FirmwareType_EFIDUAL);
    712763#else
    713764    BOOL fEfiEnabled = false;
     
    774825    else
    775826    {
     827        Utf8Str efiRomFile;
     828
     829        rc = findEfiRom(eFwType, efiRomFile);                                       RC_CHECK();
    776830        /*
    777831         * EFI.
     
    784838        rc = CFGMR3InsertInteger(pCfg,  "RamHoleSize",      cbRamHole);             RC_CHECK();
    785839        rc = CFGMR3InsertInteger(pCfg,  "NumCPUs",          cCpus);                 RC_CHECK();
     840        rc = CFGMR3InsertString(pCfg,   "EfiRom",           efiRomFile.raw());      RC_CHECK();
    786841    }
    787842
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