Changeset 64472 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Oct 28, 2016 3:29:59 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Bus/DevPciIch9.cpp
r64471 r64472 684 684 * as a possible file #2 contains external code if there's any left. 685 685 */ 686 # define pciR3UnmergedConfigWriteDev ich9pciConfigWriteDev687 686 # include "DevPciMerge1.cpp.h" 688 687 … … 987 986 return u32Value; 988 987 } 988 989 990 991 /* -=-=-=-=-=- Saved State -=-=-=-=-=- */ 989 992 990 993 … … 1347 1350 1348 1351 1352 1353 /* -=-=-=-=-=- Fake PCI BIOS Init -=-=-=-=-=- */ 1354 1355 1349 1356 /* 1350 1357 * Perform imeediate read of configuration space register. 1351 1358 * Cannot be rescheduled, as already in R3. 1352 1359 */ 1353 static uint32_t ich9pci ConfigRead(PDEVPCIROOT pGlobals, uint8_t uBus, uint8_t uDevFn, uint32_t addr, uint32_t len)1360 static uint32_t ich9pciBiosInitReadConfig(PDEVPCIROOT pGlobals, uint8_t uBus, uint8_t uDevFn, uint32_t addr, uint32_t len) 1354 1361 { 1355 1362 PciAddress aPciAddr; … … 1370 1377 * Cannot be rescheduled, as already in R3. 1371 1378 */ 1372 static void ich9pci ConfigWrite(PDEVPCIROOT pGlobals, uint8_t uBus, uint8_t uDevFn, uint32_t addr, uint32_t val, uint32_t len)1379 static void ich9pciBiosInitWriteConfig(PDEVPCIROOT pGlobals, uint8_t uBus, uint8_t uDevFn, uint32_t addr, uint32_t val, uint32_t len) 1373 1380 { 1374 1381 PciAddress aPciAddr; … … 1382 1389 1383 1390 1384 static void ich9pci SetRegionAddress(PDEVPCIROOT pGlobals, uint8_t uBus, uint8_t uDevFn, int iRegion, uint64_t addr)1391 static void ich9pciBiosInitSetRegionAddress(PDEVPCIROOT pGlobals, uint8_t uBus, uint8_t uDevFn, int iRegion, uint64_t addr) 1385 1392 { 1386 1393 uint32_t uReg = ich9pciGetRegionReg(iRegion); 1387 1394 1388 1395 /* Read memory type first. */ 1389 uint8_t uResourceType = ich9pci ConfigRead(pGlobals, uBus, uDevFn, uReg, 1);1396 uint8_t uResourceType = ich9pciBiosInitReadConfig(pGlobals, uBus, uDevFn, uReg, 1); 1390 1397 bool f64Bit = (uResourceType & ((uint8_t)(PCI_ADDRESS_SPACE_BAR64 | PCI_ADDRESS_SPACE_IO))) 1391 1398 == PCI_ADDRESS_SPACE_BAR64; … … 1395 1402 1396 1403 /* Write address of the device. */ 1397 ich9pci ConfigWrite(pGlobals, uBus, uDevFn, uReg, (uint32_t)addr, 4);1404 ich9pciBiosInitWriteConfig(pGlobals, uBus, uDevFn, uReg, (uint32_t)addr, 4); 1398 1405 if (f64Bit) 1399 ich9pci ConfigWrite(pGlobals, uBus, uDevFn, uReg + 4, (uint32_t)(addr >> 32), 4);1406 ich9pciBiosInitWriteConfig(pGlobals, uBus, uDevFn, uReg + 4, (uint32_t)(addr >> 32), 4); 1400 1407 } 1401 1408 … … 1415 1422 Log(("%s: Aligned I/O start address. New address %#x\n", __FUNCTION__, pGlobals->uPciBiosIo)); 1416 1423 } 1417 ich9pci ConfigWrite(pGlobals, uBus, uDevFn, VBOX_PCI_IO_BASE, (pGlobals->uPciBiosIo >> 8) & 0xf0, 1);1424 ich9pciBiosInitWriteConfig(pGlobals, uBus, uDevFn, VBOX_PCI_IO_BASE, (pGlobals->uPciBiosIo >> 8) & 0xf0, 1); 1418 1425 1419 1426 /* The MMIO range for the bridge must be aligned to a 1MB boundary. */ … … 1423 1430 Log(("%s: Aligned MMIO start address. New address %#x\n", __FUNCTION__, pGlobals->uPciBiosMmio)); 1424 1431 } 1425 ich9pci ConfigWrite(pGlobals, uBus, uDevFn, VBOX_PCI_MEMORY_BASE, (pGlobals->uPciBiosMmio >> 16) & UINT32_C(0xffff0), 2);1432 ich9pciBiosInitWriteConfig(pGlobals, uBus, uDevFn, VBOX_PCI_MEMORY_BASE, (pGlobals->uPciBiosMmio >> 16) & UINT32_C(0xffff0), 2); 1426 1433 1427 1434 /* Save values to compare later to. */ 1428 1435 uint32_t u32IoAddressBase = pGlobals->uPciBiosIo; 1429 1436 uint32_t u32MMIOAddressBase = pGlobals->uPciBiosMmio; 1430 uint8_t uBridgeBus = ich9pci ConfigRead(pGlobals, uBus, uDevFn, VBOX_PCI_SECONDARY_BUS, 1);1437 uint8_t uBridgeBus = ich9pciBiosInitReadConfig(pGlobals, uBus, uDevFn, VBOX_PCI_SECONDARY_BUS, 1); 1431 1438 1432 1439 /* Init devices behind the bridge and possibly other bridges as well. */ … … 1446 1453 } 1447 1454 1448 ich9pci ConfigWrite(pGlobals, uBus, uDevFn, VBOX_PCI_IO_LIMIT, ((pGlobals->uPciBiosIo >> 8) & 0xf0) - 1, 1);1455 ich9pciBiosInitWriteConfig(pGlobals, uBus, uDevFn, VBOX_PCI_IO_LIMIT, ((pGlobals->uPciBiosIo >> 8) & 0xf0) - 1, 1); 1449 1456 1450 1457 /* Same with the MMIO limit register but with 1MB boundary here. */ … … 1454 1461 pGlobals->uPciBiosMmio = RT_ALIGN_32(pGlobals->uPciBiosMmio, 1024*1024); 1455 1462 } 1456 ich9pci ConfigWrite(pGlobals, uBus, uDevFn, VBOX_PCI_MEMORY_LIMIT, ((pGlobals->uPciBiosMmio >> 16) & UINT32_C(0xfff0)) - 1, 2);1463 ich9pciBiosInitWriteConfig(pGlobals, uBus, uDevFn, VBOX_PCI_MEMORY_LIMIT, ((pGlobals->uPciBiosMmio >> 16) & UINT32_C(0xfff0)) - 1, 2); 1457 1464 1458 1465 /* … … 1461 1468 * the base register than in the limit register. 1462 1469 */ 1463 ich9pci ConfigWrite(pGlobals, uBus, uDevFn, VBOX_PCI_PREF_MEMORY_BASE, 0xfff0, 2);1464 ich9pci ConfigWrite(pGlobals, uBus, uDevFn, VBOX_PCI_PREF_MEMORY_LIMIT, 0x0, 2);1465 ich9pci ConfigWrite(pGlobals, uBus, uDevFn, VBOX_PCI_PREF_BASE_UPPER32, 0x00, 4);1466 ich9pci ConfigWrite(pGlobals, uBus, uDevFn, VBOX_PCI_PREF_LIMIT_UPPER32, 0x00, 4);1470 ich9pciBiosInitWriteConfig(pGlobals, uBus, uDevFn, VBOX_PCI_PREF_MEMORY_BASE, 0xfff0, 2); 1471 ich9pciBiosInitWriteConfig(pGlobals, uBus, uDevFn, VBOX_PCI_PREF_MEMORY_LIMIT, 0x0, 2); 1472 ich9pciBiosInitWriteConfig(pGlobals, uBus, uDevFn, VBOX_PCI_PREF_BASE_UPPER32, 0x00, 4); 1473 ich9pciBiosInitWriteConfig(pGlobals, uBus, uDevFn, VBOX_PCI_PREF_LIMIT_UPPER32, 0x00, 4); 1467 1474 } 1468 1475 … … 1472 1479 uint8_t uCmd; 1473 1480 1474 uDevClass = ich9pci ConfigRead(pGlobals, uBus, uDevFn, VBOX_PCI_CLASS_DEVICE, 2);1475 uVendor = ich9pci ConfigRead(pGlobals, uBus, uDevFn, VBOX_PCI_VENDOR_ID, 2);1476 uDevice = ich9pci ConfigRead(pGlobals, uBus, uDevFn, VBOX_PCI_DEVICE_ID, 2);1481 uDevClass = ich9pciBiosInitReadConfig(pGlobals, uBus, uDevFn, VBOX_PCI_CLASS_DEVICE, 2); 1482 uVendor = ich9pciBiosInitReadConfig(pGlobals, uBus, uDevFn, VBOX_PCI_VENDOR_ID, 2); 1483 uDevice = ich9pciBiosInitReadConfig(pGlobals, uBus, uDevFn, VBOX_PCI_DEVICE_ID, 2); 1477 1484 1478 1485 /* If device is present */ … … 1486 1493 case 0x0101: 1487 1494 /* IDE controller */ 1488 ich9pci ConfigWrite(pGlobals, uBus, uDevFn, 0x40, 0x8000, 2); /* enable IDE0 */1489 ich9pci ConfigWrite(pGlobals, uBus, uDevFn, 0x42, 0x8000, 2); /* enable IDE1 */1495 ich9pciBiosInitWriteConfig(pGlobals, uBus, uDevFn, 0x40, 0x8000, 2); /* enable IDE0 */ 1496 ich9pciBiosInitWriteConfig(pGlobals, uBus, uDevFn, 0x42, 0x8000, 2); /* enable IDE1 */ 1490 1497 goto default_map; 1491 1498 break; … … 1502 1509 * ich9pciSetRegionAddress, so don't forget to enable I/O decoding. 1503 1510 */ 1504 uCmd = ich9pci ConfigRead(pGlobals, uBus, uDevFn, VBOX_PCI_COMMAND, 1);1505 ich9pci ConfigWrite(pGlobals, uBus, uDevFn, VBOX_PCI_COMMAND,1506 uCmd | PCI_COMMAND_IOACCESS,1507 1);1511 uCmd = ich9pciBiosInitReadConfig(pGlobals, uBus, uDevFn, VBOX_PCI_COMMAND, 1); 1512 ich9pciBiosInitWriteConfig(pGlobals, uBus, uDevFn, VBOX_PCI_COMMAND, 1513 uCmd | PCI_COMMAND_IOACCESS, 1514 1); 1508 1515 goto default_map; 1509 1516 break; … … 1528 1535 /* Calculate size - we write all 1s into the BAR, and then evaluate which bits 1529 1536 are cleared. */ 1530 uint8_t u8ResourceType = ich9pci ConfigRead(pGlobals, uBus, uDevFn, u32Address, 1);1537 uint8_t u8ResourceType = ich9pciBiosInitReadConfig(pGlobals, uBus, uDevFn, u32Address, 1); 1531 1538 1532 1539 bool f64Bit = (u8ResourceType & ((uint8_t)(PCI_ADDRESS_SPACE_BAR64 | PCI_ADDRESS_SPACE_IO))) … … 1537 1544 if (f64Bit) 1538 1545 { 1539 ich9pci ConfigWrite(pGlobals, uBus, uDevFn, u32Address, UINT32_C(0xffffffff), 4);1540 ich9pci ConfigWrite(pGlobals, uBus, uDevFn, u32Address+4, UINT32_C(0xffffffff), 4);1541 cbRegSize64 = ich9pci ConfigRead(pGlobals, uBus, uDevFn, u32Address, 4);1542 cbRegSize64 |= ((uint64_t)ich9pci ConfigRead(pGlobals, uBus, uDevFn, u32Address+4, 4) << 32);1546 ich9pciBiosInitWriteConfig(pGlobals, uBus, uDevFn, u32Address, UINT32_C(0xffffffff), 4); 1547 ich9pciBiosInitWriteConfig(pGlobals, uBus, uDevFn, u32Address+4, UINT32_C(0xffffffff), 4); 1548 cbRegSize64 = ich9pciBiosInitReadConfig(pGlobals, uBus, uDevFn, u32Address, 4); 1549 cbRegSize64 |= ((uint64_t)ich9pciBiosInitReadConfig(pGlobals, uBus, uDevFn, u32Address+4, 4) << 32); 1543 1550 cbRegSize64 &= ~UINT64_C(0x0f); 1544 1551 cbRegSize64 = (~cbRegSize64) + 1; … … 1552 1559 { 1553 1560 uint32_t cbRegSize32; 1554 ich9pci ConfigWrite(pGlobals, uBus, uDevFn, u32Address, UINT32_C(0xffffffff), 4);1555 cbRegSize32 = ich9pci ConfigRead(pGlobals, uBus, uDevFn, u32Address, 4);1561 ich9pciBiosInitWriteConfig(pGlobals, uBus, uDevFn, u32Address, UINT32_C(0xffffffff), 4); 1562 cbRegSize32 = ich9pciBiosInitReadConfig(pGlobals, uBus, uDevFn, u32Address, 4); 1556 1563 1557 1564 /* Clear resource information depending on resource type. */ … … 1596 1603 uNew = (uNew + cbRegSize64 - 1) & ~(cbRegSize64 - 1); 1597 1604 LogFunc(("Start address of 64-bit MMIO region %u/%u is %#llx\n", iRegion, iRegion + 1, uNew)); 1598 ich9pci SetRegionAddress(pGlobals, uBus, uDevFn, iRegion, uNew);1605 ich9pciBiosInitSetRegionAddress(pGlobals, uBus, uDevFn, iRegion, uNew); 1599 1606 fActiveMemRegion = true; 1600 1607 pGlobals->uPciBiosMmio64 = uNew + cbRegSize64; … … 1606 1613 iRegion, uBus, uDevFn >> 3, uDevFn & 7, uVendor, uDevice)); /** @todo make this a VM start failure later. */ 1607 1614 /* Undo the mapping mess caused by the size probing. */ 1608 ich9pci ConfigWrite(pGlobals, uBus, uDevFn, u32Address, UINT32_C(0), 4);1615 ich9pciBiosInitWriteConfig(pGlobals, uBus, uDevFn, u32Address, UINT32_C(0), 4); 1609 1616 } 1610 1617 } … … 1612 1619 { 1613 1620 LogFunc(("Start address of %s region %u is %#x\n", (fIsPio ? "I/O" : "MMIO"), iRegion, uNew)); 1614 ich9pci SetRegionAddress(pGlobals, uBus, uDevFn, iRegion, uNew);1621 ich9pciBiosInitSetRegionAddress(pGlobals, uBus, uDevFn, iRegion, uNew); 1615 1622 if (fIsPio) 1616 1623 fActiveIORegion = true; … … 1627 1634 1628 1635 /* Update the command word appropriately. */ 1629 uCmd = ich9pci ConfigRead(pGlobals, uBus, uDevFn, VBOX_PCI_COMMAND, 2);1636 uCmd = ich9pciBiosInitReadConfig(pGlobals, uBus, uDevFn, VBOX_PCI_COMMAND, 2); 1630 1637 if (fActiveMemRegion) 1631 1638 uCmd |= PCI_COMMAND_MEMACCESS; /* Enable MMIO access. */ 1632 1639 if (fActiveIORegion) 1633 1640 uCmd |= PCI_COMMAND_IOACCESS; /* Enable I/O space access. */ 1634 ich9pci ConfigWrite(pGlobals, uBus, uDevFn, VBOX_PCI_COMMAND, uCmd, 2);1641 ich9pciBiosInitWriteConfig(pGlobals, uBus, uDevFn, VBOX_PCI_COMMAND, uCmd, 2); 1635 1642 break; 1636 1643 } … … 1638 1645 1639 1646 /* map the interrupt */ 1640 uint32_t iPin = ich9pci ConfigRead(pGlobals, uBus, uDevFn, VBOX_PCI_INTERRUPT_PIN, 1);1647 uint32_t iPin = ich9pciBiosInitReadConfig(pGlobals, uBus, uDevFn, VBOX_PCI_INTERRUPT_PIN, 1); 1641 1648 if (iPin != 0) 1642 1649 { … … 1677 1684 Log(("Using pin %d and IRQ %d for device %02x:%02x.%d\n", 1678 1685 iPin, iIrq, uBus, uDevFn>>3, uDevFn&7)); 1679 ich9pci ConfigWrite(pGlobals, uBus, uDevFn, VBOX_PCI_INTERRUPT_LINE, iIrq, 1);1686 ich9pciBiosInitWriteConfig(pGlobals, uBus, uDevFn, VBOX_PCI_INTERRUPT_LINE, iIrq, 1); 1680 1687 } 1681 1688 }
Note:
See TracChangeset
for help on using the changeset viewer.