VirtualBox

Changeset 11257 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Aug 8, 2008 2:23:19 PM (16 years ago)
Author:
vboxsync
Message:

DevPcBios: Use CFGM*Def, cosmetics.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/PC/DevPcBios.cpp

    r10928 r11257  
    3636#include <VBox/param.h>
    3737
    38 #include "Builtins.h"
    39 #include "Builtins2.h"
     38#include "../Builtins.h"
     39#include "../Builtins2.h"
    4040#include "DevPcBios.h"
    4141
    4242
    43 /*
     43/** @page pg_devbios_cmos_assign    CMOS Assignments (BIOS)
     44 *
    4445 * The BIOS uses a CMOS to store configuration data.
    45  * It is currently used as followed:
     46 * It is currently used as follows:
    4647 *
    4748 *     Base memory:
     
    8889 */
    8990
     91
    9092/*******************************************************************************
    9193*   Structures and Typedefs                                                    *
     
    285287        return VERR_INVALID_PARAMETER;
    286288    rc = pBlock->pfnRead(pBlock, 0, aMBR, sizeof(aMBR));
    287     if (VBOX_FAILURE(rc))
     289    if (RT_FAILURE(rc))
    288290        return rc;
    289291    /* Test MBR magic number. */
     
    390392        /* No LCHS geometry, autodetect and set. */
    391393        rc = biosGuessDiskLCHS(pBlock, &LCHSGeometry);
    392         if (VBOX_FAILURE(rc))
     394        if (RT_FAILURE(rc))
    393395        {
    394396            /* Try if PCHS geometry works, otherwise fall back. */
    395397            rc = pHardDisk->pfnGetPCHSGeometry(pHardDisk, &LCHSGeometry);
    396398        }
    397         if (   VBOX_FAILURE(rc)
     399        if (   RT_FAILURE(rc)
    398400            || LCHSGeometry.cCylinders == 0
    399401            || LCHSGeometry.cCylinders > 1024
     
    450452 * @todo r=bird: This is a rather silly function since the conversion is 1:1.
    451453 */
    452 static uint8_t getBiosBootCode(PDEVPCBIOS pData, unsigned iOrder)
    453 {
    454     switch (pData->aenmBootDevice[iOrder])
     454static uint8_t getBiosBootCode(PDEVPCBIOS pThis, unsigned iOrder)
     455{
     456    switch (pThis->aenmBootDevice[iOrder])
    455457    {
    456458        case DEVPCBIOSBOOT_NONE:
     
    465467            return 4;
    466468        default:
    467             AssertMsgFailed(("aenmBootDevice[%d]=%d\n", iOrder, pData->aenmBootDevice[iOrder]));
     469            AssertMsgFailed(("aenmBootDevice[%d]=%d\n", iOrder, pThis->aenmBootDevice[iOrder]));
    468470            return 0;
    469471    }
     
    482484static DECLCALLBACK(int) pcbiosInitComplete(PPDMDEVINS pDevIns)
    483485{
    484     PDEVPCBIOS      pData = PDMINS2DATA(pDevIns, PDEVPCBIOS);
     486    PDEVPCBIOS      pThis = PDMINS_2_DATA(pDevIns, PDEVPCBIOS);
    485487    uint32_t        u32;
    486488    unsigned        i;
     
    495497     */
    496498    /* base memory. */
    497     u32 = pData->cbRam > 640 ? 640 : (uint32_t)pData->cbRam / _1K;
     499    u32 = pThis->cbRam > 640 ? 640 : (uint32_t)pThis->cbRam / _1K;
    498500    pcbiosCmosWrite(pDevIns, 0x15, u32 & 0xff);                                 /* 15h - Base Memory in K, Low Byte */
    499501    pcbiosCmosWrite(pDevIns, 0x16, u32 >> 8);                                   /* 16h - Base Memory in K, High Byte */
    500502
    501503    /* Extended memory, up to 65MB */
    502     u32 = pData->cbRam >= 65 * _1M ? 0xffff : ((uint32_t)pData->cbRam - _1M) / _1K;
     504    u32 = pThis->cbRam >= 65 * _1M ? 0xffff : ((uint32_t)pThis->cbRam - _1M) / _1K;
    503505    pcbiosCmosWrite(pDevIns, 0x17, u32 & 0xff);                                 /* 17h - Extended Memory in K, Low Byte */
    504506    pcbiosCmosWrite(pDevIns, 0x18, u32 >> 8);                                   /* 18h - Extended Memory in K, High Byte */
     
    507509
    508510    /* Bochs BIOS specific? Anyway, it's the amount of memory above 16MB */
    509     if (pData->cbRam > 16 * _1M)
    510     {
    511         u32 = (uint32_t)( (pData->cbRam - 16 * _1M) / _64K );
     511    if (pThis->cbRam > 16 * _1M)
     512    {
     513        u32 = (uint32_t)( (pThis->cbRam - 16 * _1M) / _64K );
    512514        u32 = RT_MIN(u32, 0xffff);
    513515    }
     
    523525     */
    524526
    525     uint8_t reg3d = getBiosBootCode(pData, 0) | (getBiosBootCode(pData, 1) << 4);
    526     uint8_t reg38 = /* pcbiosCmosRead(pDevIns, 0x38) | */ getBiosBootCode(pData, 2) << 4;
     527    uint8_t reg3d = getBiosBootCode(pThis, 0) | (getBiosBootCode(pThis, 1) << 4);
     528    uint8_t reg38 = /* pcbiosCmosRead(pDevIns, 0x38) | */ getBiosBootCode(pThis, 2) << 4;
    527529    /* This is an extension. Bochs BIOS normally supports only 3 boot devices. */
    528     uint8_t reg3c = getBiosBootCode(pData, 3) | (pData->uBootDelay << 4);
     530    uint8_t reg3c = getBiosBootCode(pThis, 3) | (pThis->uBootDelay << 4);
    529531    pcbiosCmosWrite(pDevIns, 0x3d, reg3d);
    530532    pcbiosCmosWrite(pDevIns, 0x38, reg38);
     
    534536     * PXE debug option.
    535537     */
    536     pcbiosCmosWrite(pDevIns, 0x3f, pData->u8PXEDebug);
     538    pcbiosCmosWrite(pDevIns, 0x3f, pThis->u8PXEDebug);
    537539
    538540    /*
    539541     * Floppy drive type.
    540542     */
    541     for (i = 0; i < ELEMENTS(apFDs); i++)
     543    for (i = 0; i < RT_ELEMENTS(apFDs); i++)
    542544    {
    543545        PPDMIBASE pBase;
    544         int rc = PDMR3QueryLun(pVM, pData->pszFDDevice, 0, i, &pBase);
    545         if (VBOX_SUCCESS(rc))
     546        int rc = PDMR3QueryLun(pVM, pThis->pszFDDevice, 0, i, &pBase);
     547        if (RT_SUCCESS(rc))
    546548            apFDs[i] = (PPDMIBLOCKBIOS)pBase->pfnQueryInterface(pBase, PDMINTERFACE_BLOCK_BIOS);
    547549    }
     
    586588     * Harddisks.
    587589     */
    588     for (i = 0; i < ELEMENTS(apHDs); i++)
     590    for (i = 0; i < RT_ELEMENTS(apHDs); i++)
    589591    {
    590592        PPDMIBASE pBase;
    591         int rc = PDMR3QueryLun(pVM, pData->pszHDDevice, 0, i, &pBase);
    592         if (VBOX_SUCCESS(rc))
     593        int rc = PDMR3QueryLun(pVM, pThis->pszHDDevice, 0, i, &pBase);
     594        if (RT_SUCCESS(rc))
    593595            apHDs[i] = (PPDMIBLOCKBIOS)pBase->pfnQueryInterface(pBase, PDMINTERFACE_BLOCK_BIOS);
    594596        if (   apHDs[i]
     
    641643     * Sata Harddisks.
    642644     */
    643     if (pData->pszSataDevice)
     645    if (pThis->pszSataDevice)
    644646    {
    645647        /* Clear pointers to IDE controller. */
    646         for (i = 0; i < ELEMENTS(apHDs); i++)
     648        for (i = 0; i < RT_ELEMENTS(apHDs); i++)
    647649            apHDs[i] = NULL;
    648650
    649         for (i = 0; i < ELEMENTS(apHDs); i++)
     651        for (i = 0; i < RT_ELEMENTS(apHDs); i++)
    650652        {
    651653            PPDMIBASE pBase;
    652             int rc = PDMR3QueryLun(pVM, pData->pszSataDevice, 0, pData->iSataHDLUN[i], &pBase);
    653             if (VBOX_SUCCESS(rc))
     654            int rc = PDMR3QueryLun(pVM, pThis->pszSataDevice, 0, pThis->iSataHDLUN[i], &pBase);
     655            if (RT_SUCCESS(rc))
    654656                apHDs[i] = (PPDMIBLOCKBIOS)pBase->pfnQueryInterface(pBase, PDMINTERFACE_BLOCK_BIOS);
    655657            if (   apHDs[i]
     
    751753             || Port == 0x403))
    752754    {
    753         PDEVPCBIOS pData = PDMINS2DATA(pDevIns, PDEVPCBIOS);
     755        PDEVPCBIOS pThis = PDMINS_2_DATA(pDevIns, PDEVPCBIOS);
    754756        /* The raw version. */
    755757        switch (u32)
     
    764766        if (u32 == '\n' || u32 == '\r')
    765767        {
    766             pData->szMsg[pData->iMsg] = '\0';
    767             if (pData->iMsg)
    768                 Log(("pcbios: %s\n", pData->szMsg));
    769             pData->iMsg = 0;
     768            pThis->szMsg[pThis->iMsg] = '\0';
     769            if (pThis->iMsg)
     770                Log(("pcbios: %s\n", pThis->szMsg));
     771            pThis->iMsg = 0;
    770772        }
    771773        else
    772774        {
    773             if (pData->iMsg >= sizeof(pData->szMsg)-1)
     775            if (pThis->iMsg >= sizeof(pThis->szMsg)-1)
    774776            {
    775                 pData->szMsg[pData->iMsg] = '\0';
    776                 Log(("pcbios: %s\n", pData->szMsg));
    777                 pData->iMsg = 0;
     777                pThis->szMsg[pThis->iMsg] = '\0';
     778                Log(("pcbios: %s\n", pThis->szMsg));
     779                pThis->iMsg = 0;
    778780            }
    779             pData->szMsg[pData->iMsg] = (char )u32;
    780             pData->szMsg[++pData->iMsg] = '\0';
     781            pThis->szMsg[pThis->iMsg] = (char )u32;
     782            pThis->szMsg[++pThis->iMsg] = '\0';
    781783        }
    782784        return VINF_SUCCESS;
     
    789791    {
    790792        static const unsigned char szShutdown[] = "Shutdown";
    791         PDEVPCBIOS pData = PDMINS2DATA(pDevIns, PDEVPCBIOS);
    792         if (u32 == szShutdown[pData->iShutdown])
    793         {
    794             pData->iShutdown++;
    795             if (pData->iShutdown == 8)
     793        PDEVPCBIOS pThis = PDMINS_2_DATA(pDevIns, PDEVPCBIOS);
     794        if (u32 == szShutdown[pThis->iShutdown])
     795        {
     796            pThis->iShutdown++;
     797            if (pThis->iShutdown == 8)
    796798            {
    797                 pData->iShutdown = 0;
     799                pThis->iShutdown = 0;
    798800                LogRel(("8900h shutdown request.\n"));
    799801                return PDMDevHlpVMPowerOff(pDevIns);
     
    801803        }
    802804        else
    803             pData->iShutdown = 0;
     805            pThis->iShutdown = 0;
    804806        return VINF_SUCCESS;
    805807    }
     
    845847        if (rc == VERR_CFGM_VALUE_NOT_FOUND) \
    846848            variable = MMR3HeapStrDup(PDMDevHlpGetVM(pDevIns), MM_TAG_CFGM, default_value); \
    847         else if (VBOX_FAILURE(rc)) \
     849        else if (RT_FAILURE(rc)) \
    848850            return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, \
    849851                    N_("Configuration error: Querying \"" name "\" as a string failed")); \
     
    854856        if (rc == VERR_CFGM_VALUE_NOT_FOUND) \
    855857            variable = default_value; \
    856         else if (VBOX_FAILURE(rc)) \
     858        else if (RT_FAILURE(rc)) \
    857859            return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, \
    858860                    N_("Configuration error: Querying \"" name "\" as a Int failed")); \
     
    877879    if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    878880        pszDmiSystemUuid = NULL;
    879     else if (VBOX_FAILURE(rc))
     881    else if (RT_FAILURE(rc))
    880882        return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
    881883                                   N_("Configuration error: Querying \"DmiUuid\" as a string failed"));
     
    951953    {
    952954        int rc = RTUuidFromStr(&uuid, pszDmiSystemUuid);
    953         if (VBOX_FAILURE(rc))
     955        if (RT_FAILURE(rc))
    954956            return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
    955957                                       N_("Invalid UUID for DMI tables specified"));
     
    11431145static DECLCALLBACK(void) pcbiosReset(PPDMDEVINS pDevIns)
    11441146{
    1145     PDEVPCBIOS  pData = PDMINS2DATA(pDevIns, PDEVPCBIOS);
     1147    PDEVPCBIOS  pThis = PDMINS_2_DATA(pDevIns, PDEVPCBIOS);
    11461148    LogFlow(("pcbiosReset:\n"));
    11471149
    1148     if (pData->u8IOAPIC)
    1149         pcbiosPlantMPStable(pDevIns, pData->au8DMIPage + VBOX_DMI_TABLE_SIZE);
     1150    if (pThis->u8IOAPIC)
     1151        pcbiosPlantMPStable(pDevIns, pThis->au8DMIPage + VBOX_DMI_TABLE_SIZE);
    11501152}
    11511153
     
    11611163static DECLCALLBACK(int) pcbiosDestruct(PPDMDEVINS pDevIns)
    11621164{
    1163     PDEVPCBIOS  pData = PDMINS2DATA(pDevIns, PDEVPCBIOS);
     1165    PDEVPCBIOS  pThis = PDMINS_2_DATA(pDevIns, PDEVPCBIOS);
    11641166    LogFlow(("pcbiosDestruct:\n"));
    11651167
     
    11671169     * Free MM heap pointers.
    11681170     */
    1169     if (pData->pu8PcBios)
    1170     {
    1171         MMR3HeapFree(pData->pu8PcBios);
    1172         pData->pu8PcBios = NULL;
    1173     }
    1174 
    1175     if (pData->pszPcBiosFile)
    1176     {
    1177         MMR3HeapFree(pData->pszPcBiosFile);
    1178         pData->pszPcBiosFile = NULL;
    1179     }
    1180 
    1181     if (pData->pu8LanBoot)
    1182     {
    1183         MMR3HeapFree(pData->pu8LanBoot);
    1184         pData->pu8LanBoot = NULL;
    1185     }
    1186 
    1187     if (pData->pszLanBootFile)
    1188     {
    1189         MMR3HeapFree(pData->pszLanBootFile);
    1190         pData->pszLanBootFile = NULL;
     1171    if (pThis->pu8PcBios)
     1172    {
     1173        MMR3HeapFree(pThis->pu8PcBios);
     1174        pThis->pu8PcBios = NULL;
     1175    }
     1176
     1177    if (pThis->pszPcBiosFile)
     1178    {
     1179        MMR3HeapFree(pThis->pszPcBiosFile);
     1180        pThis->pszPcBiosFile = NULL;
     1181    }
     1182
     1183    if (pThis->pu8LanBoot)
     1184    {
     1185        MMR3HeapFree(pThis->pu8LanBoot);
     1186        pThis->pu8LanBoot = NULL;
     1187    }
     1188
     1189    if (pThis->pszLanBootFile)
     1190    {
     1191        MMR3HeapFree(pThis->pszLanBootFile);
     1192        pThis->pszLanBootFile = NULL;
    11911193    }
    11921194
     
    12071209    char *psz;
    12081210    int rc = CFGMR3QueryStringAlloc(pCfgHandle, pszParam, &psz);
    1209     if (VBOX_FAILURE(rc))
     1211    if (RT_FAILURE(rc))
    12101212        return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
    12111213                                   N_("Configuration error: Querying \"%s\" as a string failed"),
     
    12481250{
    12491251    unsigned    i;
    1250     PDEVPCBIOS  pData = PDMINS2DATA(pDevIns, PDEVPCBIOS);
     1252    PDEVPCBIOS  pThis = PDMINS_2_DATA(pDevIns, PDEVPCBIOS);
    12511253    int         rc;
    12521254    int         cb;
     
    12951297     * Init the data.
    12961298     */
    1297     rc = CFGMR3QueryU64(pCfgHandle, "RamSize", &pData->cbRam);
    1298     if (VBOX_FAILURE(rc))
     1299    rc = CFGMR3QueryU64(pCfgHandle, "RamSize", &pThis->cbRam);
     1300    if (RT_FAILURE(rc))
    12991301        return PDMDEV_SET_ERROR(pDevIns, rc,
    13001302                                N_("Configuration error: Querying \"RamSize\" as integer failed"));
    13011303
    1302     rc = CFGMR3QueryU8 (pCfgHandle, "IOAPIC", &pData->u8IOAPIC);
    1303     if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    1304         pData->u8IOAPIC = 1;
    1305     else if (VBOX_FAILURE (rc))
     1304    rc = CFGMR3QueryU8Def(pCfgHandle, "IOAPIC", &pThis->u8IOAPIC, 1);
     1305    if (RT_FAILURE (rc))
    13061306        return PDMDEV_SET_ERROR(pDevIns, rc,
    13071307                                N_("Configuration error: Failed to read \"IOAPIC\""));
    13081308
    13091309    static const char * const s_apszBootDevices[] = { "BootDevice0", "BootDevice1", "BootDevice2", "BootDevice3" };
    1310     Assert(ELEMENTS(s_apszBootDevices) == ELEMENTS(pData->aenmBootDevice));
    1311     for (i = 0; i < ELEMENTS(pData->aenmBootDevice); i++)
    1312     {
    1313         rc = pcbiosBootFromCfg(pDevIns, pCfgHandle, s_apszBootDevices[i], &pData->aenmBootDevice[i]);
    1314         if (VBOX_FAILURE(rc))
     1310    Assert(RT_ELEMENTS(s_apszBootDevices) == RT_ELEMENTS(pThis->aenmBootDevice));
     1311    for (i = 0; i < RT_ELEMENTS(pThis->aenmBootDevice); i++)
     1312    {
     1313        rc = pcbiosBootFromCfg(pDevIns, pCfgHandle, s_apszBootDevices[i], &pThis->aenmBootDevice[i]);
     1314        if (RT_FAILURE(rc))
    13151315            return rc;
    13161316    }
    13171317
    1318     rc = CFGMR3QueryStringAlloc(pCfgHandle, "HardDiskDevice", &pData->pszHDDevice);
    1319     if (VBOX_FAILURE(rc))
     1318    rc = CFGMR3QueryStringAlloc(pCfgHandle, "HardDiskDevice", &pThis->pszHDDevice);
     1319    if (RT_FAILURE(rc))
    13201320        return PDMDEV_SET_ERROR(pDevIns, rc,
    13211321                                N_("Configuration error: Querying \"HardDiskDevice\" as a string failed"));
    13221322
    1323     rc = CFGMR3QueryStringAlloc(pCfgHandle, "FloppyDevice", &pData->pszFDDevice);
    1324     if (VBOX_FAILURE(rc))
     1323    rc = CFGMR3QueryStringAlloc(pCfgHandle, "FloppyDevice", &pThis->pszFDDevice);
     1324    if (RT_FAILURE(rc))
    13251325        return PDMDEV_SET_ERROR(pDevIns, rc,
    13261326                                N_("Configuration error: Querying \"FloppyDevice\" as a string failed"));
    13271327
    1328     rc = CFGMR3QueryStringAlloc(pCfgHandle, "SataHardDiskDevice", &pData->pszSataDevice);
     1328    rc = CFGMR3QueryStringAlloc(pCfgHandle, "SataHardDiskDevice", &pThis->pszSataDevice);
    13291329    if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    1330         pData->pszSataDevice = NULL;
    1331     else if (VBOX_FAILURE(rc))
     1330        pThis->pszSataDevice = NULL;
     1331    else if (RT_FAILURE(rc))
    13321332        return PDMDEV_SET_ERROR(pDevIns, rc,
    13331333                                N_("Configuration error: Querying \"SataHardDiskDevice\" as a string failed"));
    13341334
    1335     if (pData->pszSataDevice)
     1335    if (pThis->pszSataDevice)
    13361336    {
    13371337        static const char * const s_apszSataDisks[] =
    13381338            { "SataPrimaryMasterLUN", "SataPrimarySlaveLUN", "SataSecondaryMasterLUN", "SataSecondarySlaveLUN" };
    1339         Assert(ELEMENTS(s_apszSataDisks) == ELEMENTS(pData->iSataHDLUN));
    1340         for (i = 0; i < ELEMENTS(pData->iSataHDLUN); i++)
    1341         {
    1342             rc = CFGMR3QueryU32(pCfgHandle, s_apszSataDisks[i], &pData->iSataHDLUN[i]);
     1339        Assert(RT_ELEMENTS(s_apszSataDisks) == RT_ELEMENTS(pThis->iSataHDLUN));
     1340        for (i = 0; i < RT_ELEMENTS(pThis->iSataHDLUN); i++)
     1341        {
     1342            rc = CFGMR3QueryU32(pCfgHandle, s_apszSataDisks[i], &pThis->iSataHDLUN[i]);
    13431343            if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    1344                 pData->iSataHDLUN[i] = i;
    1345             else if (VBOX_FAILURE(rc))
     1344                pThis->iSataHDLUN[i] = i;
     1345            else if (RT_FAILURE(rc))
    13461346                return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
    13471347                                           N_("Configuration error: Querying \"%s\" as a string failed"), s_apszSataDisks);
     
    13531353    rc = PDMDevHlpIOPortRegister(pDevIns, 0x400, 4, NULL, pcbiosIOPortWrite, pcbiosIOPortRead,
    13541354                                 NULL, NULL, "Bochs PC BIOS - Panic & Debug");
    1355     if (VBOX_FAILURE(rc))
     1355    if (RT_FAILURE(rc))
    13561356        return rc;
    13571357    rc = PDMDevHlpIOPortRegister(pDevIns, 0x8900, 1, NULL, pcbiosIOPortWrite, pcbiosIOPortRead,
    13581358                                 NULL, NULL, "Bochs PC BIOS - Shutdown");
    1359     if (VBOX_FAILURE(rc))
     1359    if (RT_FAILURE(rc))
    13601360        return rc;
    13611361
     
    13651365    RTUUID  uuid;
    13661366    rc = CFGMR3QueryBytes(pCfgHandle, "UUID", &uuid, sizeof(uuid));
    1367     if (VBOX_FAILURE(rc))
     1367    if (RT_FAILURE(rc))
    13681368        return PDMDEV_SET_ERROR(pDevIns, rc,
    13691369                                N_("Configuration error: Querying \"UUID\" failed"));
     
    13741374    uuid.Gen.u16TimeMid = RT_H2BE_U16(uuid.Gen.u16TimeMid);
    13751375    uuid.Gen.u16TimeHiAndVersion = RT_H2BE_U16(uuid.Gen.u16TimeHiAndVersion);
    1376     rc = pcbiosPlantDMITable(pDevIns, pData->au8DMIPage, VBOX_DMI_TABLE_SIZE, &uuid, pCfgHandle);
    1377     if (VBOX_FAILURE(rc))
     1376    rc = pcbiosPlantDMITable(pDevIns, pThis->au8DMIPage, VBOX_DMI_TABLE_SIZE, &uuid, pCfgHandle);
     1377    if (RT_FAILURE(rc))
    13781378        return rc;
    1379     if (pData->u8IOAPIC)
    1380         pcbiosPlantMPStable(pDevIns, pData->au8DMIPage + VBOX_DMI_TABLE_SIZE);
    1381 
    1382     rc = PDMDevHlpROMRegister(pDevIns, VBOX_DMI_TABLE_BASE, _4K, pData->au8DMIPage, false /* fShadow */, "DMI tables");
    1383     if (VBOX_FAILURE(rc))
     1379    if (pThis->u8IOAPIC)
     1380        pcbiosPlantMPStable(pDevIns, pThis->au8DMIPage + VBOX_DMI_TABLE_SIZE);
     1381
     1382    rc = PDMDevHlpROMRegister(pDevIns, VBOX_DMI_TABLE_BASE, _4K, pThis->au8DMIPage, false /* fShadow */, "DMI tables");
     1383    if (RT_FAILURE(rc))
    13841384        return rc;
    13851385
     
    13871387     * Read the PXE debug logging option.
    13881388     */
    1389     rc = CFGMR3QueryU8(pCfgHandle, "PXEDebug", &pData->u8PXEDebug);
    1390     if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    1391         pData->u8PXEDebug = 0;
    1392     else if (VBOX_FAILURE(rc))
     1389    rc = CFGMR3QueryU8Def(pCfgHandle, "PXEDebug", &pThis->u8PXEDebug, false);
     1390    if (RT_FAILURE(rc))
    13931391        return PDMDEV_SET_ERROR(pDevIns, rc,
    13941392                                N_("Configuration error: Querying \"PXEDebug\" as integer failed"));
     
    13971395     * Get the system BIOS ROM file name.
    13981396     */
    1399     rc = CFGMR3QueryStringAlloc(pCfgHandle, "BiosRom", &pData->pszPcBiosFile);
     1397    rc = CFGMR3QueryStringAlloc(pCfgHandle, "BiosRom", &pThis->pszPcBiosFile);
    14001398    if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    14011399    {
    1402         pData->pszPcBiosFile = NULL;
     1400        pThis->pszPcBiosFile = NULL;
    14031401        rc = VINF_SUCCESS;
    14041402    }
    1405     else if (VBOX_FAILURE(rc))
     1403    else if (RT_FAILURE(rc))
    14061404        return PDMDEV_SET_ERROR(pDevIns, rc,
    14071405                                N_("Configuration error: Querying \"BiosRom\" as a string failed"));
    1408     else if (!*pData->pszPcBiosFile)
    1409     {
    1410         MMR3HeapFree(pData->pszPcBiosFile);
    1411         pData->pszPcBiosFile = NULL;
     1406    else if (!*pThis->pszPcBiosFile)
     1407    {
     1408        MMR3HeapFree(pThis->pszPcBiosFile);
     1409        pThis->pszPcBiosFile = NULL;
    14121410    }
    14131411
     
    14181416     */
    14191417    RTFILE FilePcBios = NIL_RTFILE;
    1420     if (pData->pszPcBiosFile)
    1421     {
    1422         rc = RTFileOpen(&FilePcBios, pData->pszPcBiosFile,
     1418    if (pThis->pszPcBiosFile)
     1419    {
     1420        rc = RTFileOpen(&FilePcBios, pThis->pszPcBiosFile,
    14231421                        RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
    1424         if (VBOX_SUCCESS(rc))
    1425         {
    1426             rc = RTFileGetSize(FilePcBios, &pData->cbPcBios);
    1427             if (VBOX_SUCCESS(rc))
     1422        if (RT_SUCCESS(rc))
     1423        {
     1424            rc = RTFileGetSize(FilePcBios, &pThis->cbPcBios);
     1425            if (RT_SUCCESS(rc))
    14281426            {
    14291427                /* The following checks should be in sync the AssertReleaseMsg's below. */
    1430                 if (    RT_ALIGN(pData->cbPcBios, _64K) != pData->cbPcBios
    1431                     ||  pData->cbPcBios > 32 * _64K
    1432                     ||  pData->cbPcBios < _64K)
     1428                if (    RT_ALIGN(pThis->cbPcBios, _64K) != pThis->cbPcBios
     1429                    ||  pThis->cbPcBios > 32 * _64K
     1430                    ||  pThis->cbPcBios < _64K)
    14331431                    rc = VERR_TOO_MUCH_DATA;
    14341432            }
    14351433        }
    1436         if (VBOX_FAILURE(rc))
     1434        if (RT_FAILURE(rc))
    14371435        {
    14381436            /*
    14391437             * In case of failure simply fall back to the built-in BIOS ROM.
    14401438             */
    1441             Log(("pcbiosConstruct: Failed to open system BIOS ROM file '%s', rc=%Vrc!\n", pData->pszPcBiosFile, rc));
     1439            Log(("pcbiosConstruct: Failed to open system BIOS ROM file '%s', rc=%Vrc!\n", pThis->pszPcBiosFile, rc));
    14421440            RTFileClose(FilePcBios);
    14431441            FilePcBios = NIL_RTFILE;
    1444             MMR3HeapFree(pData->pszPcBiosFile);
    1445             pData->pszPcBiosFile = NULL;
     1442            MMR3HeapFree(pThis->pszPcBiosFile);
     1443            pThis->pszPcBiosFile = NULL;
    14461444        }
    14471445    }
     
    14501448     * Attempt to get the system BIOS ROM data from file.
    14511449     */
    1452     if (pData->pszPcBiosFile)
     1450    if (pThis->pszPcBiosFile)
    14531451    {
    14541452        /*
    14551453         * Allocate buffer for the system BIOS ROM data.
    14561454         */
    1457         pData->pu8PcBios = (uint8_t *)PDMDevHlpMMHeapAlloc(pDevIns, pData->cbPcBios);
    1458         if (pData->pu8PcBios)
    1459         {
    1460             rc = RTFileRead(FilePcBios, pData->pu8PcBios, pData->cbPcBios, NULL);
    1461             if (VBOX_FAILURE(rc))
     1455        pThis->pu8PcBios = (uint8_t *)PDMDevHlpMMHeapAlloc(pDevIns, pThis->cbPcBios);
     1456        if (pThis->pu8PcBios)
     1457        {
     1458            rc = RTFileRead(FilePcBios, pThis->pu8PcBios, pThis->cbPcBios, NULL);
     1459            if (RT_FAILURE(rc))
    14621460            {
    1463                 AssertMsgFailed(("RTFileRead(,,%d,NULL) -> %Vrc\n", pData->cbPcBios, rc));
    1464                 MMR3HeapFree(pData->pu8PcBios);
    1465                 pData->pu8PcBios = NULL;
     1461                AssertMsgFailed(("RTFileRead(,,%d,NULL) -> %Vrc\n", pThis->cbPcBios, rc));
     1462                MMR3HeapFree(pThis->pu8PcBios);
     1463                pThis->pu8PcBios = NULL;
    14661464            }
    14671465            rc = VINF_SUCCESS;
     
    14711469    }
    14721470    else
    1473         pData->pu8PcBios = NULL;
     1471        pThis->pu8PcBios = NULL;
    14741472
    14751473    /* cleanup */
     
    14801478     * back to the built-in ROM image.
    14811479     */
    1482     if (pData->pu8PcBios == NULL)
     1480    if (pThis->pu8PcBios == NULL)
    14831481    {
    14841482        pu8PcBiosBinary = g_abPcBiosBinary;
     
    14871485    else
    14881486    {
    1489         pu8PcBiosBinary = pData->pu8PcBios;
    1490         cbPcBiosBinary  = pData->cbPcBios;
     1487        pu8PcBiosBinary = pThis->pu8PcBios;
     1488        cbPcBiosBinary  = pThis->cbPcBios;
    14911489    }
    14921490
     
    15041502    rc = PDMDevHlpROMRegister(pDevIns, 0x00100000 - cb, cb, &pu8PcBiosBinary[cbPcBiosBinary - cb],
    15051503                              false /* fShadow */, "PC BIOS - 0xfffff");
    1506     if (VBOX_FAILURE(rc))
     1504    if (RT_FAILURE(rc))
    15071505        return rc;
    15081506    rc = PDMDevHlpROMRegister(pDevIns, (uint32_t)-(int32_t)cbPcBiosBinary, cbPcBiosBinary, pu8PcBiosBinary,
    15091507                              false /* fShadow */, "PC BIOS - 0xffffffff");
    1510     if (VBOX_FAILURE(rc))
     1508    if (RT_FAILURE(rc))
    15111509        return rc;
    15121510
     
    15171515    AssertReleaseMsg(g_cbVmiBiosBinary == _4K, ("cbVmiBiosBinary=%#x\n", g_cbVmiBiosBinary));
    15181516    rc = PDMDevHlpROMRegister(pDevIns, VBOX_VMI_BIOS_BASE, g_cbVmiBiosBinary, g_abVmiBiosBinary, false, "VMI BIOS");
    1519     if (VBOX_FAILURE(rc))
     1517    if (RT_FAILURE(rc))
    15201518        return rc;
    15211519#endif
     
    15291527     * Get the LAN boot ROM file name.
    15301528     */
    1531     rc = CFGMR3QueryStringAlloc(pCfgHandle, "LanBootRom", &pData->pszLanBootFile);
     1529    rc = CFGMR3QueryStringAlloc(pCfgHandle, "LanBootRom", &pThis->pszLanBootFile);
    15321530    if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    15331531    {
    1534         pData->pszLanBootFile = NULL;
     1532        pThis->pszLanBootFile = NULL;
    15351533        rc = VINF_SUCCESS;
    15361534    }
    1537     else if (VBOX_FAILURE(rc))
     1535    else if (RT_FAILURE(rc))
    15381536        return PDMDEV_SET_ERROR(pDevIns, rc,
    15391537                                N_("Configuration error: Querying \"LanBootRom\" as a string failed"));
    1540     else if (!*pData->pszLanBootFile)
    1541     {
    1542         MMR3HeapFree(pData->pszLanBootFile);
    1543         pData->pszLanBootFile = NULL;
     1538    else if (!*pThis->pszLanBootFile)
     1539    {
     1540        MMR3HeapFree(pThis->pszLanBootFile);
     1541        pThis->pszLanBootFile = NULL;
    15441542    }
    15451543
     
    15521550     */
    15531551    RTFILE FileLanBoot = NIL_RTFILE;
    1554     if (pData->pszLanBootFile)
    1555     {
    1556         rc = RTFileOpen(&FileLanBoot, pData->pszLanBootFile,
     1552    if (pThis->pszLanBootFile)
     1553    {
     1554        rc = RTFileOpen(&FileLanBoot, pThis->pszLanBootFile,
    15571555                        RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
    1558         if (VBOX_SUCCESS(rc))
     1556        if (RT_SUCCESS(rc))
    15591557        {
    15601558            rc = RTFileGetSize(FileLanBoot, &cbFileLanBoot);
    1561             if (VBOX_SUCCESS(rc))
     1559            if (RT_SUCCESS(rc))
    15621560            {
    15631561                if (    RT_ALIGN(cbFileLanBoot, _4K) != cbFileLanBoot
     
    15661564            }
    15671565        }
    1568         if (VBOX_FAILURE(rc))
     1566        if (RT_FAILURE(rc))
    15691567        {
    15701568            /*
    15711569             * Ignore failure and fall back to the built-in LAN boot ROM.
    15721570             */
    1573             Log(("pcbiosConstruct: Failed to open LAN boot ROM file '%s', rc=%Vrc!\n", pData->pszLanBootFile, rc));
     1571            Log(("pcbiosConstruct: Failed to open LAN boot ROM file '%s', rc=%Vrc!\n", pThis->pszLanBootFile, rc));
    15741572            RTFileClose(FileLanBoot);
    15751573            FileLanBoot = NIL_RTFILE;
    1576             MMR3HeapFree(pData->pszLanBootFile);
    1577             pData->pszLanBootFile = NULL;
     1574            MMR3HeapFree(pThis->pszLanBootFile);
     1575            pThis->pszLanBootFile = NULL;
    15781576        }
    15791577    }
     
    15821580     * Get the LAN boot ROM data.
    15831581     */
    1584     if (pData->pszLanBootFile)
     1582    if (pThis->pszLanBootFile)
    15851583    {
    15861584        /*
    15871585         * Allocate buffer for the LAN boot ROM data.
    15881586         */
    1589         pData->pu8LanBoot = (uint8_t *)PDMDevHlpMMHeapAlloc(pDevIns, cbFileLanBoot);
    1590         if (pData->pu8LanBoot)
    1591         {
    1592             rc = RTFileRead(FileLanBoot, pData->pu8LanBoot, cbFileLanBoot, NULL);
    1593             if (VBOX_FAILURE(rc))
     1587        pThis->pu8LanBoot = (uint8_t *)PDMDevHlpMMHeapAlloc(pDevIns, cbFileLanBoot);
     1588        if (pThis->pu8LanBoot)
     1589        {
     1590            rc = RTFileRead(FileLanBoot, pThis->pu8LanBoot, cbFileLanBoot, NULL);
     1591            if (RT_FAILURE(rc))
    15941592            {
    15951593                AssertMsgFailed(("RTFileRead(,,%d,NULL) -> %Vrc\n", cbFileLanBoot, rc));
    1596                 MMR3HeapFree(pData->pu8LanBoot);
    1597                 pData->pu8LanBoot = NULL;
     1594                MMR3HeapFree(pThis->pu8LanBoot);
     1595                pThis->pu8LanBoot = NULL;
    15981596            }
    15991597            rc = VINF_SUCCESS;
     
    16031601    }
    16041602    else
    1605         pData->pu8LanBoot = NULL;
     1603        pThis->pu8LanBoot = NULL;
    16061604
    16071605    /* cleanup */
     
    16121610     * back to the built-in LAN boot ROM image.
    16131611     */
    1614     if (pData->pu8LanBoot == NULL)
     1612    if (pThis->pu8LanBoot == NULL)
    16151613    {
    16161614        pu8LanBootBinary = g_abNetBiosBinary;
     
    16191617    else
    16201618    {
    1621         pu8LanBootBinary = pData->pu8LanBoot;
     1619        pu8LanBootBinary = pThis->pu8LanBoot;
    16221620        cbLanBootBinary  = cbFileLanBoot;
    16231621    }
     
    16321630                                  true /* fShadow */, "Net Boot ROM");
    16331631
    1634     rc = CFGMR3QueryU8(pCfgHandle, "DelayBoot", &pData->uBootDelay);
    1635     if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    1636     {
    1637         pData->uBootDelay = 0;
    1638         rc = VINF_SUCCESS;
    1639     }
    1640     else
    1641     {
    1642         if (VBOX_FAILURE(rc))
    1643             return PDMDEV_SET_ERROR(pDevIns, rc,
     1632    rc = CFGMR3QueryU8Def(pCfgHandle, "DelayBoot", &pThis->uBootDelay, 0);
     1633    if (RT_FAILURE(rc))
     1634        return PDMDEV_SET_ERROR(pDevIns, rc,
    16441635                                    N_("Configuration error: Querying \"DelayBoot\" as integer failed"));
    1645         if (pData->uBootDelay > 15)
    1646             pData->uBootDelay = 15;
    1647     }
     1636    if (pThis->uBootDelay > 15)
     1637        pThis->uBootDelay = 15;
    16481638
    16491639    return rc;
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