VirtualBox

Ignore:
Timestamp:
Aug 19, 2019 7:36:29 PM (5 years ago)
Author:
vboxsync
Message:

VMM,PciRaw: Eliminate duplicate PGVM/PVMCC and PGVMCPU/PVMCPUCC parameters in ring-0 code. butref:9217

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR0/PDMR0Device.cpp

    r80334 r80346  
    6060*   Internal Functions                                                                                                           *
    6161*********************************************************************************************************************************/
    62 static bool pdmR0IsaSetIrq(PVMCC pVM, int iIrq, int iLevel, uint32_t uTagSrc);
     62static bool pdmR0IsaSetIrq(PGVM pGVM, int iIrq, int iLevel, uint32_t uTagSrc);
    6363
    6464
     
    132132    LogFlow(("pdmR0DevHlp_PCISetIrq: caller=%p/%d: pPciDev=%p:{%#x} iIrq=%d iLevel=%d\n",
    133133             pDevIns, pDevIns->iInstance, pPciDev, pPciDev->uDevFn, iIrq, iLevel));
    134     PVMCC        pVM     = pDevIns->Internal.s.pVMR0;
     134    PGVM         pGVM    = pDevIns->Internal.s.pVMR0;
    135135    PPDMPCIBUS   pPciBus = pPciDev->Int.s.pPdmBusR0;
    136136
    137     pdmLock(pVM);
     137    pdmLock(pGVM);
    138138    uint32_t uTagSrc;
    139139    if (iLevel & PDM_IRQ_LEVEL_HIGH)
    140140    {
    141         pDevIns->Internal.s.uLastIrqTag = uTagSrc = pdmCalcIrqTag(pVM, pDevIns->idTracing);
     141        pDevIns->Internal.s.uLastIrqTag = uTagSrc = pdmCalcIrqTag(pGVM, pDevIns->idTracing);
    142142        if (iLevel == PDM_IRQ_LEVEL_HIGH)
    143             VBOXVMM_PDM_IRQ_HIGH(VMMGetCpu(pVM), RT_LOWORD(uTagSrc), RT_HIWORD(uTagSrc));
     143            VBOXVMM_PDM_IRQ_HIGH(VMMGetCpu(pGVM), RT_LOWORD(uTagSrc), RT_HIWORD(uTagSrc));
    144144        else
    145             VBOXVMM_PDM_IRQ_HILO(VMMGetCpu(pVM), RT_LOWORD(uTagSrc), RT_HIWORD(uTagSrc));
     145            VBOXVMM_PDM_IRQ_HILO(VMMGetCpu(pGVM), RT_LOWORD(uTagSrc), RT_HIWORD(uTagSrc));
    146146    }
    147147    else
     
    153153        pPciBus->pfnSetIrqR0(pPciBus->pDevInsR0, pPciDev, iIrq, iLevel, uTagSrc);
    154154
    155         pdmUnlock(pVM);
     155        pdmUnlock(pGVM);
    156156
    157157        if (iLevel == PDM_IRQ_LEVEL_LOW)
    158             VBOXVMM_PDM_IRQ_LOW(VMMGetCpu(pVM), RT_LOWORD(uTagSrc), RT_HIWORD(uTagSrc));
     158            VBOXVMM_PDM_IRQ_LOW(VMMGetCpu(pGVM), RT_LOWORD(uTagSrc), RT_HIWORD(uTagSrc));
    159159    }
    160160    else
    161161    {
    162         pdmUnlock(pVM);
     162        pdmUnlock(pGVM);
    163163
    164164        /* queue for ring-3 execution. */
    165         PPDMDEVHLPTASK pTask = (PPDMDEVHLPTASK)PDMQueueAlloc(pVM->pdm.s.pDevHlpQueueR0);
     165        PPDMDEVHLPTASK pTask = (PPDMDEVHLPTASK)PDMQueueAlloc(pGVM->pdm.s.pDevHlpQueueR0);
    166166        AssertReturnVoid(pTask);
    167167
     
    171171        pTask->u.PciSetIRQ.iLevel = iLevel;
    172172        pTask->u.PciSetIRQ.uTagSrc = uTagSrc;
    173         pTask->u.PciSetIRQ.pPciDevR3 = MMHyperR0ToR3(pVM, pPciDev);
    174 
    175         PDMQueueInsertEx(pVM->pdm.s.pDevHlpQueueR0, &pTask->Core, 0);
     173        pTask->u.PciSetIRQ.pPciDevR3 = MMHyperR0ToR3(pGVM, pPciDev);
     174
     175        PDMQueueInsertEx(pGVM->pdm.s.pDevHlpQueueR0, &pTask->Core, 0);
    176176    }
    177177
     
    185185    PDMDEV_ASSERT_DEVINS(pDevIns);
    186186    LogFlow(("pdmR0DevHlp_ISASetIrq: caller=%p/%d: iIrq=%d iLevel=%d\n", pDevIns, pDevIns->iInstance, iIrq, iLevel));
    187     PVMCC pVM = pDevIns->Internal.s.pVMR0;
    188 
    189     pdmLock(pVM);
     187    PGVM pGVM = pDevIns->Internal.s.pVMR0;
     188
     189    pdmLock(pGVM);
    190190    uint32_t uTagSrc;
    191191    if (iLevel & PDM_IRQ_LEVEL_HIGH)
    192192    {
    193         pDevIns->Internal.s.uLastIrqTag = uTagSrc = pdmCalcIrqTag(pVM, pDevIns->idTracing);
     193        pDevIns->Internal.s.uLastIrqTag = uTagSrc = pdmCalcIrqTag(pGVM, pDevIns->idTracing);
    194194        if (iLevel == PDM_IRQ_LEVEL_HIGH)
    195             VBOXVMM_PDM_IRQ_HIGH(VMMGetCpu(pVM), RT_LOWORD(uTagSrc), RT_HIWORD(uTagSrc));
     195            VBOXVMM_PDM_IRQ_HIGH(VMMGetCpu(pGVM), RT_LOWORD(uTagSrc), RT_HIWORD(uTagSrc));
    196196        else
    197             VBOXVMM_PDM_IRQ_HILO(VMMGetCpu(pVM), RT_LOWORD(uTagSrc), RT_HIWORD(uTagSrc));
     197            VBOXVMM_PDM_IRQ_HILO(VMMGetCpu(pGVM), RT_LOWORD(uTagSrc), RT_HIWORD(uTagSrc));
    198198    }
    199199    else
    200200        uTagSrc = pDevIns->Internal.s.uLastIrqTag;
    201201
    202     bool fRc = pdmR0IsaSetIrq(pVM, iIrq, iLevel, uTagSrc);
     202    bool fRc = pdmR0IsaSetIrq(pGVM, iIrq, iLevel, uTagSrc);
    203203
    204204    if (iLevel == PDM_IRQ_LEVEL_LOW && fRc)
    205         VBOXVMM_PDM_IRQ_LOW(VMMGetCpu(pVM), RT_LOWORD(uTagSrc), RT_HIWORD(uTagSrc));
    206     pdmUnlock(pVM);
     205        VBOXVMM_PDM_IRQ_LOW(VMMGetCpu(pGVM), RT_LOWORD(uTagSrc), RT_HIWORD(uTagSrc));
     206    pdmUnlock(pGVM);
    207207    LogFlow(("pdmR0DevHlp_ISASetIrq: caller=%p/%d: returns void; uTagSrc=%#x\n", pDevIns, pDevIns->iInstance, uTagSrc));
    208208}
     
    214214    PDMDEV_ASSERT_DEVINS(pDevIns);
    215215    LogFlow(("pdmR0DevHlp_IoApicSendMsi: caller=%p/%d: GCPhys=%RGp uValue=%#x\n", pDevIns, pDevIns->iInstance, GCPhys, uValue));
    216     PVMCC pVM = pDevIns->Internal.s.pVMR0;
     216    PGVM pGVM = pDevIns->Internal.s.pVMR0;
    217217
    218218    uint32_t uTagSrc;
    219     pDevIns->Internal.s.uLastIrqTag = uTagSrc = pdmCalcIrqTag(pVM, pDevIns->idTracing);
    220     VBOXVMM_PDM_IRQ_HILO(VMMGetCpu(pVM), RT_LOWORD(uTagSrc), RT_HIWORD(uTagSrc));
    221 
    222     if (pVM->pdm.s.IoApic.pDevInsR0)
    223         pVM->pdm.s.IoApic.pfnSendMsiR0(pVM->pdm.s.IoApic.pDevInsR0, GCPhys, uValue, uTagSrc);
     219    pDevIns->Internal.s.uLastIrqTag = uTagSrc = pdmCalcIrqTag(pGVM, pDevIns->idTracing);
     220    VBOXVMM_PDM_IRQ_HILO(VMMGetCpu(pGVM), RT_LOWORD(uTagSrc), RT_HIWORD(uTagSrc));
     221
     222    if (pGVM->pdm.s.IoApic.pDevInsR0)
     223        pGVM->pdm.s.IoApic.pfnSendMsiR0(pGVM->pdm.s.IoApic.pDevInsR0, GCPhys, uValue, uTagSrc);
    224224    else
    225225        AssertFatalMsgFailed(("Lazy bastards!"));
     
    518518{
    519519    PDMDEV_ASSERT_DEVINS(pDevIns);
    520     PVMCC pVM = pDevIns->Internal.s.pVMR0;
     520    PGVM pGVM = pDevIns->Internal.s.pVMR0;
    521521    LogFlow(("pdmR0IoApicHlp_ApicBusDeliver: caller=%p/%d: u8Dest=%RX8 u8DestMode=%RX8 u8DeliveryMode=%RX8 uVector=%RX8 u8Polarity=%RX8 u8TriggerMode=%RX8 uTagSrc=%#x\n",
    522522             pDevIns, pDevIns->iInstance, u8Dest, u8DestMode, u8DeliveryMode, uVector, u8Polarity, u8TriggerMode, uTagSrc));
    523     return APICBusDeliver(pVM, u8Dest, u8DestMode, u8DeliveryMode, uVector, u8Polarity, u8TriggerMode, uTagSrc);
     523    return APICBusDeliver(pGVM, u8Dest, u8DestMode, u8DeliveryMode, uVector, u8Polarity, u8TriggerMode, uTagSrc);
    524524}
    525525
     
    567567    PDMDEV_ASSERT_DEVINS(pDevIns);
    568568    Log4(("pdmR0PciHlp_IsaSetIrq: iIrq=%d iLevel=%d uTagSrc=%#x\n", iIrq, iLevel, uTagSrc));
    569     PVMCC pVM = pDevIns->Internal.s.pVMR0;
    570 
    571     pdmLock(pVM);
    572     pdmR0IsaSetIrq(pVM, iIrq, iLevel, uTagSrc);
    573     pdmUnlock(pVM);
     569    PGVM pGVM = pDevIns->Internal.s.pVMR0;
     570
     571    pdmLock(pGVM);
     572    pdmR0IsaSetIrq(pGVM, iIrq, iLevel, uTagSrc);
     573    pdmUnlock(pGVM);
    574574}
    575575
     
    580580    PDMDEV_ASSERT_DEVINS(pDevIns);
    581581    Log4(("pdmR0PciHlp_IoApicSetIrq: iIrq=%d iLevel=%d uTagSrc=%#x\n", iIrq, iLevel, uTagSrc));
    582     PVMCC pVM = pDevIns->Internal.s.pVMR0;
    583 
    584     if (pVM->pdm.s.IoApic.pDevInsR0)
    585         pVM->pdm.s.IoApic.pfnSetIrqR0(pVM->pdm.s.IoApic.pDevInsR0, iIrq, iLevel, uTagSrc);
    586     else if (pVM->pdm.s.IoApic.pDevInsR3)
     582    PGVM pGVM = pDevIns->Internal.s.pVMR0;
     583
     584    if (pGVM->pdm.s.IoApic.pDevInsR0)
     585        pGVM->pdm.s.IoApic.pfnSetIrqR0(pGVM->pdm.s.IoApic.pDevInsR0, iIrq, iLevel, uTagSrc);
     586    else if (pGVM->pdm.s.IoApic.pDevInsR3)
    587587    {
    588588        /* queue for ring-3 execution. */
    589         PPDMDEVHLPTASK pTask = (PPDMDEVHLPTASK)PDMQueueAlloc(pVM->pdm.s.pDevHlpQueueR0);
     589        PPDMDEVHLPTASK pTask = (PPDMDEVHLPTASK)PDMQueueAlloc(pGVM->pdm.s.pDevHlpQueueR0);
    590590        if (pTask)
    591591        {
     
    596596            pTask->u.IoApicSetIRQ.uTagSrc = uTagSrc;
    597597
    598             PDMQueueInsertEx(pVM->pdm.s.pDevHlpQueueR0, &pTask->Core, 0);
     598            PDMQueueInsertEx(pGVM->pdm.s.pDevHlpQueueR0, &pTask->Core, 0);
    599599        }
    600600        else
     
    609609    PDMDEV_ASSERT_DEVINS(pDevIns);
    610610    Log4(("pdmR0PciHlp_IoApicSendMsi: GCPhys=%p uValue=%d uTagSrc=%#x\n", GCPhys, uValue, uTagSrc));
    611     PVMCC pVM = pDevIns->Internal.s.pVMR0;
    612     if (pVM->pdm.s.IoApic.pDevInsR0)
    613         pVM->pdm.s.IoApic.pfnSendMsiR0(pVM->pdm.s.IoApic.pDevInsR0, GCPhys, uValue, uTagSrc);
     611    PGVM pGVM = pDevIns->Internal.s.pVMR0;
     612    if (pGVM->pdm.s.IoApic.pDevInsR0)
     613        pGVM->pdm.s.IoApic.pfnSendMsiR0(pGVM->pdm.s.IoApic.pDevInsR0, GCPhys, uValue, uTagSrc);
    614614    else
    615615        AssertFatalMsgFailed(("Lazy bastards!"));
     
    784784 *
    785785 * @returns true if delivered, false if postponed.
    786  * @param   pVM         The cross context VM structure.
     786 * @param   pGVM        The global (ring-0) VM structure.
    787787 * @param   iIrq        The irq.
    788788 * @param   iLevel      The new level.
     
    791791 * @remarks The caller holds the PDM lock.
    792792 */
    793 static bool pdmR0IsaSetIrq(PVMCC pVM, int iIrq, int iLevel, uint32_t uTagSrc)
    794 {
    795     if (RT_LIKELY(    (   pVM->pdm.s.IoApic.pDevInsR0
    796                        || !pVM->pdm.s.IoApic.pDevInsR3)
    797                   &&  (   pVM->pdm.s.Pic.pDevInsR0
    798                        || !pVM->pdm.s.Pic.pDevInsR3)))
     793static bool pdmR0IsaSetIrq(PGVM pGVM, int iIrq, int iLevel, uint32_t uTagSrc)
     794{
     795    if (RT_LIKELY(    (   pGVM->pdm.s.IoApic.pDevInsR0
     796                       || !pGVM->pdm.s.IoApic.pDevInsR3)
     797                  &&  (   pGVM->pdm.s.Pic.pDevInsR0
     798                       || !pGVM->pdm.s.Pic.pDevInsR3)))
    799799    {
    800         if (pVM->pdm.s.Pic.pDevInsR0)
    801             pVM->pdm.s.Pic.pfnSetIrqR0(pVM->pdm.s.Pic.pDevInsR0, iIrq, iLevel, uTagSrc);
    802         if (pVM->pdm.s.IoApic.pDevInsR0)
    803             pVM->pdm.s.IoApic.pfnSetIrqR0(pVM->pdm.s.IoApic.pDevInsR0, iIrq, iLevel, uTagSrc);
     800        if (pGVM->pdm.s.Pic.pDevInsR0)
     801            pGVM->pdm.s.Pic.pfnSetIrqR0(pGVM->pdm.s.Pic.pDevInsR0, iIrq, iLevel, uTagSrc);
     802        if (pGVM->pdm.s.IoApic.pDevInsR0)
     803            pGVM->pdm.s.IoApic.pfnSetIrqR0(pGVM->pdm.s.IoApic.pDevInsR0, iIrq, iLevel, uTagSrc);
    804804        return true;
    805805    }
    806806
    807807    /* queue for ring-3 execution. */
    808     PPDMDEVHLPTASK pTask = (PPDMDEVHLPTASK)PDMQueueAlloc(pVM->pdm.s.pDevHlpQueueR0);
     808    PPDMDEVHLPTASK pTask = (PPDMDEVHLPTASK)PDMQueueAlloc(pGVM->pdm.s.pDevHlpQueueR0);
    809809    AssertReturn(pTask, false);
    810810
     
    815815    pTask->u.IsaSetIRQ.uTagSrc = uTagSrc;
    816816
    817     PDMQueueInsertEx(pVM->pdm.s.pDevHlpQueueR0, &pTask->Core, 0);
     817    PDMQueueInsertEx(pGVM->pdm.s.pDevHlpQueueR0, &pTask->Core, 0);
    818818    return false;
    819819}
     
    825825 * @returns See PFNPDMDEVREQHANDLERR0.
    826826 * @param   pGVM    The global (ring-0) VM structure. (For validation.)
    827  * @param   pVM     The cross context VM structure. (For validation.)
    828827 * @param   pReq    Pointer to the request buffer.
    829828 */
    830 VMMR0_INT_DECL(int) PDMR0DeviceCallReqHandler(PGVM pGVM, PVMCC pVM, PPDMDEVICECALLREQHANDLERREQ pReq)
     829VMMR0_INT_DECL(int) PDMR0DeviceCallReqHandler(PGVM pGVM, PPDMDEVICECALLREQHANDLERREQ pReq)
    831830{
    832831    /*
    833832     * Validate input and make the call.
    834833     */
    835     int rc = GVMMR0ValidateGVMandVM(pGVM, pVM);
     834    int rc = GVMMR0ValidateGVM(pGVM);
    836835    if (RT_SUCCESS(rc))
    837836    {
     
    841840        PPDMDEVINS pDevIns = pReq->pDevInsR0;
    842841        AssertPtrReturn(pDevIns, VERR_INVALID_POINTER);
    843         AssertReturn(pDevIns->Internal.s.pVMR0 == pVM, VERR_INVALID_PARAMETER);
     842        AssertReturn(pDevIns->Internal.s.pVMR0 == pGVM, VERR_INVALID_PARAMETER);
    844843
    845844        PFNPDMDEVREQHANDLERR0 pfnReqHandlerR0 = pReq->pfnReqHandlerR0;
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