VirtualBox

Changeset 37424 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Jun 12, 2011 7:28:11 PM (14 years ago)
Author:
vboxsync
Message:

IOM: Moved the inline functions out of IOMInternal.h and into IOMInline.h.

Location:
trunk/src/VBox/VMM
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/IOMAll.cpp

    r36794 r37424  
    3737#include <VBox/log.h>
    3838#include <iprt/assert.h>
     39#include "IOMInline.h"
    3940
    4041
     
    292293        ||   (unsigned)Port - (unsigned)pRange->Port >= (unsigned)pRange->cPorts)
    293294    {
    294         pRange = iomIOPortGetRange(&pVM->iom.s, Port);
     295        pRange = iomIOPortGetRange(pVM, Port);
    295296        if (pRange)
    296297            pVM->iom.s.CTX_SUFF(pRangeLastRead) = pRange;
     
    387388     * Handler in ring-3?
    388389     */
    389     PIOMIOPORTRANGER3 pRangeR3 = iomIOPortGetRangeR3(&pVM->iom.s, Port);
     390    PIOMIOPORTRANGER3 pRangeR3 = iomIOPortGetRangeR3(pVM, Port);
    390391    if (pRangeR3)
    391392    {
     
    488489        ||   (unsigned)Port - (unsigned)pRange->Port >= (unsigned)pRange->cPorts)
    489490    {
    490         pRange = iomIOPortGetRange(&pVM->iom.s, Port);
     491        pRange = iomIOPortGetRange(pVM, Port);
    491492        if (pRange)
    492493            pVM->iom.s.CTX_SUFF(pRangeLastRead) = pRange;
     
    569570     * Handler in ring-3?
    570571     */
    571     PIOMIOPORTRANGER3 pRangeR3 = iomIOPortGetRangeR3(&pVM->iom.s, Port);
     572    PIOMIOPORTRANGER3 pRangeR3 = iomIOPortGetRangeR3(pVM, Port);
    572573    if (pRangeR3)
    573574    {
     
    658659        ||   (unsigned)Port - (unsigned)pRange->Port >= (unsigned)pRange->cPorts)
    659660    {
    660         pRange = iomIOPortGetRange(&pVM->iom.s, Port);
     661        pRange = iomIOPortGetRange(pVM, Port);
    661662        if (pRange)
    662663            pVM->iom.s.CTX_SUFF(pRangeLastWrite) = pRange;
     
    738739     * Handler in ring-3?
    739740     */
    740     PIOMIOPORTRANGER3 pRangeR3 = iomIOPortGetRangeR3(&pVM->iom.s, Port);
     741    PIOMIOPORTRANGER3 pRangeR3 = iomIOPortGetRangeR3(pVM, Port);
    741742    if (pRangeR3)
    742743    {
     
    828829        ||   (unsigned)Port - (unsigned)pRange->Port >= (unsigned)pRange->cPorts)
    829830    {
    830         pRange = iomIOPortGetRange(&pVM->iom.s, Port);
     831        pRange = iomIOPortGetRange(pVM, Port);
    831832        if (pRange)
    832833            pVM->iom.s.CTX_SUFF(pRangeLastWrite) = pRange;
     
    909910     * Handler in ring-3?
    910911     */
    911     PIOMIOPORTRANGER3 pRangeR3 = iomIOPortGetRangeR3(&pVM->iom.s, Port);
     912    PIOMIOPORTRANGER3 pRangeR3 = iomIOPortGetRangeR3(pVM, Port);
    912913    if (pRangeR3)
    913914    {
  • trunk/src/VBox/VMM/VMMAll/IOMAllMMIO.cpp

    r37423 r37424  
    3636#include <VBox/vmm/vmm.h>
    3737#include <VBox/vmm/hwaccm.h>
     38#include "IOMInline.h"
    3839
    3940#include <VBox/dis.h>
     
    8182{
    8283#ifdef VBOX_WITH_STATISTICS
    83     PIOMMMIOSTATS pStats = iomMMIOGetStats(&pVM->iom.s, GCPhysFault, pRange);
     84    PIOMMMIOSTATS pStats = iomMMIOGetStats(pVM, GCPhysFault, pRange);
    8485    Assert(pStats);
    8586#endif
     
    103104{
    104105#ifdef VBOX_WITH_STATISTICS
    105     PIOMMMIOSTATS pStats = iomMMIOGetStats(&pVM->iom.s, GCPhys, pRange);
     106    PIOMMMIOSTATS pStats = iomMMIOGetStats(pVM, GCPhys, pRange);
    106107    Assert(pStats);
    107108#endif
     
    455456        PhysDst |= (RTGCUINTPTR)pu8Virt & PAGE_OFFSET_MASK;
    456457        if (    RT_SUCCESS(rc)
    457             &&  (pMMIODst = iomMMIOGetRange(&pVM->iom.s, PhysDst)))
     458            &&  (pMMIODst = iomMMIOGetRange(pVM, PhysDst)))
    458459        {
    459460            /** @todo implement per-device locks for MMIO access. */
     
    10761077    PIOMMMIORANGE pRange = (PIOMMMIORANGE)pvUser;
    10771078    Assert(pRange);
    1078     Assert(pRange == iomMMIOGetRange(&pVM->iom.s, GCPhysFault));
     1079    Assert(pRange == iomMMIOGetRange(pVM, GCPhysFault));
    10791080    /** @todo implement per-device locks for MMIO access. It can replace the IOM
    10801081     *        lock for most of the code, provided that we retake the lock while
     
    10871088     * Locate the statistics, if > PAGE_SIZE we'll use the first byte for everything.
    10881089     */
    1089     PIOMMMIOSTATS pStats = iomMMIOGetStats(&pVM->iom.s, GCPhysFault, pRange);
     1090    PIOMMMIOSTATS pStats = iomMMIOGetStats(pVM, GCPhysFault, pRange);
    10901091    if (!pStats)
    10911092    {
     
    13091310        return VINF_IOM_HC_MMIO_READ_WRITE;
    13101311#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));
    13121313    iomUnlock(pVM);
    13131314    return VBOXSTRICTRC_VAL(rcStrict);
     
    13401341
    13411342    Assert(pRange);
    1342     Assert(pRange == iomMMIOGetRange(&pVM->iom.s, GCPhysFault));
     1343    Assert(pRange == iomMMIOGetRange(pVM, GCPhysFault));
    13431344    /** @todo implement per-device locks for MMIO access. It can replace the IOM
    13441345     *        lock for most of the code, provided that we retake the lock while
     
    13841385     * Lookup the current context range node and statistics.
    13851386     */
    1386     PIOMMMIORANGE pRange = iomMMIOGetRange(&pVM->iom.s, GCPhys);
     1387    PIOMMMIORANGE pRange = iomMMIOGetRange(pVM, GCPhys);
    13871388    AssertMsg(pRange, ("Handlers and page tables are out of sync or something! GCPhys=%RGp cbValue=%d\n", GCPhys, cbValue));
    13881389    if (!pRange)
     
    13941395    Assert(!pRange->CTX_SUFF(pDevIns) || !pRange->CTX_SUFF(pDevIns)->CTX_SUFF(pCritSect));
    13951396#ifdef VBOX_WITH_STATISTICS
    1396     PIOMMMIOSTATS pStats = iomMMIOGetStats(&pVM->iom.s, GCPhys, pRange);
     1397    PIOMMMIOSTATS pStats = iomMMIOGetStats(pVM, GCPhys, pRange);
    13971398    if (!pStats)
    13981399    {
     
    15131514     * Lookup the current context range node.
    15141515     */
    1515     PIOMMMIORANGE pRange = iomMMIOGetRange(&pVM->iom.s, GCPhys);
     1516    PIOMMMIORANGE pRange = iomMMIOGetRange(pVM, GCPhys);
    15161517    AssertMsg(pRange, ("Handlers and page tables are out of sync or something! GCPhys=%RGp cbValue=%d\n", GCPhys, cbValue));
    15171518    if (!pRange)
     
    15231524    Assert(!pRange->CTX_SUFF(pDevIns) || !pRange->CTX_SUFF(pDevIns)->CTX_SUFF(pCritSect));
    15241525#ifdef VBOX_WITH_STATISTICS
    1525     PIOMMMIOSTATS pStats = iomMMIOGetStats(&pVM->iom.s, GCPhys, pRange);
     1526    PIOMMMIOSTATS pStats = iomMMIOGetStats(pVM, GCPhys, pRange);
    15261527    if (!pStats)
    15271528    {
     
    19341935     * Lookup the context range node the page belongs to.
    19351936     */
    1936     PIOMMMIORANGE pRange = iomMMIOGetRange(&pVM->iom.s, GCPhys);
     1937    PIOMMMIORANGE pRange = iomMMIOGetRange(pVM, GCPhys);
    19371938    AssertMsgReturn(pRange,
    19381939                    ("Handlers and page tables are out of sync or something! GCPhys=%RGp\n", GCPhys), VERR_IOM_MMIO_RANGE_NOT_FOUND);
     
    19981999#ifdef VBOX_STRICT
    19992000    /* 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);
    20012002    AssertMsgReturn(pRange,
    20022003            ("Handlers and page tables are out of sync or something! GCPhys=%RGp\n", GCPhys), VERR_IOM_MMIO_RANGE_NOT_FOUND);
     
    20512052#ifdef VBOX_STRICT
    20522053    /* 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);
    20542055    AssertMsgReturn(pRange,
    20552056            ("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  
    112112#include <VBox/log.h>
    113113#include <VBox/err.h>
     114
     115#include "IOMInline.h"
    114116
    115117
     
    15381540     */
    15391541    iomLock(pVM);
    1540     PIOMMMIORANGE pRange = iomMMIOGetRange(&pVM->iom.s, GCPhysStart);
     1542    PIOMMMIORANGE pRange = iomMMIOGetRange(pVM, GCPhysStart);
    15411543    AssertReturnStmt(pRange, iomUnlock(pVM), VERR_IOM_MMIO_RANGE_NOT_FOUND);
    15421544    AssertReturnStmt(pRange->pDevInsR3 == pDevIns, iomUnlock(pVM), VERR_IOM_NOT_MMIO_RANGE_OWNER);
     
    15941596     */
    15951597    iomLock(pVM);
    1596     PIOMMMIORANGE pRange = iomMMIOGetRange(&pVM->iom.s, GCPhysStart);
     1598    PIOMMMIORANGE pRange = iomMMIOGetRange(pVM, GCPhysStart);
    15971599    AssertReturnStmt(pRange, iomUnlock(pVM), VERR_IOM_MMIO_RANGE_NOT_FOUND);
    15981600    AssertReturnStmt(pRange->pDevInsR3 == pDevIns, iomUnlock(pVM), VERR_IOM_NOT_MMIO_RANGE_OWNER);
     
    16481650    while (GCPhys <= GCPhysLast && GCPhys >= GCPhysStart)
    16491651    {
    1650         PIOMMMIORANGE pRange = iomMMIOGetRange(&pVM->iom.s, GCPhys);
     1652        PIOMMMIORANGE pRange = iomMMIOGetRange(pVM, GCPhys);
    16511653        if (!pRange)
    16521654        {
  • trunk/src/VBox/VMM/include/IOMInternal.h

    r35346 r37424  
    428428#endif
    429429
    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_RING3
    443     if (PDMCritSectIsInitialized(&pIOM->EmtLock))
    444 #endif
    445         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_RING3
    463     if (PDMCritSectIsInitialized(&pIOM->EmtLock))
    464 #endif
    465         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_RING3
    483     if (PDMCritSectIsInitialized(&pIOM->EmtLock))
    484 #endif
    485         Assert(IOMIsLockOwner(IOM2VM(pIOM)));
    486     PIOMMMIORANGE pRange = pIOM->CTX_SUFF(pMMIORangeLast);
    487     if (    !pRange
    488         ||  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_STRICT
    494 /**
    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 (    !pRange
    507         ||  GCPhys - pRange->GCPhys >= pRange->cb)
    508         pIOM->CTX_SUFF(pMMIORangeLast) = pRange = (PIOMMMIORANGE)RTAvlroGCPhysRangeGet(&pIOM->CTX_SUFF(pTrees)->MMIOTree, GCPhys);
    509     return pRange;
    510 }
    511 #endif
    512 
    513 
    514 #ifdef VBOX_WITH_STATISTICS
    515 /**
    516  * Gets the MMIO statistics record.
    517  *
    518  * In ring-3 this will lazily create missing records, while in GC/R0 the caller has to
    519  * 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 (    !pStats
    537         ||  pStats->Core.Key != GCPhys)
    538     {
    539         pStats = (PIOMMMIOSTATS)RTAvloGCPhysGet(&pIOM->CTX_SUFF(pTrees)->MMIOStatTree, GCPhys);
    540 # ifdef IN_RING3
    541         if (!pStats)
    542             pStats = iomR3MMIOStatsCreate(IOM2VM(pIOM), GCPhys, pRange->pszDesc);
    543 # endif
    544     }
    545     return pStats;
    546 }
    547 #endif
    548 
    549430/* IOM locking helpers. */
    550431int     iomLock(PVM pVM);
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