VirtualBox

Changeset 81536 in vbox


Ignore:
Timestamp:
Oct 25, 2019 11:42:49 AM (5 years ago)
Author:
vboxsync
Message:

DevOHCI: Moved the in-flight and done-queue into the OHCIR3 structure. bugref:9218

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/USB/DevOHCI.cpp

    r81535 r81536  
    337337    uint64_t            cTicksPerUsbTick;
    338338
     339    /** Detected canceled isochronous URBs. */
     340    STAMCOUNTER         StatCanceledIsocUrbs;
     341    /** Detected canceled general URBs. */
     342    STAMCOUNTER         StatCanceledGenUrbs;
     343    /** Dropped URBs (endpoint halted, or URB canceled). */
     344    STAMCOUNTER         StatDroppedUrbs;
     345    /** Profiling ohciR3FrameBoundaryTimer. */
     346    STAMPROFILE         StatTimer;
     347
     348    /** This member and all the following are not part of saved state. */
     349    uint64_t            SavedStateEnd;
     350
     351    /** VM timer frequency used for frame timer calculations. */
     352    uint64_t            u64TimerHz;
     353    /** Idle detection flag; must be cleared at start of frame */
     354    bool                fIdle;
     355    /** A flag indicating that the bulk list may have in-flight URBs. */
     356    bool                fBulkNeedsCleaning;
     357
     358    bool                afAlignment3[2];
     359    uint32_t            Alignment4;     /**< Align size on a 8 byte boundary. */
     360
     361    /** Critical section synchronising interrupt handling. */
     362    PDMCRITSECT         CsIrq;
     363
     364    /** The MMIO region handle. */
     365    IOMMMIOHANDLE       hMmio;
     366} OHCI;
     367
     368
     369/**
     370 * OHCI device data, ring-3.
     371 */
     372typedef struct OHCIR3
     373{
     374    /** The root hub, ring-3 portion.   */
     375    OHCIROOTHUBR3       RootHub;
     376    /** Pointer to the device instance - R3 ptr. */
     377    PPDMDEVINSR3        pDevInsR3;
     378
    339379    /** Number of in-flight TDs. */
    340380    unsigned            cInFlight;
     
    344384    {
    345385        /** Address of the transport descriptor. */
    346         uint32_t    GCPhysTD;
     386        uint32_t            GCPhysTD;
    347387        /** Flag indicating an inactive (not-linked) URB. */
    348         bool        fInactive;
     388        bool                fInactive;
    349389        /** Pointer to the URB. */
    350390        R3PTRTYPE(PVUSBURB) pUrb;
     
    361401    {
    362402        /** Address of the transport descriptor. */
    363         uint32_t GCPhysTD;
     403        uint32_t            GCPhysTD;
    364404    } aInDoneQueue[64];
    365405    /** When the tail of the done queue was added.
     
    371411#endif
    372412
    373     /** Detected canceled isochronous URBs. */
    374     STAMCOUNTER         StatCanceledIsocUrbs;
    375     /** Detected canceled general URBs. */
    376     STAMCOUNTER         StatCanceledGenUrbs;
    377     /** Dropped URBs (endpoint halted, or URB canceled). */
    378     STAMCOUNTER         StatDroppedUrbs;
    379     /** Profiling ohciR3FrameBoundaryTimer. */
    380     STAMPROFILE         StatTimer;
    381 
    382     /** This member and all the following are not part of saved state. */
    383     uint64_t            SavedStateEnd;
    384 
    385     /** VM timer frequency used for frame timer calculations. */
    386     uint64_t            u64TimerHz;
    387     /** Idle detection flag; must be cleared at start of frame */
    388     bool                fIdle;
    389     /** A flag indicating that the bulk list may have in-flight URBs. */
    390     bool                fBulkNeedsCleaning;
    391 
    392     bool                afAlignment3[2];
    393     uint32_t            Alignment4;     /**< Align size on a 8 byte boundary. */
    394 
    395     /** Critical section synchronising interrupt handling. */
    396     PDMCRITSECT         CsIrq;
    397 
    398     /** The MMIO region handle. */
    399     IOMMMIOHANDLE       hMmio;
    400 } OHCI;
    401 
    402 
    403 /**
    404  * OHCI device data, ring-3.
    405  */
    406 typedef struct OHCIR3
    407 {
    408     /** The root hub, ring-3 portion.   */
    409     OHCIROOTHUBR3           RootHub;
    410     /** Pointer to the device instance - R3 ptr. */
    411     PPDMDEVINSR3            pDevInsR3;
    412 
    413     /** Pointer to state load data. */
    414     R3PTRTYPE(POHCILOAD)    pLoad;
    415 
    416413#ifdef VBOX_WITH_OHCI_PHYS_READ_CACHE
    417414    /** Last read physical page for caching ED reads in the framer thread. */
    418     OHCIPAGECACHE           CacheED;
     415    OHCIPAGECACHE       CacheED;
    419416    /** Last read physical page for caching TD reads in the framer thread. */
    420     OHCIPAGECACHE           CacheTD;
     417    OHCIPAGECACHE       CacheTD;
    421418#endif
    422419
    423420    /** Critical section to synchronize the framer and URB completion handler. */
    424     RTCRITSECT              CritSect;
     421    RTCRITSECT          CritSect;
     422
     423    /** Pointer to state load data. */
     424    R3PTRTYPE(POHCILOAD) pLoad;
    425425} OHCIR3;
    426426/** Pointer to ring-3 OHCI state. */
     
    906906static DECLCALLBACK(bool)   ohciR3RhXferError(PVUSBIROOTHUBPORT pInterface, PVUSBURB pUrb);
    907907
    908 static int                  ohciR3InFlightFind(POHCI pThis, uint32_t GCPhysTD);
     908static int                  ohciR3InFlightFind(POHCICC pThisCC, uint32_t GCPhysTD);
    909909# if defined(VBOX_STRICT) || defined(LOG_ENABLED)
    910 static int                  ohciR3InDoneQueueFind(POHCI pThis, uint32_t GCPhysTD);
     910static int                  ohciR3InDoneQueueFind(POHCICC pThisCC, uint32_t GCPhysTD);
    911911# endif
    912912static DECLCALLBACK(void)   ohciR3LoadReattachDevices(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser);
     
    12621262     */
    12631263    pThisCC->RootHub.pIRhConn->pfnCancelAllUrbs(pThisCC->RootHub.pIRhConn);
    1264     Assert(pThis->cInFlight == 0);
     1264    Assert(pThisCC->cInFlight == 0);
    12651265
    12661266    /*
     
    17561756 * Core TD queue dumper. LOG_ENABLED builds only.
    17571757 */
    1758 DECLINLINE(void) ohciR3DumpTdQueueCore(PPDMDEVINS pDevIns, POHCI pThis, uint32_t GCPhysHead, uint32_t GCPhysTail, bool fFull)
     1758DECLINLINE(void) ohciR3DumpTdQueueCore(PPDMDEVINS pDevIns, POHCICC pThisCC, uint32_t GCPhysHead, uint32_t GCPhysTail, bool fFull)
    17591759{
    17601760    uint32_t GCPhys = GCPhysHead;
     
    17641764        OHCITD Td;
    17651765        Log4(("%#010x%s%s", GCPhys,
    1766               GCPhys && ohciR3InFlightFind(pThis, GCPhys) >= 0 ? "~" : "",
    1767               GCPhys && ohciR3InDoneQueueFind(pThis, GCPhys) >= 0 ? "^" : ""));
     1766              GCPhys && ohciR3InFlightFind(pThisCC, GCPhys) >= 0 ? "~" : "",
     1767              GCPhys && ohciR3InDoneQueueFind(pThisCC, GCPhys) >= 0 ? "^" : ""));
    17681768        if (GCPhys == 0 || GCPhys == GCPhysTail)
    17691769            break;
     
    17931793 * Dumps a TD queue. LOG_ENABLED builds only.
    17941794 */
    1795 DECLINLINE(void) ohciR3DumpTdQueue(PPDMDEVINS pDevIns, POHCI pThis, uint32_t GCPhysHead, const char *pszMsg)
     1795DECLINLINE(void) ohciR3DumpTdQueue(PPDMDEVINS pDevIns, POHCICC pThisCC, uint32_t GCPhysHead, const char *pszMsg)
    17961796{
    17971797    if (pszMsg)
    17981798        Log4(("%s: ", pszMsg));
    1799     ohciR3DumpTdQueueCore(pDevIns, pThis, GCPhysHead, 0, true);
     1799    ohciR3DumpTdQueueCore(pDevIns, pThisCC, GCPhysHead, 0, true);
    18001800    Log4(("\n"));
    18011801}
     
    18041804 * Core ITD queue dumper. LOG_ENABLED builds only.
    18051805 */
    1806 DECLINLINE(void) ohciR3DumpITdQueueCore(PPDMDEVINS pDevIns, POHCI pThis, uint32_t GCPhysHead, uint32_t GCPhysTail, bool fFull)
     1806DECLINLINE(void) ohciR3DumpITdQueueCore(PPDMDEVINS pDevIns, POHCICC pThisCC, uint32_t GCPhysHead, uint32_t GCPhysTail, bool fFull)
    18071807{
    18081808    RT_NOREF(fFull);
     
    18131813        OHCIITD ITd;
    18141814        Log4(("%#010x%s%s", GCPhys,
    1815               GCPhys && ohciR3InFlightFind(pThis, GCPhys) >= 0 ? "~" : "",
    1816               GCPhys && ohciR3InDoneQueueFind(pThis, GCPhys) >= 0 ? "^" : ""));
     1815              GCPhys && ohciR3InFlightFind(pThisCC, GCPhys) >= 0 ? "~" : "",
     1816              GCPhys && ohciR3InDoneQueueFind(pThisCC, GCPhys) >= 0 ? "^" : ""));
    18171817        if (GCPhys == 0 || GCPhys == GCPhysTail)
    18181818            break;
     
    18421842 * Dumps a ED list. LOG_ENABLED builds only.
    18431843 */
    1844 DECLINLINE(void) ohciR3DumpEdList(PPDMDEVINS pDevIns, POHCI pThis, uint32_t GCPhysHead, const char *pszMsg, bool fTDs)
     1844DECLINLINE(void) ohciR3DumpEdList(PPDMDEVINS pDevIns, POHCICC pThisCC, uint32_t GCPhysHead, const char *pszMsg, bool fTDs)
    18451845{
    18461846    RT_NOREF(fTDs);
     
    18761876        {
    18771877            if (Ed.hwinfo & ED_HWINFO_ISO)
    1878                 ohciR3DumpITdQueueCore(pDevIns, pThis, Ed.HeadP & ED_PTR_MASK, Ed.TailP & ED_PTR_MASK, false);
     1878                ohciR3DumpITdQueueCore(pDevIns, pThisCC, Ed.HeadP & ED_PTR_MASK, Ed.TailP & ED_PTR_MASK, false);
    18791879            else
    1880                 ohciR3DumpTdQueueCore(pDevIns, pThis, Ed.HeadP & ED_PTR_MASK, Ed.TailP & ED_PTR_MASK, false);
     1880                ohciR3DumpTdQueueCore(pDevIns, pThisCC, Ed.HeadP & ED_PTR_MASK, Ed.TailP & ED_PTR_MASK, false);
    18811881            Log4(("}"));
    18821882        }
     
    18921892
    18931893
    1894 DECLINLINE(int) ohciR3InFlightFindFree(POHCI pThis, const int iStart)
     1894DECLINLINE(int) ohciR3InFlightFindFree(POHCICC pThisCC, const int iStart)
    18951895{
    18961896    unsigned i = iStart;
    1897     while (i < RT_ELEMENTS(pThis->aInFlight))
    1898     {
    1899         if (pThis->aInFlight[i].GCPhysTD == 0)
     1897    while (i < RT_ELEMENTS(pThisCC->aInFlight))
     1898    {
     1899        if (pThisCC->aInFlight[i].GCPhysTD == 0)
    19001900            return i;
    19011901        i++;
     
    19041904    while (i-- > 0)
    19051905    {
    1906         if (pThis->aInFlight[i].GCPhysTD == 0)
     1906        if (pThisCC->aInFlight[i].GCPhysTD == 0)
    19071907            return i;
    19081908    }
     
    19141914 * Record an in-flight TD.
    19151915 *
    1916  * @param   pThis       OHCI instance data.
     1916 * @param   pThis       OHCI instance data, shared edition.
     1917 * @param   pThisCC     OHCI instance data, ring-3 edition.
    19171918 * @param   GCPhysTD    Physical address of the TD.
    19181919 * @param   pUrb        The URB.
    19191920 */
    1920 static void ohciR3InFlightAdd(POHCI pThis, uint32_t GCPhysTD, PVUSBURB pUrb)
    1921 {
    1922     int i = ohciR3InFlightFindFree(pThis, (GCPhysTD >> 4) % RT_ELEMENTS(pThis->aInFlight));
     1921static void ohciR3InFlightAdd(POHCI pThis, POHCICC pThisCC, uint32_t GCPhysTD, PVUSBURB pUrb)
     1922{
     1923    int i = ohciR3InFlightFindFree(pThisCC, (GCPhysTD >> 4) % RT_ELEMENTS(pThisCC->aInFlight));
    19231924    if (i >= 0)
    19241925    {
     
    19261927        pUrb->pHci->u32FrameNo = pThis->HcFmNumber;
    19271928# endif
    1928         pThis->aInFlight[i].GCPhysTD = GCPhysTD;
    1929         pThis->aInFlight[i].pUrb = pUrb;
    1930         pThis->cInFlight++;
     1929        pThisCC->aInFlight[i].GCPhysTD = GCPhysTD;
     1930        pThisCC->aInFlight[i].pUrb = pUrb;
     1931        pThisCC->cInFlight++;
    19311932        return;
    19321933    }
    1933     AssertMsgFailed(("Out of space cInFlight=%d!\n", pThis->cInFlight));
     1934    AssertMsgFailed(("Out of space cInFlight=%d!\n", pThisCC->cInFlight));
     1935    RT_NOREF(pThis);
    19341936}
    19351937
     
    19381940 * Record in-flight TDs for an URB.
    19391941 *
    1940  * @param   pThis       OHCI instance data.
     1942 * @param   pThis       OHCI instance data, shared edition.
     1943 * @param   pThisCC     OHCI instance data, ring-3 edition.
    19411944 * @param   pUrb        The URB.
    19421945 */
    1943 static void ohciR3InFlightAddUrb(POHCI pThis, PVUSBURB pUrb)
     1946static void ohciR3InFlightAddUrb(POHCI pThis, POHCICC pThisCC, PVUSBURB pUrb)
    19441947{
    19451948    for (unsigned iTd = 0; iTd < pUrb->pHci->cTds; iTd++)
    1946         ohciR3InFlightAdd(pThis, pUrb->paTds[iTd].TdAddr, pUrb);
     1949        ohciR3InFlightAdd(pThis, pThisCC, pUrb->paTds[iTd].TdAddr, pUrb);
    19471950}
    19481951
     
    19531956 * @returns Index of the record.
    19541957 * @returns -1 if not found.
    1955  * @param   pThis       OHCI instance data.
     1958 * @param   pThisCC     OHCI instance data, ring-3 edition.
    19561959 * @param   GCPhysTD    Physical address of the TD.
    19571960 * @remark  This has to be fast.
    19581961 */
    1959 static int ohciR3InFlightFind(POHCI pThis, uint32_t GCPhysTD)
    1960 {
    1961     unsigned cLeft = pThis->cInFlight;
    1962     unsigned i = (GCPhysTD >> 4) % RT_ELEMENTS(pThis->aInFlight);
     1962static int ohciR3InFlightFind(POHCICC pThisCC, uint32_t GCPhysTD)
     1963{
     1964    unsigned cLeft = pThisCC->cInFlight;
     1965    unsigned i = (GCPhysTD >> 4) % RT_ELEMENTS(pThisCC->aInFlight);
    19631966    const int iLast = i;
    1964     while (i < RT_ELEMENTS(pThis->aInFlight))
    1965     {
    1966         if (pThis->aInFlight[i].GCPhysTD == GCPhysTD)
     1967    while (i < RT_ELEMENTS(pThisCC->aInFlight))
     1968    {
     1969        if (pThisCC->aInFlight[i].GCPhysTD == GCPhysTD)
    19671970            return i;
    1968         if (pThis->aInFlight[i].GCPhysTD)
     1971        if (pThisCC->aInFlight[i].GCPhysTD)
    19691972            if (cLeft-- <= 1)
    19701973                return -1;
     
    19741977    while (i-- > 0)
    19751978    {
    1976         if (pThis->aInFlight[i].GCPhysTD == GCPhysTD)
     1979        if (pThisCC->aInFlight[i].GCPhysTD == GCPhysTD)
    19771980            return i;
    1978         if (pThis->aInFlight[i].GCPhysTD)
     1981        if (pThisCC->aInFlight[i].GCPhysTD)
    19791982            if (cLeft-- <= 1)
    19801983                return -1;
     
    19881991 *
    19891992 * @returns true if in flight, false if not.
    1990  * @param   pThis       OHCI instance data.
     1993 * @param   pThisCC     OHCI instance data, ring-3 edition.
    19911994 * @param   GCPhysTD    Physical address of the TD.
    19921995 */
    1993 static bool ohciR3IsTdInFlight(POHCI pThis, uint32_t GCPhysTD)
    1994 {
    1995     return ohciR3InFlightFind(pThis, GCPhysTD) >= 0;
     1996static bool ohciR3IsTdInFlight(POHCICC pThisCC, uint32_t GCPhysTD)
     1997{
     1998    return ohciR3InFlightFind(pThisCC, GCPhysTD) >= 0;
    19961999}
    19972000
     
    20012004 * @returns pointer to URB if TD is in flight.
    20022005 * @returns NULL if not in flight.
    2003  * @param   pThis       OHCI instance data.
     2006 * @param   pThisCC     OHCI instance data, ring-3 edition.
    20042007 * @param   GCPhysTD    Physical address of the TD.
    20052008 */
    2006 static PVUSBURB ohciR3TdInFlightUrb(POHCI pThis, uint32_t GCPhysTD)
     2009static PVUSBURB ohciR3TdInFlightUrb(POHCICC pThisCC, uint32_t GCPhysTD)
    20072010{
    20082011    int i;
    20092012
    2010     i = ohciR3InFlightFind(pThis, GCPhysTD);
     2013    i = ohciR3InFlightFind(pThisCC, GCPhysTD);
    20112014    if ( i >= 0 )
    2012         return pThis->aInFlight[i].pUrb;
     2015        return pThisCC->aInFlight[i].pUrb;
    20132016    return NULL;
    20142017}
     
    20192022 * @returns 0 if found. For logged builds this is the number of frames the TD has been in-flight.
    20202023 * @returns -1 if not found.
    2021  * @param   pThis       OHCI instance data.
     2024 * @param   pThis       OHCI instance data, shared edition (for logging).
     2025 * @param   pThisCC     OHCI instance data, ring-3 edition.
    20222026 * @param   GCPhysTD    Physical address of the TD.
    20232027 */
    2024 static int ohciR3InFlightRemove(POHCI pThis, uint32_t GCPhysTD)
    2025 {
    2026     int i = ohciR3InFlightFind(pThis, GCPhysTD);
     2028static int ohciR3InFlightRemove(POHCI pThis, POHCICC pThisCC, uint32_t GCPhysTD)
     2029{
     2030    int i = ohciR3InFlightFind(pThisCC, GCPhysTD);
    20272031    if (i >= 0)
    20282032    {
    20292033# ifdef LOG_ENABLED
    2030         const int cFramesInFlight = pThis->HcFmNumber - pThis->aInFlight[i].pUrb->pHci->u32FrameNo;
     2034        const int cFramesInFlight = pThis->HcFmNumber - pThisCC->aInFlight[i].pUrb->pHci->u32FrameNo;
    20312035# else
    2032         const int cFramesInFlight = 0;
     2036        const int cFramesInFlight = 0; RT_NOREF(pThis);
    20332037# endif
    20342038        Log2(("ohciR3InFlightRemove: reaping TD=%#010x %d frames (%#010x-%#010x)\n",
    2035               GCPhysTD, cFramesInFlight, pThis->aInFlight[i].pUrb->pHci->u32FrameNo, pThis->HcFmNumber));
    2036         pThis->aInFlight[i].GCPhysTD = 0;
    2037         pThis->aInFlight[i].pUrb = NULL;
    2038         pThis->cInFlight--;
     2039              GCPhysTD, cFramesInFlight, pThisCC->aInFlight[i].pUrb->pHci->u32FrameNo, pThis->HcFmNumber));
     2040        pThisCC->aInFlight[i].GCPhysTD = 0;
     2041        pThisCC->aInFlight[i].pUrb = NULL;
     2042        pThisCC->cInFlight--;
    20392043        return cFramesInFlight;
    20402044    }
     
    20492053 * @returns 0 if found. For logged builds this is the number of frames the TD has been in-flight.
    20502054 * @returns -1 if not found.
    2051  * @param   pThis       OHCI instance data.
     2055 * @param   pThis       OHCI instance data, shared edition (for logging).
     2056 * @param   pThisCC     OHCI instance data, ring-3 edition.
    20522057 * @param   pUrb        The URB.
    20532058 */
    2054 static int ohciR3InFlightRemoveUrb(POHCI pThis, PVUSBURB pUrb)
    2055 {
    2056     int cFramesInFlight = ohciR3InFlightRemove(pThis, pUrb->paTds[0].TdAddr);
     2059static int ohciR3InFlightRemoveUrb(POHCI pThis, POHCICC pThisCC, PVUSBURB pUrb)
     2060{
     2061    int cFramesInFlight = ohciR3InFlightRemove(pThis, pThisCC, pUrb->paTds[0].TdAddr);
    20572062    if (pUrb->pHci->cTds > 1)
    20582063    {
    20592064        for (unsigned iTd = 1; iTd < pUrb->pHci->cTds; iTd++)
    2060             if (ohciR3InFlightRemove(pThis, pUrb->paTds[iTd].TdAddr) < 0)
     2065            if (ohciR3InFlightRemove(pThis, pThisCC, pUrb->paTds[iTd].TdAddr) < 0)
    20612066                cFramesInFlight = -1;
    20622067    }
     
    20692074/**
    20702075 * Empties the in-done-queue.
    2071  * @param   pThis       OHCI instance data.
    2072  */
    2073 static void ohciR3InDoneQueueZap(POHCI pThis)
    2074 {
    2075     pThis->cInDoneQueue = 0;
     2076 * @param   pThisCC     OHCI instance data, ring-3 edition.
     2077 */
     2078static void ohciR3InDoneQueueZap(POHCICC pThisCC)
     2079{
     2080    pThisCC->cInDoneQueue = 0;
    20762081}
    20772082
     
    20802085 * @returns >= 0 on success.
    20812086 * @returns -1 if not found.
    2082  * @param   pThis       OHCI instance data.
     2087 * @param   pThisCC     OHCI instance data, ring-3 edition.
    20832088 * @param   GCPhysTD    Physical address of the TD.
    20842089 */
    2085 static int ohciR3InDoneQueueFind(POHCI pThis, uint32_t GCPhysTD)
    2086 {
    2087     unsigned i = pThis->cInDoneQueue;
     2090static int ohciR3InDoneQueueFind(POHCICC pThisCC, uint32_t GCPhysTD)
     2091{
     2092    unsigned i = pThisCC->cInDoneQueue;
    20882093    while (i-- > 0)
    2089         if (pThis->aInDoneQueue[i].GCPhysTD == GCPhysTD)
     2094        if (pThisCC->aInDoneQueue[i].GCPhysTD == GCPhysTD)
    20902095            return i;
    20912096    return -1;
     
    20942099/**
    20952100 * Checks that the specified TD is not in the done queue.
    2096  * @param   pThis       OHCI instance data.
     2101 * @param   pThisCC     OHCI instance data, ring-3 edition.
    20972102 * @param   GCPhysTD    Physical address of the TD.
    20982103 */
    2099 static bool ohciR3InDoneQueueCheck(POHCI pThis, uint32_t GCPhysTD)
    2100 {
    2101     int i = ohciR3InDoneQueueFind(pThis, GCPhysTD);
     2104static bool ohciR3InDoneQueueCheck(POHCICC pThisCC, uint32_t GCPhysTD)
     2105{
     2106    int i = ohciR3InDoneQueueFind(pThisCC, GCPhysTD);
    21022107#  if 0
    21032108    /* This condition has been observed with the USB tablet emulation or with
     
    21202125/**
    21212126 * Adds a TD to the in-done-queue tracking, checking that it's not there already.
    2122  * @param   pThis       OHCI instance data.
     2127 * @param   pThisCC     OHCI instance data, ring-3 edition.
    21232128 * @param   GCPhysTD    Physical address of the TD.
    21242129 */
    2125 static void ohciR3InDoneQueueAdd(POHCI pThis, uint32_t GCPhysTD)
    2126 {
    2127     Assert(pThis->cInDoneQueue + 1 <= RT_ELEMENTS(pThis->aInDoneQueue));
    2128     if (ohciR3InDoneQueueCheck(pThis, GCPhysTD))
    2129         pThis->aInDoneQueue[pThis->cInDoneQueue++].GCPhysTD = GCPhysTD;
     2130static void ohciR3InDoneQueueAdd(POHCICC pThisCC, uint32_t GCPhysTD)
     2131{
     2132    Assert(pThisCC->cInDoneQueue + 1 <= RT_ELEMENTS(pThisCC->aInDoneQueue));
     2133    if (ohciR3InDoneQueueCheck(pThisCC, GCPhysTD))
     2134        pThisCC->aInDoneQueue[pThisCC->cInDoneQueue++].GCPhysTD = GCPhysTD;
    21302135}
    21312136#  endif /* VBOX_STRICT */
     
    25662571 * In general, all URBs should have status OK.
    25672572 */
    2568 static void ohciR3RhXferCompleteIsochronousURB(PPDMDEVINS pDevIns, POHCI pThis, PVUSBURB pUrb /*, POHCIED pEd , int cFmAge*/)
     2573static void ohciR3RhXferCompleteIsochronousURB(PPDMDEVINS pDevIns, POHCI pThis, POHCICC pThisCC, PVUSBURB pUrb
     2574                                               /*, POHCIED pEd , int cFmAge*/)
    25692575{
    25702576    /*
     
    26862692# ifdef LOG_ENABLED
    26872693        if (!pThis->done)
    2688             pThis->u32FmDoneQueueTail = pThis->HcFmNumber;
     2694            pThisCC->u32FmDoneQueueTail = pThis->HcFmNumber;
    26892695#  ifdef VBOX_STRICT
    2690         ohciR3InDoneQueueAdd(pThis, ITdAddr);
     2696        ohciR3InDoneQueueAdd(pThisCC, ITdAddr);
    26912697#  endif
    26922698# endif
     
    27122718        ohciR3WriteITd(pDevIns, pThis, ITdAddr, pITd, "retired");
    27132719    }
     2720    RT_NOREF(pThisCC);
    27142721}
    27152722
     
    27192726 * a URB made up of general TDs.
    27202727 */
    2721 static void ohciR3RhXferCompleteGeneralURB(PPDMDEVINS pDevIns, POHCI pThis, PVUSBURB pUrb, POHCIED pEd, int cFmAge)
     2728static void ohciR3RhXferCompleteGeneralURB(PPDMDEVINS pDevIns, POHCI pThis, POHCICC pThisCC, PVUSBURB pUrb,
     2729                                           POHCIED pEd, int cFmAge)
    27222730{
    27232731    RT_NOREF(cFmAge);
     
    28362844# ifdef LOG_ENABLED
    28372845        if (!pThis->done)
    2838             pThis->u32FmDoneQueueTail = pThis->HcFmNumber;
     2846            pThisCC->u32FmDoneQueueTail = pThis->HcFmNumber;
    28392847#  ifdef VBOX_STRICT
    2840         ohciR3InDoneQueueAdd(pThis, TdAddr);
     2848        ohciR3InDoneQueueAdd(pThisCC, TdAddr);
    28412849#  endif
    28422850# endif
     
    28582866            break;
    28592867    }
     2868    RT_NOREF(pThisCC);
    28602869}
    28612870
     
    28802889    ohciR3Lock(pThisCC);
    28812890
    2882     int cFmAge = ohciR3InFlightRemoveUrb(pThis, pUrb);
     2891    int cFmAge = ohciR3InFlightRemoveUrb(pThis, pThisCC, pUrb);
    28832892
    28842893    /* Do nothing requiring memory access if the HC encountered an unrecoverable error. */
     
    29362945         */
    29372946        if (pUrb->enmType == VUSBXFERTYPE_ISOC)
    2938             ohciR3RhXferCompleteIsochronousURB(pDevIns, pThis, pUrb /*, &Ed , cFmAge*/);
     2947            ohciR3RhXferCompleteIsochronousURB(pDevIns, pThis, pThisCC, pUrb /*, &Ed , cFmAge*/);
    29392948        else
    2940             ohciR3RhXferCompleteGeneralURB(pDevIns, pThis, pUrb, &Ed, cFmAge);
     2949            ohciR3RhXferCompleteGeneralURB(pDevIns, pThis, pThisCC, pUrb, &Ed, cFmAge);
    29412950
    29422951        /* finally write back the endpoint descriptor. */
     
    31043113     * Submit the URB.
    31053114     */
    3106     ohciR3InFlightAdd(pThis, TdAddr, pUrb);
     3115    ohciR3InFlightAdd(pThis, pThisCC, TdAddr, pUrb);
    31073116    Log(("%s: ohciR3ServiceTd: submitting TdAddr=%#010x EdAddr=%#010x cbData=%#x\n",
    31083117         pUrb->pszDesc, TdAddr, EdAddr, pUrb->cbData));
     
    31173126    Log(("ohciR3ServiceTd: failed submitting TdAddr=%#010x EdAddr=%#010x pUrb=%p!!\n",
    31183127         TdAddr, EdAddr, pUrb));
    3119     ohciR3InFlightRemove(pThis, TdAddr);
     3128    ohciR3InFlightRemove(pThis, pThisCC, TdAddr);
    31203129    VUSBIRhFreeUrb(pThisCC->RootHub.pIRhConn, pUrb);
    31213130    return false;
     
    31333142     */
    31343143    uint32_t TdAddr = pEd->HeadP & ED_PTR_MASK;
    3135     if (ohciR3IsTdInFlight(pThis, TdAddr))
     3144    if (ohciR3IsTdInFlight(pThisCC, TdAddr))
    31363145        return false;
    31373146# if defined(VBOX_STRICT) || defined(LOG_ENABLED)
    3138     ohciR3InDoneQueueCheck(pThis, TdAddr);
     3147    ohciR3InDoneQueueCheck(pThisCC, TdAddr);
    31393148# endif
    31403149    return ohciR3ServiceTd(pDevIns, pThis, pThisCC, enmType, pEd, EdAddr, TdAddr, &TdAddr, pszListName);
     
    32773286     * Submit the URB.
    32783287     */
    3279     ohciR3InFlightAddUrb(pThis, pUrb);
     3288    ohciR3InFlightAddUrb(pThis, pThisCC, pUrb);
    32803289    Log(("%s: ohciR3ServiceTdMultiple: submitting cbData=%#x EdAddr=%#010x cTds=%d TdAddr0=%#010x\n",
    32813290         pUrb->pszDesc, pUrb->cbData, EdAddr, cTds, TdAddr));
     
    32893298    Log(("ohciR3ServiceTdMultiple: failed submitting pUrb=%p cbData=%#x EdAddr=%#010x cTds=%d TdAddr0=%#010x - rc=%Rrc\n",
    32903299         pUrb, cbTotal, EdAddr, cTds, TdAddr, rc));
    3291     ohciR3InFlightRemoveUrb(pThis, pUrb);
     3300    ohciR3InFlightRemoveUrb(pThis, pThisCC, pUrb);
    32923301    VUSBIRhFreeUrb(pThisCC->RootHub.pIRhConn, pUrb);
    32933302    return false;
     
    32983307 * Service the head TD of an endpoint.
    32993308 */
    3300 static bool ohciR3ServiceHeadTdMultiple(PPDMDEVINS pDevIns, POHCI pThis, VUSBXFERTYPE enmType, PCOHCIED pEd, uint32_t EdAddr,
    3301                                         const char *pszListName)
     3309static bool ohciR3ServiceHeadTdMultiple(PPDMDEVINS pDevIns, POHCI pThis, POHCICC pThisCC, VUSBXFERTYPE enmType,
     3310                                        PCOHCIED pEd, uint32_t EdAddr, const char *pszListName)
    33023311{
    33033312    /*
     
    33053314     */
    33063315    uint32_t TdAddr = pEd->HeadP & ED_PTR_MASK;
    3307     if (ohciR3IsTdInFlight(pThis, TdAddr))
     3316    if (ohciR3IsTdInFlight(pThisCC, TdAddr))
    33083317        return false;
    33093318# if defined(VBOX_STRICT) || defined(LOG_ENABLED)
    3310     ohciR3InDoneQueueCheck(pThis, TdAddr);
     3319    ohciR3InDoneQueueCheck(pThisCC, TdAddr);
    33113320# endif
    33123321    return ohciR3ServiceTdMultiple(pDevIns, pThis, enmType, pEd, EdAddr, TdAddr, &TdAddr, pszListName);
     
    33183327 * that belongs to the past.
    33193328 */
    3320 static bool ohciR3ServiceIsochronousTdUnlink(PPDMDEVINS pDevIns, POHCI pThis, POHCIITD pITd, uint32_t ITdAddr,
     3329static bool ohciR3ServiceIsochronousTdUnlink(PPDMDEVINS pDevIns, POHCI pThis, POHCICC pThisCC, POHCIITD pITd, uint32_t ITdAddr,
    33213330                                             uint32_t ITdAddrPrev, PVUSBURB pUrb, POHCIED pEd, uint32_t EdAddr)
    33223331{
     
    33313340    {
    33323341        /* Get validate the previous TD */
    3333         int iInFlightPrev = ohciR3InFlightFind(pThis, ITdAddrPrev);
     3342        int iInFlightPrev = ohciR3InFlightFind(pThisCC, ITdAddrPrev);
    33343343        AssertMsgReturn(iInFlightPrev >= 0, ("ITdAddr=%#RX32\n", ITdAddrPrev), false);
    3335         PVUSBURB pUrbPrev = pThis->aInFlight[iInFlightPrev].pUrb;
     3344        PVUSBURB pUrbPrev = pThisCC->aInFlight[iInFlightPrev].pUrb;
    33363345        if (ohciR3HasUrbBeenCanceled(pDevIns, pThis, pUrbPrev, pEd)) /* ensures the copy is correct. */
    33373346            return false;
     
    35233532     * Submit the URB.
    35243533     */
    3525     ohciR3InFlightAdd(pThis, ITdAddr, pUrb);
     3534    ohciR3InFlightAdd(pThis, pThisCC, ITdAddr, pUrb);
    35263535    Log(("%s: ohciR3ServiceIsochronousTd: submitting cbData=%#x cIsocPkts=%d EdAddr=%#010x TdAddr=%#010x SF=%#x (%#x)\n",
    35273536         pUrb->pszDesc, pUrb->cbData, pUrb->cIsocPkts, EdAddr, ITdAddr, pITd->HwInfo & ITD_HWINFO_SF, pThis->HcFmNumber));
     
    35353544    Log(("ohciR3ServiceIsochronousTd: failed submitting pUrb=%p cbData=%#x EdAddr=%#010x cTds=%d ITdAddr0=%#010x - rc=%Rrc\n",
    35363545         pUrb, cbTotal, EdAddr, 1, ITdAddr, rc));
    3537     ohciR3InFlightRemove(pThis, ITdAddr);
     3546    ohciR3InFlightRemove(pThis, pThisCC, ITdAddr);
    35383547    VUSBIRhFreeUrb(pThisCC->RootHub.pIRhConn, pUrb);
    35393548    return false;
     
    36023611                &&  (uint16_t)u32NextFrame != (uint16_t)(ITd.HwInfo & ITD_HWINFO_SF))
    36033612                break;
    3604             if (ohciR3InFlightFind(pThis, ITdAddr) < 0)
     3613            if (ohciR3InFlightFind(pThisCC, ITdAddr) < 0)
    36053614                if (!ohciR3ServiceIsochronousTd(pDevIns, pThis, pThisCC, &ITd, ITdAddr, R < 0 ? 0 : R, pEd, EdAddr))
    36063615                    break;
     
    36243633             * time will show.
    36253634             */
    3626             int iInFlight = ohciR3InFlightFind(pThis, ITdAddr);
     3635            int iInFlight = ohciR3InFlightFind(pThisCC, ITdAddr);
    36273636            if (iInFlight >= 0)
    36283637                ITdAddrPrev = ITdAddr;
    3629             else if (!ohciR3ServiceIsochronousTdUnlink(pDevIns, pThis, &ITd, ITdAddr, ITdAddrPrev, NULL, pEd, EdAddr))
     3638            else if (!ohciR3ServiceIsochronousTdUnlink(pDevIns, pThis, pThisCC, &ITd, ITdAddr, ITdAddrPrev, NULL, pEd, EdAddr))
    36303639            {
    36313640                Log(("ohciR3ServiceIsochronousEndpoint: Failed unlinking old ITD.\n"));
     
    36963705# ifdef LOG_ENABLED
    36973706    if (g_fLogBulkEPs)
    3698         ohciR3DumpEdList(pDevIns, pThis, pThis->bulk_head, "Bulk before", true);
     3707        ohciR3DumpEdList(pDevIns, pThisCC, pThis->bulk_head, "Bulk before", true);
    36993708    if (pThis->bulk_cur)
    37003709        Log(("ohciR3ServiceBulkList: bulk_cur=%#010x before listprocessing!!! HCD have positioned us!!!\n", pThis->bulk_cur));
     
    37353744             * on a bulk endpoint.
    37363745             */
    3737             ohciR3ServiceHeadTdMultiple(pDevIns, pThis, VUSBXFERTYPE_BULK, &Ed, EdAddr, "Bulk");
     3746            ohciR3ServiceHeadTdMultiple(pDevIns, pThis, pThisCC, VUSBXFERTYPE_BULK, &Ed, EdAddr, "Bulk");
    37383747# else
    37393748            /*
     
    37723781                 */
    37733782                uint32_t TdAddr = Ed.HeadP & ED_PTR_MASK;
    3774                 PVUSBURB pUrb = ohciR3TdInFlightUrb(pThis, TdAddr);
     3783                PVUSBURB pUrb = ohciR3TdInFlightUrb(pThisCC, TdAddr);
    37753784                if (pUrb)
    37763785                    pThisCC->RootHub.pIRhConn->pfnCancelUrbsEp(pThisCC->RootHub.pIRhConn, pUrb);
     
    37853794# ifdef LOG_ENABLED
    37863795    if (g_fLogBulkEPs)
    3787         ohciR3DumpEdList(pDevIns, pThis, pThis->bulk_head, "Bulk after ", true);
     3796        ohciR3DumpEdList(pDevIns, pThisCC, pThis->bulk_head, "Bulk after ", true);
    37883797# endif
    37893798}
     
    38013810# ifdef LOG_ENABLED
    38023811    if (g_fLogBulkEPs)
    3803         ohciR3DumpEdList(pDevIns, pThis, pThis->bulk_head, "Bulk before", true);
     3812        ohciR3DumpEdList(pDevIns, pThisCC, pThis->bulk_head, "Bulk before", true);
    38043813    if (pThis->bulk_cur)
    38053814        Log(("ohciR3UndoBulkList: bulk_cur=%#010x before list processing!!! HCD has positioned us!!!\n", pThis->bulk_cur));
     
    38193828        {
    38203829            uint32_t TdAddr = Ed.HeadP & ED_PTR_MASK;
    3821             if (ohciR3IsTdInFlight(pThis, TdAddr))
     3830            if (ohciR3IsTdInFlight(pThisCC, TdAddr))
    38223831            {
    38233832                LogFlow(("ohciR3UndoBulkList: Ed=%#010RX32 Ed.TailP=%#010RX32 UNDO\n", EdAddr, Ed.TailP));
    3824                 PVUSBURB pUrb = ohciR3TdInFlightUrb(pThis, TdAddr);
     3833                PVUSBURB pUrb = ohciR3TdInFlightUrb(pThisCC, TdAddr);
    38253834                if (pUrb)
    38263835                    pThisCC->RootHub.pIRhConn->pfnCancelUrbsEp(pThisCC->RootHub.pIRhConn, pUrb);
     
    38433852# ifdef LOG_ENABLED
    38443853    if (g_fLogControlEPs)
    3845         ohciR3DumpEdList(pDevIns, pThis, pThis->ctrl_head, "Ctrl before", true);
     3854        ohciR3DumpEdList(pDevIns, pThisCC, pThis->ctrl_head, "Ctrl before", true);
    38463855    if (pThis->ctrl_cur)
    38473856        Log(("ohciR3ServiceCtrlList: ctrl_cur=%010x before list processing!!! HCD have positioned us!!!\n", pThis->ctrl_cur));
     
    38793888            {
    38803889                if (    !ohciR3ServiceHeadTd(pDevIns, pThis, pThisCC, VUSBXFERTYPE_CTRL, &Ed, EdAddr, "Control")
    3881                     ||  ohciR3IsTdInFlight(pThis, Ed.HeadP & ED_PTR_MASK))
     3890                    ||  ohciR3IsTdInFlight(pThisCC, Ed.HeadP & ED_PTR_MASK))
    38823891                {
    38833892                    pThis->status |= OHCI_STATUS_CLF;
     
    38993908# ifdef LOG_ENABLED
    39003909    if (g_fLogControlEPs)
    3901         ohciR3DumpEdList(pDevIns, pThis, pThis->ctrl_head, "Ctrl after ", true);
     3910        ohciR3DumpEdList(pDevIns, pThisCC, pThis->ctrl_head, "Ctrl after ", true);
    39023911# endif
    39033912}
     
    39263935        char sz[48];
    39273936        RTStrPrintf(sz, sizeof(sz), "Int%02x before", iList);
    3928         ohciR3DumpEdList(pDevIns, pThis, EdAddrHead, sz, true);
     3937        ohciR3DumpEdList(pDevIns, pThisCC, EdAddrHead, sz, true);
    39293938    }
    39303939# endif
     
    39543963                 * Presently we will only process the head URB on an interrupt endpoint.
    39553964                 */
    3956                 ohciR3ServiceHeadTdMultiple(pDevIns, pThis, VUSBXFERTYPE_INTR, &Ed, EdAddr, "Periodic");
     3965                ohciR3ServiceHeadTdMultiple(pDevIns, pThis, pThisCC, VUSBXFERTYPE_INTR, &Ed, EdAddr, "Periodic");
    39573966            }
    39583967            else if (pThis->ctl & OHCI_CTL_IE)
     
    39753984                 */
    39763985                uint32_t TdAddr = Ed.HeadP & ED_PTR_MASK;
    3977                 PVUSBURB pUrb = ohciR3TdInFlightUrb(pThis, TdAddr);
     3986                PVUSBURB pUrb = ohciR3TdInFlightUrb(pThisCC, TdAddr);
    39783987                if (pUrb)
    39793988                    pThisCC->RootHub.pIRhConn->pfnCancelUrbsEp(pThisCC->RootHub.pIRhConn, pUrb);
     
    39893998        char sz[48];
    39903999        RTStrPrintf(sz, sizeof(sz), "Int%02x after ", iList);
    3991         ohciR3DumpEdList(pDevIns, pThis, EdAddrHead, sz, true);
     4000        ohciR3DumpEdList(pDevIns, pThisCC, EdAddrHead, sz, true);
    39924001    }
    39934002# endif
     
    40004009 * @param   pThis   The OHCI instance data.
    40014010 */
    4002 static void ohciR3UpdateHCCA(PPDMDEVINS pDevIns, POHCI pThis)
     4011static void ohciR3UpdateHCCA(PPDMDEVINS pDevIns, POHCI pThis, POHCICC pThisCC)
    40034012{
    40044013    OCHIHCCA hcca;
     
    40234032
    40244033        Log(("ohci: Writeback Done (%#010x) on frame %#x (age %#x)\n", hcca.done,
    4025              pThis->HcFmNumber, pThis->HcFmNumber - pThis->u32FmDoneQueueTail));
     4034             pThis->HcFmNumber, pThis->HcFmNumber - pThisCC->u32FmDoneQueueTail));
    40264035# ifdef LOG_ENABLED
    4027         ohciR3DumpTdQueue(pDevIns, pThis, hcca.done & ED_PTR_MASK, "DoneQueue");
     4036        ohciR3DumpTdQueue(pDevIns, pThisCC, hcca.done & ED_PTR_MASK, "DoneQueue");
    40284037# endif
    40294038        Assert(RT_OFFSETOF(OCHIHCCA, done) == 4);
    40304039# if defined(VBOX_STRICT) || defined(LOG_ENABLED)
    4031         ohciR3InDoneQueueZap(pThis);
     4040        ohciR3InDoneQueueZap(pThisCC);
    40324041# endif
    40334042        fWriteDoneHeadInterrupt = true;
     
    40384047    if (fWriteDoneHeadInterrupt)
    40394048        ohciR3SetInterrupt(pDevIns, pThis, OHCI_INTR_WRITE_DONE_HEAD);
     4049    RT_NOREF(pThisCC);
    40404050}
    40414051
     
    40474057 * they might "steal" data destined for another URB.
    40484058 */
    4049 static void ohciR3CancelOrphanedURBs(PPDMDEVINS pDevIns, POHCI pThis)
     4059static void ohciR3CancelOrphanedURBs(PPDMDEVINS pDevIns, POHCI pThis, POHCICC pThisCC)
    40504060{
    40514061    bool fValidHCCA = !(    pThis->hcca >= OHCI_HCCA_MASK
     
    40594069     * there's nothing to do.
    40604070     */
    4061     if (!fValidHCCA || !pThis->cInFlight)
     4071    if (!fValidHCCA || !pThisCC->cInFlight)
    40624072        return;
    40634073
    40644074    /* Initially mark all in-flight URBs as inactive. */
    4065     for (i = 0, cLeft = pThis->cInFlight; cLeft && i < RT_ELEMENTS(pThis->aInFlight); i++)
    4066     {
    4067         if (pThis->aInFlight[i].pUrb)
     4075    for (i = 0, cLeft = pThisCC->cInFlight; cLeft && i < RT_ELEMENTS(pThisCC->aInFlight); i++)
     4076    {
     4077        if (pThisCC->aInFlight[i].pUrb)
    40684078        {
    4069             pThis->aInFlight[i].fInactive = true;
     4079            pThisCC->aInFlight[i].fInactive = true;
    40704080            cLeft--;
    40714081        }
     
    40774087    uint32_t au32HCCA[OHCI_HCCA_NUM_INTR];
    40784088    ohciR3GetDWords(pDevIns, pThis->hcca, au32HCCA, OHCI_HCCA_NUM_INTR);
    4079     POHCICC pThisCC = PDMINS_2_DATA_CC(pDevIns, POHCICC);
    40804089# endif
    40814090
     
    41194128                {
    41204129                    ohciR3ReadTd(pDevIns, TdAddr, &Td);
    4121                     j = ohciR3InFlightFind(pThis, TdAddr);
     4130                    j = ohciR3InFlightFind(pThisCC, TdAddr);
    41224131                    if (j > -1)
    4123                         pThis->aInFlight[j].fInactive = false;
     4132                        pThisCC->aInFlight[j].fInactive = false;
    41244133                    TdAddr = Td.NextTD & ED_PTR_MASK;
    41254134                    /* See #8125.
     
    41444153     * to be canceled.
    41454154     */
    4146     for (i = 0, cLeft = pThis->cInFlight; cLeft && i < RT_ELEMENTS(pThis->aInFlight); i++)
    4147     {
    4148         if (pThis->aInFlight[i].pUrb)
     4155    for (i = 0, cLeft = pThisCC->cInFlight; cLeft && i < RT_ELEMENTS(pThisCC->aInFlight); i++)
     4156    {
     4157        if (pThisCC->aInFlight[i].pUrb)
    41494158        {
    41504159            cLeft--;
    4151             pUrb = pThis->aInFlight[i].pUrb;
    4152             if (pThis->aInFlight[i].fInactive
     4160            pUrb = pThisCC->aInFlight[i].pUrb;
     4161            if (   pThisCC->aInFlight[i].fInactive
    41534162                && pUrb->enmState == VUSBURBSTATE_IN_FLIGHT
    41544163                && pUrb->enmType != VUSBXFERTYPE_CTRL)
     
    41874196     */
    41884197    if (fValidHCCA)
    4189         ohciR3UpdateHCCA(pDevIns, pThis);
     4198        ohciR3UpdateHCCA(pDevIns, pThis, pThisCC);
    41904199# endif
    41914200
     
    43004309
    43014310        /* Clean up any URBs that have been removed. */
    4302         ohciR3CancelOrphanedURBs(pDevIns, pThis);
     4311        ohciR3CancelOrphanedURBs(pDevIns, pThis, pThisCC);
    43034312
    43044313        /* Start the next frame. */
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