Changeset 37424 in vbox for trunk/src/VBox/VMM
- Timestamp:
- Jun 12, 2011 7:28:11 PM (14 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/IOMAll.cpp
r36794 r37424 37 37 #include <VBox/log.h> 38 38 #include <iprt/assert.h> 39 #include "IOMInline.h" 39 40 40 41 … … 292 293 || (unsigned)Port - (unsigned)pRange->Port >= (unsigned)pRange->cPorts) 293 294 { 294 pRange = iomIOPortGetRange( &pVM->iom.s, Port);295 pRange = iomIOPortGetRange(pVM, Port); 295 296 if (pRange) 296 297 pVM->iom.s.CTX_SUFF(pRangeLastRead) = pRange; … … 387 388 * Handler in ring-3? 388 389 */ 389 PIOMIOPORTRANGER3 pRangeR3 = iomIOPortGetRangeR3( &pVM->iom.s, Port);390 PIOMIOPORTRANGER3 pRangeR3 = iomIOPortGetRangeR3(pVM, Port); 390 391 if (pRangeR3) 391 392 { … … 488 489 || (unsigned)Port - (unsigned)pRange->Port >= (unsigned)pRange->cPorts) 489 490 { 490 pRange = iomIOPortGetRange( &pVM->iom.s, Port);491 pRange = iomIOPortGetRange(pVM, Port); 491 492 if (pRange) 492 493 pVM->iom.s.CTX_SUFF(pRangeLastRead) = pRange; … … 569 570 * Handler in ring-3? 570 571 */ 571 PIOMIOPORTRANGER3 pRangeR3 = iomIOPortGetRangeR3( &pVM->iom.s, Port);572 PIOMIOPORTRANGER3 pRangeR3 = iomIOPortGetRangeR3(pVM, Port); 572 573 if (pRangeR3) 573 574 { … … 658 659 || (unsigned)Port - (unsigned)pRange->Port >= (unsigned)pRange->cPorts) 659 660 { 660 pRange = iomIOPortGetRange( &pVM->iom.s, Port);661 pRange = iomIOPortGetRange(pVM, Port); 661 662 if (pRange) 662 663 pVM->iom.s.CTX_SUFF(pRangeLastWrite) = pRange; … … 738 739 * Handler in ring-3? 739 740 */ 740 PIOMIOPORTRANGER3 pRangeR3 = iomIOPortGetRangeR3( &pVM->iom.s, Port);741 PIOMIOPORTRANGER3 pRangeR3 = iomIOPortGetRangeR3(pVM, Port); 741 742 if (pRangeR3) 742 743 { … … 828 829 || (unsigned)Port - (unsigned)pRange->Port >= (unsigned)pRange->cPorts) 829 830 { 830 pRange = iomIOPortGetRange( &pVM->iom.s, Port);831 pRange = iomIOPortGetRange(pVM, Port); 831 832 if (pRange) 832 833 pVM->iom.s.CTX_SUFF(pRangeLastWrite) = pRange; … … 909 910 * Handler in ring-3? 910 911 */ 911 PIOMIOPORTRANGER3 pRangeR3 = iomIOPortGetRangeR3( &pVM->iom.s, Port);912 PIOMIOPORTRANGER3 pRangeR3 = iomIOPortGetRangeR3(pVM, Port); 912 913 if (pRangeR3) 913 914 { -
trunk/src/VBox/VMM/VMMAll/IOMAllMMIO.cpp
r37423 r37424 36 36 #include <VBox/vmm/vmm.h> 37 37 #include <VBox/vmm/hwaccm.h> 38 #include "IOMInline.h" 38 39 39 40 #include <VBox/dis.h> … … 81 82 { 82 83 #ifdef VBOX_WITH_STATISTICS 83 PIOMMMIOSTATS pStats = iomMMIOGetStats( &pVM->iom.s, GCPhysFault, pRange);84 PIOMMMIOSTATS pStats = iomMMIOGetStats(pVM, GCPhysFault, pRange); 84 85 Assert(pStats); 85 86 #endif … … 103 104 { 104 105 #ifdef VBOX_WITH_STATISTICS 105 PIOMMMIOSTATS pStats = iomMMIOGetStats( &pVM->iom.s, GCPhys, pRange);106 PIOMMMIOSTATS pStats = iomMMIOGetStats(pVM, GCPhys, pRange); 106 107 Assert(pStats); 107 108 #endif … … 455 456 PhysDst |= (RTGCUINTPTR)pu8Virt & PAGE_OFFSET_MASK; 456 457 if ( RT_SUCCESS(rc) 457 && (pMMIODst = iomMMIOGetRange( &pVM->iom.s, PhysDst)))458 && (pMMIODst = iomMMIOGetRange(pVM, PhysDst))) 458 459 { 459 460 /** @todo implement per-device locks for MMIO access. */ … … 1076 1077 PIOMMMIORANGE pRange = (PIOMMMIORANGE)pvUser; 1077 1078 Assert(pRange); 1078 Assert(pRange == iomMMIOGetRange( &pVM->iom.s, GCPhysFault));1079 Assert(pRange == iomMMIOGetRange(pVM, GCPhysFault)); 1079 1080 /** @todo implement per-device locks for MMIO access. It can replace the IOM 1080 1081 * lock for most of the code, provided that we retake the lock while … … 1087 1088 * Locate the statistics, if > PAGE_SIZE we'll use the first byte for everything. 1088 1089 */ 1089 PIOMMMIOSTATS pStats = iomMMIOGetStats( &pVM->iom.s, GCPhysFault, pRange);1090 PIOMMMIOSTATS pStats = iomMMIOGetStats(pVM, GCPhysFault, pRange); 1090 1091 if (!pStats) 1091 1092 { … … 1309 1310 return VINF_IOM_HC_MMIO_READ_WRITE; 1310 1311 #endif 1311 VBOXSTRICTRC rcStrict = iomMMIOHandler(pVM, (uint32_t)uErrorCode, pCtxCore, GCPhysFault, iomMMIOGetRange( &pVM->iom.s, GCPhysFault));1312 VBOXSTRICTRC rcStrict = iomMMIOHandler(pVM, (uint32_t)uErrorCode, pCtxCore, GCPhysFault, iomMMIOGetRange(pVM, GCPhysFault)); 1312 1313 iomUnlock(pVM); 1313 1314 return VBOXSTRICTRC_VAL(rcStrict); … … 1340 1341 1341 1342 Assert(pRange); 1342 Assert(pRange == iomMMIOGetRange( &pVM->iom.s, GCPhysFault));1343 Assert(pRange == iomMMIOGetRange(pVM, GCPhysFault)); 1343 1344 /** @todo implement per-device locks for MMIO access. It can replace the IOM 1344 1345 * lock for most of the code, provided that we retake the lock while … … 1384 1385 * Lookup the current context range node and statistics. 1385 1386 */ 1386 PIOMMMIORANGE pRange = iomMMIOGetRange( &pVM->iom.s, GCPhys);1387 PIOMMMIORANGE pRange = iomMMIOGetRange(pVM, GCPhys); 1387 1388 AssertMsg(pRange, ("Handlers and page tables are out of sync or something! GCPhys=%RGp cbValue=%d\n", GCPhys, cbValue)); 1388 1389 if (!pRange) … … 1394 1395 Assert(!pRange->CTX_SUFF(pDevIns) || !pRange->CTX_SUFF(pDevIns)->CTX_SUFF(pCritSect)); 1395 1396 #ifdef VBOX_WITH_STATISTICS 1396 PIOMMMIOSTATS pStats = iomMMIOGetStats( &pVM->iom.s, GCPhys, pRange);1397 PIOMMMIOSTATS pStats = iomMMIOGetStats(pVM, GCPhys, pRange); 1397 1398 if (!pStats) 1398 1399 { … … 1513 1514 * Lookup the current context range node. 1514 1515 */ 1515 PIOMMMIORANGE pRange = iomMMIOGetRange( &pVM->iom.s, GCPhys);1516 PIOMMMIORANGE pRange = iomMMIOGetRange(pVM, GCPhys); 1516 1517 AssertMsg(pRange, ("Handlers and page tables are out of sync or something! GCPhys=%RGp cbValue=%d\n", GCPhys, cbValue)); 1517 1518 if (!pRange) … … 1523 1524 Assert(!pRange->CTX_SUFF(pDevIns) || !pRange->CTX_SUFF(pDevIns)->CTX_SUFF(pCritSect)); 1524 1525 #ifdef VBOX_WITH_STATISTICS 1525 PIOMMMIOSTATS pStats = iomMMIOGetStats( &pVM->iom.s, GCPhys, pRange);1526 PIOMMMIOSTATS pStats = iomMMIOGetStats(pVM, GCPhys, pRange); 1526 1527 if (!pStats) 1527 1528 { … … 1934 1935 * Lookup the context range node the page belongs to. 1935 1936 */ 1936 PIOMMMIORANGE pRange = iomMMIOGetRange( &pVM->iom.s, GCPhys);1937 PIOMMMIORANGE pRange = iomMMIOGetRange(pVM, GCPhys); 1937 1938 AssertMsgReturn(pRange, 1938 1939 ("Handlers and page tables are out of sync or something! GCPhys=%RGp\n", GCPhys), VERR_IOM_MMIO_RANGE_NOT_FOUND); … … 1998 1999 #ifdef VBOX_STRICT 1999 2000 /* Can't lock IOM here due to potential deadlocks in the VGA device; not safe to access. */ 2000 PIOMMMIORANGE pRange = iomMMIOGetRangeUnsafe( &pVM->iom.s, GCPhys);2001 PIOMMMIORANGE pRange = iomMMIOGetRangeUnsafe(pVM, GCPhys); 2001 2002 AssertMsgReturn(pRange, 2002 2003 ("Handlers and page tables are out of sync or something! GCPhys=%RGp\n", GCPhys), VERR_IOM_MMIO_RANGE_NOT_FOUND); … … 2051 2052 #ifdef VBOX_STRICT 2052 2053 /* Can't lock IOM here due to potential deadlocks in the VGA device; not safe to access. */ 2053 PIOMMMIORANGE pRange = iomMMIOGetRangeUnsafe( &pVM->iom.s, GCPhys);2054 PIOMMMIORANGE pRange = iomMMIOGetRangeUnsafe(pVM, GCPhys); 2054 2055 AssertMsgReturn(pRange, 2055 2056 ("Handlers and page tables are out of sync or something! GCPhys=%RGp\n", GCPhys), VERR_IOM_MMIO_RANGE_NOT_FOUND); -
trunk/src/VBox/VMM/VMMR3/IOM.cpp
r35346 r37424 112 112 #include <VBox/log.h> 113 113 #include <VBox/err.h> 114 115 #include "IOMInline.h" 114 116 115 117 … … 1538 1540 */ 1539 1541 iomLock(pVM); 1540 PIOMMMIORANGE pRange = iomMMIOGetRange( &pVM->iom.s, GCPhysStart);1542 PIOMMMIORANGE pRange = iomMMIOGetRange(pVM, GCPhysStart); 1541 1543 AssertReturnStmt(pRange, iomUnlock(pVM), VERR_IOM_MMIO_RANGE_NOT_FOUND); 1542 1544 AssertReturnStmt(pRange->pDevInsR3 == pDevIns, iomUnlock(pVM), VERR_IOM_NOT_MMIO_RANGE_OWNER); … … 1594 1596 */ 1595 1597 iomLock(pVM); 1596 PIOMMMIORANGE pRange = iomMMIOGetRange( &pVM->iom.s, GCPhysStart);1598 PIOMMMIORANGE pRange = iomMMIOGetRange(pVM, GCPhysStart); 1597 1599 AssertReturnStmt(pRange, iomUnlock(pVM), VERR_IOM_MMIO_RANGE_NOT_FOUND); 1598 1600 AssertReturnStmt(pRange->pDevInsR3 == pDevIns, iomUnlock(pVM), VERR_IOM_NOT_MMIO_RANGE_OWNER); … … 1648 1650 while (GCPhys <= GCPhysLast && GCPhys >= GCPhysStart) 1649 1651 { 1650 PIOMMMIORANGE pRange = iomMMIOGetRange( &pVM->iom.s, GCPhys);1652 PIOMMMIORANGE pRange = iomMMIOGetRange(pVM, GCPhys); 1651 1653 if (!pRange) 1652 1654 { -
trunk/src/VBox/VMM/include/IOMInternal.h
r35346 r37424 428 428 #endif 429 429 430 431 /**432 * Gets the I/O port range for the specified I/O port in the current context.433 *434 * @returns Pointer to I/O port range.435 * @returns NULL if no port registered.436 *437 * @param pIOM IOM instance data.438 * @param Port Port to lookup.439 */440 DECLINLINE(CTX_SUFF(PIOMIOPORTRANGE)) iomIOPortGetRange(PIOM pIOM, RTIOPORT Port)441 {442 #ifdef IN_RING3443 if (PDMCritSectIsInitialized(&pIOM->EmtLock))444 #endif445 Assert(IOMIsLockOwner(IOM2VM(pIOM)));446 CTX_SUFF(PIOMIOPORTRANGE) pRange = (CTX_SUFF(PIOMIOPORTRANGE))RTAvlroIOPortRangeGet(&pIOM->CTX_SUFF(pTrees)->CTX_SUFF(IOPortTree), Port);447 return pRange;448 }449 450 451 /**452 * Gets the I/O port range for the specified I/O port in the HC.453 *454 * @returns Pointer to I/O port range.455 * @returns NULL if no port registered.456 *457 * @param pIOM IOM instance data.458 * @param Port Port to lookup.459 */460 DECLINLINE(PIOMIOPORTRANGER3) iomIOPortGetRangeR3(PIOM pIOM, RTIOPORT Port)461 {462 #ifdef IN_RING3463 if (PDMCritSectIsInitialized(&pIOM->EmtLock))464 #endif465 Assert(IOMIsLockOwner(IOM2VM(pIOM)));466 PIOMIOPORTRANGER3 pRange = (PIOMIOPORTRANGER3)RTAvlroIOPortRangeGet(&pIOM->CTX_SUFF(pTrees)->IOPortTreeR3, Port);467 return pRange;468 }469 470 471 /**472 * Gets the MMIO range for the specified physical address in the current context.473 *474 * @returns Pointer to MMIO range.475 * @returns NULL if address not in a MMIO range.476 *477 * @param pIOM IOM instance data.478 * @param GCPhys Physical address to lookup.479 */480 DECLINLINE(PIOMMMIORANGE) iomMMIOGetRange(PIOM pIOM, RTGCPHYS GCPhys)481 {482 #ifdef IN_RING3483 if (PDMCritSectIsInitialized(&pIOM->EmtLock))484 #endif485 Assert(IOMIsLockOwner(IOM2VM(pIOM)));486 PIOMMMIORANGE pRange = pIOM->CTX_SUFF(pMMIORangeLast);487 if ( !pRange488 || GCPhys - pRange->GCPhys >= pRange->cb)489 pIOM->CTX_SUFF(pMMIORangeLast) = pRange = (PIOMMMIORANGE)RTAvlroGCPhysRangeGet(&pIOM->CTX_SUFF(pTrees)->MMIOTree, GCPhys);490 return pRange;491 }492 493 #ifdef VBOX_STRICT494 /**495 * Gets the MMIO range for the specified physical address in the current context.496 *497 * @returns Pointer to MMIO range.498 * @returns NULL if address not in a MMIO range.499 *500 * @param pIOM IOM instance data.501 * @param GCPhys Physical address to lookup.502 */503 DECLINLINE(PIOMMMIORANGE) iomMMIOGetRangeUnsafe(PIOM pIOM, RTGCPHYS GCPhys)504 {505 PIOMMMIORANGE pRange = pIOM->CTX_SUFF(pMMIORangeLast);506 if ( !pRange507 || GCPhys - pRange->GCPhys >= pRange->cb)508 pIOM->CTX_SUFF(pMMIORangeLast) = pRange = (PIOMMMIORANGE)RTAvlroGCPhysRangeGet(&pIOM->CTX_SUFF(pTrees)->MMIOTree, GCPhys);509 return pRange;510 }511 #endif512 513 514 #ifdef VBOX_WITH_STATISTICS515 /**516 * Gets the MMIO statistics record.517 *518 * In ring-3 this will lazily create missing records, while in GC/R0 the caller has to519 * return the appropriate status to defer the operation to ring-3.520 *521 * @returns Pointer to MMIO stats.522 * @returns NULL if not found (R0/GC), or out of memory (R3).523 *524 * @param pIOM IOM instance data.525 * @param GCPhys Physical address to lookup.526 * @param pRange The MMIO range.527 */528 DECLINLINE(PIOMMMIOSTATS) iomMMIOGetStats(PIOM pIOM, RTGCPHYS GCPhys, PIOMMMIORANGE pRange)529 {530 Assert(IOMIsLockOwner(IOM2VM(pIOM)));531 /* For large ranges, we'll put everything on the first byte. */532 if (pRange->cb > PAGE_SIZE)533 GCPhys = pRange->GCPhys;534 535 PIOMMMIOSTATS pStats = pIOM->CTX_SUFF(pMMIOStatsLast);536 if ( !pStats537 || pStats->Core.Key != GCPhys)538 {539 pStats = (PIOMMMIOSTATS)RTAvloGCPhysGet(&pIOM->CTX_SUFF(pTrees)->MMIOStatTree, GCPhys);540 # ifdef IN_RING3541 if (!pStats)542 pStats = iomR3MMIOStatsCreate(IOM2VM(pIOM), GCPhys, pRange->pszDesc);543 # endif544 }545 return pStats;546 }547 #endif548 549 430 /* IOM locking helpers. */ 550 431 int iomLock(PVM pVM);
Note:
See TracChangeset
for help on using the changeset viewer.