Changeset 11257 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Aug 8, 2008 2:23:19 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/DevPcBios.cpp
r10928 r11257 36 36 #include <VBox/param.h> 37 37 38 #include " Builtins.h"39 #include " Builtins2.h"38 #include "../Builtins.h" 39 #include "../Builtins2.h" 40 40 #include "DevPcBios.h" 41 41 42 42 43 /* 43 /** @page pg_devbios_cmos_assign CMOS Assignments (BIOS) 44 * 44 45 * The BIOS uses a CMOS to store configuration data. 45 * It is currently used as follow ed:46 * It is currently used as follows: 46 47 * 47 48 * Base memory: … … 88 89 */ 89 90 91 90 92 /******************************************************************************* 91 93 * Structures and Typedefs * … … 285 287 return VERR_INVALID_PARAMETER; 286 288 rc = pBlock->pfnRead(pBlock, 0, aMBR, sizeof(aMBR)); 287 if ( VBOX_FAILURE(rc))289 if (RT_FAILURE(rc)) 288 290 return rc; 289 291 /* Test MBR magic number. */ … … 390 392 /* No LCHS geometry, autodetect and set. */ 391 393 rc = biosGuessDiskLCHS(pBlock, &LCHSGeometry); 392 if ( VBOX_FAILURE(rc))394 if (RT_FAILURE(rc)) 393 395 { 394 396 /* Try if PCHS geometry works, otherwise fall back. */ 395 397 rc = pHardDisk->pfnGetPCHSGeometry(pHardDisk, &LCHSGeometry); 396 398 } 397 if ( VBOX_FAILURE(rc)399 if ( RT_FAILURE(rc) 398 400 || LCHSGeometry.cCylinders == 0 399 401 || LCHSGeometry.cCylinders > 1024 … … 450 452 * @todo r=bird: This is a rather silly function since the conversion is 1:1. 451 453 */ 452 static uint8_t getBiosBootCode(PDEVPCBIOS p Data, unsigned iOrder)453 { 454 switch (p Data->aenmBootDevice[iOrder])454 static uint8_t getBiosBootCode(PDEVPCBIOS pThis, unsigned iOrder) 455 { 456 switch (pThis->aenmBootDevice[iOrder]) 455 457 { 456 458 case DEVPCBIOSBOOT_NONE: … … 465 467 return 4; 466 468 default: 467 AssertMsgFailed(("aenmBootDevice[%d]=%d\n", iOrder, p Data->aenmBootDevice[iOrder]));469 AssertMsgFailed(("aenmBootDevice[%d]=%d\n", iOrder, pThis->aenmBootDevice[iOrder])); 468 470 return 0; 469 471 } … … 482 484 static DECLCALLBACK(int) pcbiosInitComplete(PPDMDEVINS pDevIns) 483 485 { 484 PDEVPCBIOS p Data = PDMINS2DATA(pDevIns, PDEVPCBIOS);486 PDEVPCBIOS pThis = PDMINS_2_DATA(pDevIns, PDEVPCBIOS); 485 487 uint32_t u32; 486 488 unsigned i; … … 495 497 */ 496 498 /* base memory. */ 497 u32 = p Data->cbRam > 640 ? 640 : (uint32_t)pData->cbRam / _1K;499 u32 = pThis->cbRam > 640 ? 640 : (uint32_t)pThis->cbRam / _1K; 498 500 pcbiosCmosWrite(pDevIns, 0x15, u32 & 0xff); /* 15h - Base Memory in K, Low Byte */ 499 501 pcbiosCmosWrite(pDevIns, 0x16, u32 >> 8); /* 16h - Base Memory in K, High Byte */ 500 502 501 503 /* Extended memory, up to 65MB */ 502 u32 = p Data->cbRam >= 65 * _1M ? 0xffff : ((uint32_t)pData->cbRam - _1M) / _1K;504 u32 = pThis->cbRam >= 65 * _1M ? 0xffff : ((uint32_t)pThis->cbRam - _1M) / _1K; 503 505 pcbiosCmosWrite(pDevIns, 0x17, u32 & 0xff); /* 17h - Extended Memory in K, Low Byte */ 504 506 pcbiosCmosWrite(pDevIns, 0x18, u32 >> 8); /* 18h - Extended Memory in K, High Byte */ … … 507 509 508 510 /* Bochs BIOS specific? Anyway, it's the amount of memory above 16MB */ 509 if (p Data->cbRam > 16 * _1M)510 { 511 u32 = (uint32_t)( (p Data->cbRam - 16 * _1M) / _64K );511 if (pThis->cbRam > 16 * _1M) 512 { 513 u32 = (uint32_t)( (pThis->cbRam - 16 * _1M) / _64K ); 512 514 u32 = RT_MIN(u32, 0xffff); 513 515 } … … 523 525 */ 524 526 525 uint8_t reg3d = getBiosBootCode(p Data, 0) | (getBiosBootCode(pData, 1) << 4);526 uint8_t reg38 = /* pcbiosCmosRead(pDevIns, 0x38) | */ getBiosBootCode(p Data, 2) << 4;527 uint8_t reg3d = getBiosBootCode(pThis, 0) | (getBiosBootCode(pThis, 1) << 4); 528 uint8_t reg38 = /* pcbiosCmosRead(pDevIns, 0x38) | */ getBiosBootCode(pThis, 2) << 4; 527 529 /* This is an extension. Bochs BIOS normally supports only 3 boot devices. */ 528 uint8_t reg3c = getBiosBootCode(p Data, 3) | (pData->uBootDelay << 4);530 uint8_t reg3c = getBiosBootCode(pThis, 3) | (pThis->uBootDelay << 4); 529 531 pcbiosCmosWrite(pDevIns, 0x3d, reg3d); 530 532 pcbiosCmosWrite(pDevIns, 0x38, reg38); … … 534 536 * PXE debug option. 535 537 */ 536 pcbiosCmosWrite(pDevIns, 0x3f, p Data->u8PXEDebug);538 pcbiosCmosWrite(pDevIns, 0x3f, pThis->u8PXEDebug); 537 539 538 540 /* 539 541 * Floppy drive type. 540 542 */ 541 for (i = 0; i < ELEMENTS(apFDs); i++)543 for (i = 0; i < RT_ELEMENTS(apFDs); i++) 542 544 { 543 545 PPDMIBASE pBase; 544 int rc = PDMR3QueryLun(pVM, p Data->pszFDDevice, 0, i, &pBase);545 if ( VBOX_SUCCESS(rc))546 int rc = PDMR3QueryLun(pVM, pThis->pszFDDevice, 0, i, &pBase); 547 if (RT_SUCCESS(rc)) 546 548 apFDs[i] = (PPDMIBLOCKBIOS)pBase->pfnQueryInterface(pBase, PDMINTERFACE_BLOCK_BIOS); 547 549 } … … 586 588 * Harddisks. 587 589 */ 588 for (i = 0; i < ELEMENTS(apHDs); i++)590 for (i = 0; i < RT_ELEMENTS(apHDs); i++) 589 591 { 590 592 PPDMIBASE pBase; 591 int rc = PDMR3QueryLun(pVM, p Data->pszHDDevice, 0, i, &pBase);592 if ( VBOX_SUCCESS(rc))593 int rc = PDMR3QueryLun(pVM, pThis->pszHDDevice, 0, i, &pBase); 594 if (RT_SUCCESS(rc)) 593 595 apHDs[i] = (PPDMIBLOCKBIOS)pBase->pfnQueryInterface(pBase, PDMINTERFACE_BLOCK_BIOS); 594 596 if ( apHDs[i] … … 641 643 * Sata Harddisks. 642 644 */ 643 if (p Data->pszSataDevice)645 if (pThis->pszSataDevice) 644 646 { 645 647 /* Clear pointers to IDE controller. */ 646 for (i = 0; i < ELEMENTS(apHDs); i++)648 for (i = 0; i < RT_ELEMENTS(apHDs); i++) 647 649 apHDs[i] = NULL; 648 650 649 for (i = 0; i < ELEMENTS(apHDs); i++)651 for (i = 0; i < RT_ELEMENTS(apHDs); i++) 650 652 { 651 653 PPDMIBASE pBase; 652 int rc = PDMR3QueryLun(pVM, p Data->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)) 654 656 apHDs[i] = (PPDMIBLOCKBIOS)pBase->pfnQueryInterface(pBase, PDMINTERFACE_BLOCK_BIOS); 655 657 if ( apHDs[i] … … 751 753 || Port == 0x403)) 752 754 { 753 PDEVPCBIOS p Data = PDMINS2DATA(pDevIns, PDEVPCBIOS);755 PDEVPCBIOS pThis = PDMINS_2_DATA(pDevIns, PDEVPCBIOS); 754 756 /* The raw version. */ 755 757 switch (u32) … … 764 766 if (u32 == '\n' || u32 == '\r') 765 767 { 766 p Data->szMsg[pData->iMsg] = '\0';767 if (p Data->iMsg)768 Log(("pcbios: %s\n", p Data->szMsg));769 p Data->iMsg = 0;768 pThis->szMsg[pThis->iMsg] = '\0'; 769 if (pThis->iMsg) 770 Log(("pcbios: %s\n", pThis->szMsg)); 771 pThis->iMsg = 0; 770 772 } 771 773 else 772 774 { 773 if (p Data->iMsg >= sizeof(pData->szMsg)-1)775 if (pThis->iMsg >= sizeof(pThis->szMsg)-1) 774 776 { 775 p Data->szMsg[pData->iMsg] = '\0';776 Log(("pcbios: %s\n", p Data->szMsg));777 p Data->iMsg = 0;777 pThis->szMsg[pThis->iMsg] = '\0'; 778 Log(("pcbios: %s\n", pThis->szMsg)); 779 pThis->iMsg = 0; 778 780 } 779 p Data->szMsg[pData->iMsg] = (char )u32;780 p Data->szMsg[++pData->iMsg] = '\0';781 pThis->szMsg[pThis->iMsg] = (char )u32; 782 pThis->szMsg[++pThis->iMsg] = '\0'; 781 783 } 782 784 return VINF_SUCCESS; … … 789 791 { 790 792 static const unsigned char szShutdown[] = "Shutdown"; 791 PDEVPCBIOS p Data = PDMINS2DATA(pDevIns, PDEVPCBIOS);792 if (u32 == szShutdown[p Data->iShutdown])793 { 794 p Data->iShutdown++;795 if (p Data->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) 796 798 { 797 p Data->iShutdown = 0;799 pThis->iShutdown = 0; 798 800 LogRel(("8900h shutdown request.\n")); 799 801 return PDMDevHlpVMPowerOff(pDevIns); … … 801 803 } 802 804 else 803 p Data->iShutdown = 0;805 pThis->iShutdown = 0; 804 806 return VINF_SUCCESS; 805 807 } … … 845 847 if (rc == VERR_CFGM_VALUE_NOT_FOUND) \ 846 848 variable = MMR3HeapStrDup(PDMDevHlpGetVM(pDevIns), MM_TAG_CFGM, default_value); \ 847 else if ( VBOX_FAILURE(rc)) \849 else if (RT_FAILURE(rc)) \ 848 850 return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, \ 849 851 N_("Configuration error: Querying \"" name "\" as a string failed")); \ … … 854 856 if (rc == VERR_CFGM_VALUE_NOT_FOUND) \ 855 857 variable = default_value; \ 856 else if ( VBOX_FAILURE(rc)) \858 else if (RT_FAILURE(rc)) \ 857 859 return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, \ 858 860 N_("Configuration error: Querying \"" name "\" as a Int failed")); \ … … 877 879 if (rc == VERR_CFGM_VALUE_NOT_FOUND) 878 880 pszDmiSystemUuid = NULL; 879 else if ( VBOX_FAILURE(rc))881 else if (RT_FAILURE(rc)) 880 882 return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, 881 883 N_("Configuration error: Querying \"DmiUuid\" as a string failed")); … … 951 953 { 952 954 int rc = RTUuidFromStr(&uuid, pszDmiSystemUuid); 953 if ( VBOX_FAILURE(rc))955 if (RT_FAILURE(rc)) 954 956 return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, 955 957 N_("Invalid UUID for DMI tables specified")); … … 1143 1145 static DECLCALLBACK(void) pcbiosReset(PPDMDEVINS pDevIns) 1144 1146 { 1145 PDEVPCBIOS p Data = PDMINS2DATA(pDevIns, PDEVPCBIOS);1147 PDEVPCBIOS pThis = PDMINS_2_DATA(pDevIns, PDEVPCBIOS); 1146 1148 LogFlow(("pcbiosReset:\n")); 1147 1149 1148 if (p Data->u8IOAPIC)1149 pcbiosPlantMPStable(pDevIns, p Data->au8DMIPage + VBOX_DMI_TABLE_SIZE);1150 if (pThis->u8IOAPIC) 1151 pcbiosPlantMPStable(pDevIns, pThis->au8DMIPage + VBOX_DMI_TABLE_SIZE); 1150 1152 } 1151 1153 … … 1161 1163 static DECLCALLBACK(int) pcbiosDestruct(PPDMDEVINS pDevIns) 1162 1164 { 1163 PDEVPCBIOS p Data = PDMINS2DATA(pDevIns, PDEVPCBIOS);1165 PDEVPCBIOS pThis = PDMINS_2_DATA(pDevIns, PDEVPCBIOS); 1164 1166 LogFlow(("pcbiosDestruct:\n")); 1165 1167 … … 1167 1169 * Free MM heap pointers. 1168 1170 */ 1169 if (p Data->pu8PcBios)1170 { 1171 MMR3HeapFree(p Data->pu8PcBios);1172 p Data->pu8PcBios = NULL;1173 } 1174 1175 if (p Data->pszPcBiosFile)1176 { 1177 MMR3HeapFree(p Data->pszPcBiosFile);1178 p Data->pszPcBiosFile = NULL;1179 } 1180 1181 if (p Data->pu8LanBoot)1182 { 1183 MMR3HeapFree(p Data->pu8LanBoot);1184 p Data->pu8LanBoot = NULL;1185 } 1186 1187 if (p Data->pszLanBootFile)1188 { 1189 MMR3HeapFree(p Data->pszLanBootFile);1190 p Data->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; 1191 1193 } 1192 1194 … … 1207 1209 char *psz; 1208 1210 int rc = CFGMR3QueryStringAlloc(pCfgHandle, pszParam, &psz); 1209 if ( VBOX_FAILURE(rc))1211 if (RT_FAILURE(rc)) 1210 1212 return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, 1211 1213 N_("Configuration error: Querying \"%s\" as a string failed"), … … 1248 1250 { 1249 1251 unsigned i; 1250 PDEVPCBIOS p Data = PDMINS2DATA(pDevIns, PDEVPCBIOS);1252 PDEVPCBIOS pThis = PDMINS_2_DATA(pDevIns, PDEVPCBIOS); 1251 1253 int rc; 1252 1254 int cb; … … 1295 1297 * Init the data. 1296 1298 */ 1297 rc = CFGMR3QueryU64(pCfgHandle, "RamSize", &p Data->cbRam);1298 if ( VBOX_FAILURE(rc))1299 rc = CFGMR3QueryU64(pCfgHandle, "RamSize", &pThis->cbRam); 1300 if (RT_FAILURE(rc)) 1299 1301 return PDMDEV_SET_ERROR(pDevIns, rc, 1300 1302 N_("Configuration error: Querying \"RamSize\" as integer failed")); 1301 1303 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)) 1306 1306 return PDMDEV_SET_ERROR(pDevIns, rc, 1307 1307 N_("Configuration error: Failed to read \"IOAPIC\"")); 1308 1308 1309 1309 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], &p Data->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)) 1315 1315 return rc; 1316 1316 } 1317 1317 1318 rc = CFGMR3QueryStringAlloc(pCfgHandle, "HardDiskDevice", &p Data->pszHDDevice);1319 if ( VBOX_FAILURE(rc))1318 rc = CFGMR3QueryStringAlloc(pCfgHandle, "HardDiskDevice", &pThis->pszHDDevice); 1319 if (RT_FAILURE(rc)) 1320 1320 return PDMDEV_SET_ERROR(pDevIns, rc, 1321 1321 N_("Configuration error: Querying \"HardDiskDevice\" as a string failed")); 1322 1322 1323 rc = CFGMR3QueryStringAlloc(pCfgHandle, "FloppyDevice", &p Data->pszFDDevice);1324 if ( VBOX_FAILURE(rc))1323 rc = CFGMR3QueryStringAlloc(pCfgHandle, "FloppyDevice", &pThis->pszFDDevice); 1324 if (RT_FAILURE(rc)) 1325 1325 return PDMDEV_SET_ERROR(pDevIns, rc, 1326 1326 N_("Configuration error: Querying \"FloppyDevice\" as a string failed")); 1327 1327 1328 rc = CFGMR3QueryStringAlloc(pCfgHandle, "SataHardDiskDevice", &p Data->pszSataDevice);1328 rc = CFGMR3QueryStringAlloc(pCfgHandle, "SataHardDiskDevice", &pThis->pszSataDevice); 1329 1329 if (rc == VERR_CFGM_VALUE_NOT_FOUND) 1330 p Data->pszSataDevice = NULL;1331 else if ( VBOX_FAILURE(rc))1330 pThis->pszSataDevice = NULL; 1331 else if (RT_FAILURE(rc)) 1332 1332 return PDMDEV_SET_ERROR(pDevIns, rc, 1333 1333 N_("Configuration error: Querying \"SataHardDiskDevice\" as a string failed")); 1334 1334 1335 if (p Data->pszSataDevice)1335 if (pThis->pszSataDevice) 1336 1336 { 1337 1337 static const char * const s_apszSataDisks[] = 1338 1338 { "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], &p Data->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]); 1343 1343 if (rc == VERR_CFGM_VALUE_NOT_FOUND) 1344 p Data->iSataHDLUN[i] = i;1345 else if ( VBOX_FAILURE(rc))1344 pThis->iSataHDLUN[i] = i; 1345 else if (RT_FAILURE(rc)) 1346 1346 return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, 1347 1347 N_("Configuration error: Querying \"%s\" as a string failed"), s_apszSataDisks); … … 1353 1353 rc = PDMDevHlpIOPortRegister(pDevIns, 0x400, 4, NULL, pcbiosIOPortWrite, pcbiosIOPortRead, 1354 1354 NULL, NULL, "Bochs PC BIOS - Panic & Debug"); 1355 if ( VBOX_FAILURE(rc))1355 if (RT_FAILURE(rc)) 1356 1356 return rc; 1357 1357 rc = PDMDevHlpIOPortRegister(pDevIns, 0x8900, 1, NULL, pcbiosIOPortWrite, pcbiosIOPortRead, 1358 1358 NULL, NULL, "Bochs PC BIOS - Shutdown"); 1359 if ( VBOX_FAILURE(rc))1359 if (RT_FAILURE(rc)) 1360 1360 return rc; 1361 1361 … … 1365 1365 RTUUID uuid; 1366 1366 rc = CFGMR3QueryBytes(pCfgHandle, "UUID", &uuid, sizeof(uuid)); 1367 if ( VBOX_FAILURE(rc))1367 if (RT_FAILURE(rc)) 1368 1368 return PDMDEV_SET_ERROR(pDevIns, rc, 1369 1369 N_("Configuration error: Querying \"UUID\" failed")); … … 1374 1374 uuid.Gen.u16TimeMid = RT_H2BE_U16(uuid.Gen.u16TimeMid); 1375 1375 uuid.Gen.u16TimeHiAndVersion = RT_H2BE_U16(uuid.Gen.u16TimeHiAndVersion); 1376 rc = pcbiosPlantDMITable(pDevIns, p Data->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)) 1378 1378 return rc; 1379 if (p Data->u8IOAPIC)1380 pcbiosPlantMPStable(pDevIns, p Data->au8DMIPage + VBOX_DMI_TABLE_SIZE);1381 1382 rc = PDMDevHlpROMRegister(pDevIns, VBOX_DMI_TABLE_BASE, _4K, p Data->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)) 1384 1384 return rc; 1385 1385 … … 1387 1387 * Read the PXE debug logging option. 1388 1388 */ 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)) 1393 1391 return PDMDEV_SET_ERROR(pDevIns, rc, 1394 1392 N_("Configuration error: Querying \"PXEDebug\" as integer failed")); … … 1397 1395 * Get the system BIOS ROM file name. 1398 1396 */ 1399 rc = CFGMR3QueryStringAlloc(pCfgHandle, "BiosRom", &p Data->pszPcBiosFile);1397 rc = CFGMR3QueryStringAlloc(pCfgHandle, "BiosRom", &pThis->pszPcBiosFile); 1400 1398 if (rc == VERR_CFGM_VALUE_NOT_FOUND) 1401 1399 { 1402 p Data->pszPcBiosFile = NULL;1400 pThis->pszPcBiosFile = NULL; 1403 1401 rc = VINF_SUCCESS; 1404 1402 } 1405 else if ( VBOX_FAILURE(rc))1403 else if (RT_FAILURE(rc)) 1406 1404 return PDMDEV_SET_ERROR(pDevIns, rc, 1407 1405 N_("Configuration error: Querying \"BiosRom\" as a string failed")); 1408 else if (!*p Data->pszPcBiosFile)1409 { 1410 MMR3HeapFree(p Data->pszPcBiosFile);1411 p Data->pszPcBiosFile = NULL;1406 else if (!*pThis->pszPcBiosFile) 1407 { 1408 MMR3HeapFree(pThis->pszPcBiosFile); 1409 pThis->pszPcBiosFile = NULL; 1412 1410 } 1413 1411 … … 1418 1416 */ 1419 1417 RTFILE FilePcBios = NIL_RTFILE; 1420 if (p Data->pszPcBiosFile)1421 { 1422 rc = RTFileOpen(&FilePcBios, p Data->pszPcBiosFile,1418 if (pThis->pszPcBiosFile) 1419 { 1420 rc = RTFileOpen(&FilePcBios, pThis->pszPcBiosFile, 1423 1421 RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE); 1424 if ( VBOX_SUCCESS(rc))1425 { 1426 rc = RTFileGetSize(FilePcBios, &p Data->cbPcBios);1427 if ( VBOX_SUCCESS(rc))1422 if (RT_SUCCESS(rc)) 1423 { 1424 rc = RTFileGetSize(FilePcBios, &pThis->cbPcBios); 1425 if (RT_SUCCESS(rc)) 1428 1426 { 1429 1427 /* The following checks should be in sync the AssertReleaseMsg's below. */ 1430 if ( RT_ALIGN(p Data->cbPcBios, _64K) != pData->cbPcBios1431 || p Data->cbPcBios > 32 * _64K1432 || p Data->cbPcBios < _64K)1428 if ( RT_ALIGN(pThis->cbPcBios, _64K) != pThis->cbPcBios 1429 || pThis->cbPcBios > 32 * _64K 1430 || pThis->cbPcBios < _64K) 1433 1431 rc = VERR_TOO_MUCH_DATA; 1434 1432 } 1435 1433 } 1436 if ( VBOX_FAILURE(rc))1434 if (RT_FAILURE(rc)) 1437 1435 { 1438 1436 /* 1439 1437 * In case of failure simply fall back to the built-in BIOS ROM. 1440 1438 */ 1441 Log(("pcbiosConstruct: Failed to open system BIOS ROM file '%s', rc=%Vrc!\n", p Data->pszPcBiosFile, rc));1439 Log(("pcbiosConstruct: Failed to open system BIOS ROM file '%s', rc=%Vrc!\n", pThis->pszPcBiosFile, rc)); 1442 1440 RTFileClose(FilePcBios); 1443 1441 FilePcBios = NIL_RTFILE; 1444 MMR3HeapFree(p Data->pszPcBiosFile);1445 p Data->pszPcBiosFile = NULL;1442 MMR3HeapFree(pThis->pszPcBiosFile); 1443 pThis->pszPcBiosFile = NULL; 1446 1444 } 1447 1445 } … … 1450 1448 * Attempt to get the system BIOS ROM data from file. 1451 1449 */ 1452 if (p Data->pszPcBiosFile)1450 if (pThis->pszPcBiosFile) 1453 1451 { 1454 1452 /* 1455 1453 * Allocate buffer for the system BIOS ROM data. 1456 1454 */ 1457 p Data->pu8PcBios = (uint8_t *)PDMDevHlpMMHeapAlloc(pDevIns, pData->cbPcBios);1458 if (p Data->pu8PcBios)1459 { 1460 rc = RTFileRead(FilePcBios, p Data->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)) 1462 1460 { 1463 AssertMsgFailed(("RTFileRead(,,%d,NULL) -> %Vrc\n", p Data->cbPcBios, rc));1464 MMR3HeapFree(p Data->pu8PcBios);1465 p Data->pu8PcBios = NULL;1461 AssertMsgFailed(("RTFileRead(,,%d,NULL) -> %Vrc\n", pThis->cbPcBios, rc)); 1462 MMR3HeapFree(pThis->pu8PcBios); 1463 pThis->pu8PcBios = NULL; 1466 1464 } 1467 1465 rc = VINF_SUCCESS; … … 1471 1469 } 1472 1470 else 1473 p Data->pu8PcBios = NULL;1471 pThis->pu8PcBios = NULL; 1474 1472 1475 1473 /* cleanup */ … … 1480 1478 * back to the built-in ROM image. 1481 1479 */ 1482 if (p Data->pu8PcBios == NULL)1480 if (pThis->pu8PcBios == NULL) 1483 1481 { 1484 1482 pu8PcBiosBinary = g_abPcBiosBinary; … … 1487 1485 else 1488 1486 { 1489 pu8PcBiosBinary = p Data->pu8PcBios;1490 cbPcBiosBinary = p Data->cbPcBios;1487 pu8PcBiosBinary = pThis->pu8PcBios; 1488 cbPcBiosBinary = pThis->cbPcBios; 1491 1489 } 1492 1490 … … 1504 1502 rc = PDMDevHlpROMRegister(pDevIns, 0x00100000 - cb, cb, &pu8PcBiosBinary[cbPcBiosBinary - cb], 1505 1503 false /* fShadow */, "PC BIOS - 0xfffff"); 1506 if ( VBOX_FAILURE(rc))1504 if (RT_FAILURE(rc)) 1507 1505 return rc; 1508 1506 rc = PDMDevHlpROMRegister(pDevIns, (uint32_t)-(int32_t)cbPcBiosBinary, cbPcBiosBinary, pu8PcBiosBinary, 1509 1507 false /* fShadow */, "PC BIOS - 0xffffffff"); 1510 if ( VBOX_FAILURE(rc))1508 if (RT_FAILURE(rc)) 1511 1509 return rc; 1512 1510 … … 1517 1515 AssertReleaseMsg(g_cbVmiBiosBinary == _4K, ("cbVmiBiosBinary=%#x\n", g_cbVmiBiosBinary)); 1518 1516 rc = PDMDevHlpROMRegister(pDevIns, VBOX_VMI_BIOS_BASE, g_cbVmiBiosBinary, g_abVmiBiosBinary, false, "VMI BIOS"); 1519 if ( VBOX_FAILURE(rc))1517 if (RT_FAILURE(rc)) 1520 1518 return rc; 1521 1519 #endif … … 1529 1527 * Get the LAN boot ROM file name. 1530 1528 */ 1531 rc = CFGMR3QueryStringAlloc(pCfgHandle, "LanBootRom", &p Data->pszLanBootFile);1529 rc = CFGMR3QueryStringAlloc(pCfgHandle, "LanBootRom", &pThis->pszLanBootFile); 1532 1530 if (rc == VERR_CFGM_VALUE_NOT_FOUND) 1533 1531 { 1534 p Data->pszLanBootFile = NULL;1532 pThis->pszLanBootFile = NULL; 1535 1533 rc = VINF_SUCCESS; 1536 1534 } 1537 else if ( VBOX_FAILURE(rc))1535 else if (RT_FAILURE(rc)) 1538 1536 return PDMDEV_SET_ERROR(pDevIns, rc, 1539 1537 N_("Configuration error: Querying \"LanBootRom\" as a string failed")); 1540 else if (!*p Data->pszLanBootFile)1541 { 1542 MMR3HeapFree(p Data->pszLanBootFile);1543 p Data->pszLanBootFile = NULL;1538 else if (!*pThis->pszLanBootFile) 1539 { 1540 MMR3HeapFree(pThis->pszLanBootFile); 1541 pThis->pszLanBootFile = NULL; 1544 1542 } 1545 1543 … … 1552 1550 */ 1553 1551 RTFILE FileLanBoot = NIL_RTFILE; 1554 if (p Data->pszLanBootFile)1555 { 1556 rc = RTFileOpen(&FileLanBoot, p Data->pszLanBootFile,1552 if (pThis->pszLanBootFile) 1553 { 1554 rc = RTFileOpen(&FileLanBoot, pThis->pszLanBootFile, 1557 1555 RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE); 1558 if ( VBOX_SUCCESS(rc))1556 if (RT_SUCCESS(rc)) 1559 1557 { 1560 1558 rc = RTFileGetSize(FileLanBoot, &cbFileLanBoot); 1561 if ( VBOX_SUCCESS(rc))1559 if (RT_SUCCESS(rc)) 1562 1560 { 1563 1561 if ( RT_ALIGN(cbFileLanBoot, _4K) != cbFileLanBoot … … 1566 1564 } 1567 1565 } 1568 if ( VBOX_FAILURE(rc))1566 if (RT_FAILURE(rc)) 1569 1567 { 1570 1568 /* 1571 1569 * Ignore failure and fall back to the built-in LAN boot ROM. 1572 1570 */ 1573 Log(("pcbiosConstruct: Failed to open LAN boot ROM file '%s', rc=%Vrc!\n", p Data->pszLanBootFile, rc));1571 Log(("pcbiosConstruct: Failed to open LAN boot ROM file '%s', rc=%Vrc!\n", pThis->pszLanBootFile, rc)); 1574 1572 RTFileClose(FileLanBoot); 1575 1573 FileLanBoot = NIL_RTFILE; 1576 MMR3HeapFree(p Data->pszLanBootFile);1577 p Data->pszLanBootFile = NULL;1574 MMR3HeapFree(pThis->pszLanBootFile); 1575 pThis->pszLanBootFile = NULL; 1578 1576 } 1579 1577 } … … 1582 1580 * Get the LAN boot ROM data. 1583 1581 */ 1584 if (p Data->pszLanBootFile)1582 if (pThis->pszLanBootFile) 1585 1583 { 1586 1584 /* 1587 1585 * Allocate buffer for the LAN boot ROM data. 1588 1586 */ 1589 p Data->pu8LanBoot = (uint8_t *)PDMDevHlpMMHeapAlloc(pDevIns, cbFileLanBoot);1590 if (p Data->pu8LanBoot)1591 { 1592 rc = RTFileRead(FileLanBoot, p Data->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)) 1594 1592 { 1595 1593 AssertMsgFailed(("RTFileRead(,,%d,NULL) -> %Vrc\n", cbFileLanBoot, rc)); 1596 MMR3HeapFree(p Data->pu8LanBoot);1597 p Data->pu8LanBoot = NULL;1594 MMR3HeapFree(pThis->pu8LanBoot); 1595 pThis->pu8LanBoot = NULL; 1598 1596 } 1599 1597 rc = VINF_SUCCESS; … … 1603 1601 } 1604 1602 else 1605 p Data->pu8LanBoot = NULL;1603 pThis->pu8LanBoot = NULL; 1606 1604 1607 1605 /* cleanup */ … … 1612 1610 * back to the built-in LAN boot ROM image. 1613 1611 */ 1614 if (p Data->pu8LanBoot == NULL)1612 if (pThis->pu8LanBoot == NULL) 1615 1613 { 1616 1614 pu8LanBootBinary = g_abNetBiosBinary; … … 1619 1617 else 1620 1618 { 1621 pu8LanBootBinary = p Data->pu8LanBoot;1619 pu8LanBootBinary = pThis->pu8LanBoot; 1622 1620 cbLanBootBinary = cbFileLanBoot; 1623 1621 } … … 1632 1630 true /* fShadow */, "Net Boot ROM"); 1633 1631 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, 1644 1635 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; 1648 1638 1649 1639 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.