VirtualBox

Changeset 101318 in vbox for trunk/src/VBox/Main/src-server


Ignore:
Timestamp:
Sep 29, 2023 3:13:07 PM (17 months ago)
Author:
vboxsync
Message:

Main: Move findEfiRom to the common code and add a PlatformArchitecture_T parameter to IVirtualBox::CheckFirmwarePresent to differentiate between x86 and ARM, bugref:10528

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp

    r101299 r101318  
    470470};
    471471
     472
     473/**
     474 * VirtualBox firmware descriptor.
     475 */
     476typedef struct VBOXFWDESC
     477{
     478    FirmwareType_T  enmType;
     479    bool            fBuiltIn;
     480    const char     *pszFileName;
     481    const char     *pszUrl;
     482} VBoxFwDesc;
     483typedef const VBOXFWDESC *PVBOXFWDESC;
     484
     485
    472486// constructor / destructor
    473487/////////////////////////////////////////////////////////////////////////////
     
    18851899}
    18861900
    1887 HRESULT VirtualBox::checkFirmwarePresent(FirmwareType_T aFirmwareType,
     1901HRESULT VirtualBox::checkFirmwarePresent(PlatformArchitecture_T aPlatformArchitecture,
     1902                                         FirmwareType_T aFirmwareType,
    18881903                                         const com::Utf8Str &aVersion,
    18891904                                         com::Utf8Str &aUrl,
     
    18931908    NOREF(aVersion);
    18941909
    1895     static const struct
    1896     {
    1897         FirmwareType_T  enmType;
    1898         bool            fBuiltIn;
    1899         const char     *pszFileName;
    1900         const char     *pszUrl;
    1901     }
    1902     firmwareDesc[] =
     1910    static const VBOXFWDESC s_FwDescX86[] =
    19031911    {
    19041912        {   FirmwareType_BIOS,    true,  NULL,             NULL },
     
    19141922    };
    19151923
    1916     for (size_t i = 0; i < sizeof(firmwareDesc) / sizeof(firmwareDesc[0]); i++)
    1917     {
    1918         if (aFirmwareType != firmwareDesc[i].enmType)
     1924    static const VBOXFWDESC s_FwDescArm[] =
     1925    {
     1926#ifdef VBOX_WITH_EFI_IN_DD2
     1927        {   FirmwareType_EFI32,   true,  "VBoxEFIAArch32.fd",   NULL },
     1928        {   FirmwareType_EFI64,   true,  "VBoxEFIAArch64.fd",   NULL },
     1929#else
     1930        {   FirmwareType_EFI32,   false, "VBoxEFIAArch32.fd",   "http://virtualbox.org/firmware/VBoxEFIAArch32.fd" },
     1931        {   FirmwareType_EFI64,   false, "VBoxEFIAArch64.fd",   "http://virtualbox.org/firmware/VBoxEFIAArch64.fd" },
     1932#endif
     1933    };
     1934
     1935    PVBOXFWDESC pFwDesc = NULL;
     1936    uint32_t cFwDesc = 0;
     1937    if (aPlatformArchitecture == PlatformArchitecture_x86)
     1938    {
     1939        pFwDesc = &s_FwDescX86[0];
     1940        cFwDesc = RT_ELEMENTS(s_FwDescX86);
     1941    }
     1942    else if (aPlatformArchitecture == PlatformArchitecture_ARM)
     1943    {
     1944        pFwDesc = &s_FwDescArm[0];
     1945        cFwDesc = RT_ELEMENTS(s_FwDescArm);
     1946    }
     1947    else
     1948        return E_INVALIDARG;
     1949
     1950    for (size_t i = 0; i < cFwDesc; i++)
     1951    {
     1952        if (aFirmwareType != pFwDesc->enmType)
     1953        {
     1954            pFwDesc++;
    19191955            continue;
     1956        }
    19201957
    19211958        /* compiled-in firmware */
    1922         if (firmwareDesc[i].fBuiltIn)
    1923         {
    1924             aFile = firmwareDesc[i].pszFileName;
     1959        if (pFwDesc->fBuiltIn)
     1960        {
     1961            aFile = pFwDesc->pszFileName;
    19251962            *aResult = TRUE;
    19261963            break;
     
    19281965
    19291966        Utf8Str    fullName;
    1930         Utf8StrFmt shortName("Firmware%c%s", RTPATH_DELIMITER, firmwareDesc[i].pszFileName);
     1967        Utf8StrFmt shortName("Firmware%c%s", RTPATH_DELIMITER, pFwDesc->pszFileName);
    19311968        int vrc = i_calculateFullPath(shortName, fullName);
    19321969        AssertRCReturn(vrc, VBOX_E_IPRT_ERROR);
     
    19411978        vrc = RTPathExecDir(szVBoxPath, RTPATH_MAX);
    19421979        AssertRCReturn(vrc, VBOX_E_IPRT_ERROR);
    1943         vrc = RTPathAppend(szVBoxPath, sizeof(szVBoxPath), firmwareDesc[i].pszFileName);
     1980        vrc = RTPathAppend(szVBoxPath, sizeof(szVBoxPath), pFwDesc->pszFileName);
    19441981        AssertRCReturn(vrc, VBOX_E_IPRT_ERROR);
    19451982        if (RTFileExists(szVBoxPath))
     
    19511988
    19521989        /** @todo account for version in the URL */
    1953         aUrl = firmwareDesc[i].pszUrl;
     1990        aUrl = pFwDesc->pszUrl;
    19541991        *aResult = FALSE;
    19551992
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