VirtualBox

Changeset 82109 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Nov 22, 2019 8:24:21 PM (5 years ago)
Author:
vboxsync
Message:

DevVGA: Splitting up the VGASTATE structure. bugref:9218

Location:
trunk/src/VBox/Devices/Graphics
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.cpp

    r82089 r82109  
    548548*********************************************************************************************************************************/
    549549#ifdef IN_RING3
    550 static void vmsvgaR3SetTraces(PVGASTATE pThis, bool fTraces);
     550static void vmsvgaR3SetTraces(PPDMDEVINS pDevIns, PVGASTATE pThis, bool fTraces);
    551551static int vmsvgaR3LoadExecFifo(PCPDMDEVHLPR3 pHlp, PVGASTATE pThis, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass);
    552552static int vmsvgaR3SaveExecFifo(PCPDMDEVHLPR3 pHlp, PVGASTATE pThis, PSSMHANDLE pSSM);
     
    575575 *
    576576 * @returns Index register string or "UNKNOWN"
    577  * @param   pThis       VMSVGA State
     577 * @param   pThis       The shared VGA/VMSVGA state.
    578578 * @param   idxReg      The index register.
    579579 */
     
    718718DECLCALLBACK(void) vmsvgaR3PortSetViewport(PPDMIDISPLAYPORT pInterface, uint32_t idScreen, uint32_t x, uint32_t y, uint32_t cx, uint32_t cy)
    719719{
    720     PVGASTATE pThis = RT_FROM_MEMBER(pInterface, VGASTATE, IPort);
     720    PVGASTATECC pThisCC = RT_FROM_MEMBER(pInterface, VGASTATECC, IPort);
     721    PVGASTATE   pThis   = PDMDEVINS_2_DATA(pThisCC->pDevIns, PVGASTATE);
    721722
    722723    Log(("vmsvgaPortSetViewPort: screen %d (%d,%d)(%d,%d)\n", idScreen, x, y, cx, cy));
     
    772773 * @returns VBox status code.
    773774 * @param   pDevIns     The device instance.
    774  * @param   pThis       VMSVGA State
     775 * @param   pThis       The shared VGA/VMSVGA state.
    775776 * @param   pu32        Where to store the read value
    776777 */
    777778static int vmsvgaReadPort(PPDMDEVINS pDevIns, PVGASTATE pThis, uint32_t *pu32)
    778779{
     780#ifdef IN_RING3
     781    PVGASTATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
     782#endif
    779783    int rc = VINF_SUCCESS;
    780784    *pu32 = 0;
     
    823827                rc = VINF_IOM_R3_IOPORT_READ;
    824828#else
    825                 *pu32 = pThis->pDrv->cx;
     829                *pu32 = pThisCC->pDrv->cx;
    826830#endif
    827831            }
     
    840844                rc = VINF_IOM_R3_IOPORT_READ;
    841845#else
    842                 *pu32 = pThis->pDrv->cy;
     846                *pu32 = pThisCC->pDrv->cy;
    843847#endif
    844848            }
     
    884888                rc = VINF_IOM_R3_IOPORT_READ;
    885889#else
    886                 *pu32 = pThis->pDrv->cBits;
     890                *pu32 = pThisCC->pDrv->cBits;
    887891#endif
    888892            }
     
    899903                rc = VINF_IOM_R3_IOPORT_READ;
    900904#else
    901                 *pu32 = (pThis->pDrv->cBits + 7) & ~7;
     905                *pu32 = (pThisCC->pDrv->cBits + 7) & ~7;
    902906#endif
    903907            }
     
    926930                break;
    927931#else
    928                 uBpp = pThis->pDrv->cBits;
     932                uBpp = pThisCC->pDrv->cBits;
    929933#endif
    930934            }
     
    989993                rc = VINF_IOM_R3_IOPORT_READ;
    990994#else
    991                 *pu32 = pThis->pDrv->cbScanline;
     995                *pu32 = pThisCC->pDrv->cbScanline;
    992996#endif
    993997            }
     
    10271031            }
    10281032            else
    1029                 *pu32 = RT_MAX(0x100000, (uint32_t)pThis->pDrv->cy * pThis->pDrv->cbScanline);
     1033                *pu32 = RT_MAX(0x100000, (uint32_t)pThisCC->pDrv->cy * pThisCC->pDrv->cbScanline);
    10301034
    10311035            *pu32 = RT_MIN(pThis->vram_size, *pu32);
    1032             Log(("h=%d w=%d bpp=%d\n", pThis->pDrv->cy, pThis->pDrv->cx, pThis->pDrv->cBits));
     1036            Log(("h=%d w=%d bpp=%d\n", pThisCC->pDrv->cy, pThisCC->pDrv->cx, pThisCC->pDrv->cBits));
    10331037#endif
    10341038            break;
     
    10761080                PVMSVGAR3STATE pSVGAState = pThis->svga.pSvgaR3State;
    10771081                STAM_REL_PROFILE_START(&pSVGAState->StatBusyDelayEmts, EmtDelay);
    1078                 PVM         pVM   = PDMDevHlpGetVM(pThis->pDevInsR3);
    1079                 VMCPUID     idCpu = PDMDevHlpGetCurrentCpuId(pThis->pDevInsR3);
     1082                PVM         pVM   = PDMDevHlpGetVM(pDevIns);
     1083                VMCPUID     idCpu = PDMDevHlpGetCurrentCpuId(pDevIns);
    10801084                VMCPUSET_ATOMIC_ADD(&pSVGAState->BusyDelayedEmts, idCpu);
    10811085                ASMAtomicIncU32(&pSVGAState->cBusyDelayedEmts);
     
    11071111                         *        code in VMEmt.cpp here, otherwise all kind of EMT interaction will
    11081112                         *        suffer when the guest is polling on a busy FIFO. */
    1109                         uint64_t cNsMaxWait = TMVirtualSyncGetNsToDeadline(PDMDevHlpGetVM(pThis->pDevInsR3));
     1113                        uint64_t cNsMaxWait = TMVirtualSyncGetNsToDeadline(PDMDevHlpGetVM(pDevIns));
    11101114                        if (cNsMaxWait >= RT_NS_100US)
    11111115                            RTSemEventMultiWaitEx(pSVGAState->hBusyDelayedEmts,
     
    12881292 *
    12891293 * @returns VBox status code.
    1290  * @param   pThis       VMSVGA State
     1294 * @param   pThis       The shared VGA state.
     1295 * @param   pThisCC     The ring-3 VGA state.
    12911296 */
    1292 static int vmsvgaR3ChangeMode(PVGASTATE pThis)
     1297static int vmsvgaR3ChangeMode(PVGASTATE pThis, PVGASTATECC pThisCC)
    12931298{
    12941299    int rc;
     
    12991304    PVMSVGAR3STATE pSVGAState = pThis->svga.pSvgaR3State;
    13001305
    1301     pThis->pDrv->pfnLFBModeChange(pThis->pDrv, true);
     1306    pThisCC->pDrv->pfnLFBModeChange(pThisCC->pDrv, true);
    13021307
    13031308    if (pThis->svga.fGFBRegisters)
     
    13921397        }
    13931398
    1394         rc = pThis->pDrv->pfnVBVAResize(pThis->pDrv, &view, &screen, pThis->CTX_SUFF(vram_ptr), /*fResetInputMapping=*/ true);
     1399        rc = pThisCC->pDrv->pfnVBVAResize(pThisCC->pDrv, &view, &screen, pThisCC->pbVRam, /*fResetInputMapping=*/ true);
    13951400        AssertRC(rc);
    13961401    }
     
    14171422}
    14181423
    1419 int vmsvgaR3UpdateScreen(PVGASTATE pThis, VMSVGASCREENOBJECT *pScreen, int x, int y, int w, int h)
     1424int vmsvgaR3UpdateScreen(PVGASTATECC pThisCC, VMSVGASCREENOBJECT *pScreen, int x, int y, int w, int h)
    14201425{
    14211426    VBVACMDHDR cmd;
     
    14251430    cmd.h = (uint16_t)h;
    14261431
    1427     pThis->pDrv->pfnVBVAUpdateBegin(pThis->pDrv, pScreen->idScreen);
    1428     pThis->pDrv->pfnVBVAUpdateProcess(pThis->pDrv, pScreen->idScreen, &cmd, sizeof(cmd));
    1429     pThis->pDrv->pfnVBVAUpdateEnd(pThis->pDrv, pScreen->idScreen,
    1430                                   pScreen->xOrigin + x, pScreen->yOrigin + y, w, h);
     1432    pThisCC->pDrv->pfnVBVAUpdateBegin(pThisCC->pDrv, pScreen->idScreen);
     1433    pThisCC->pDrv->pfnVBVAUpdateProcess(pThisCC->pDrv, pScreen->idScreen, &cmd, sizeof(cmd));
     1434    pThisCC->pDrv->pfnVBVAUpdateEnd(pThisCC->pDrv, pScreen->idScreen,
     1435                                    pScreen->xOrigin + x, pScreen->yOrigin + y, w, h);
    14311436
    14321437    return VINF_SUCCESS;
     
    14641469 * width/bpp.
    14651470 *
    1466  * @param   pThis       VMSVGA State
     1471 * @param   pThis       The shared VGA/VMSVGA state.
    14671472 */
    14681473DECLINLINE(void) vmsvgaHCUpdatePitch(PVGASTATE pThis)
     
    15051510 *
    15061511 * @returns Strict VBox status code.
    1507  * @param   pThis       VMSVGA State
     1512 * @param   pDevIns     The device instance.
     1513 * @param   pThis       The shared VGA/VMSVGA state.
     1514 * @param   pThisC      The VGA/VMSVGA state for the current context.
    15081515 * @param   u32         Value to write
    15091516 */
    1510 static VBOXSTRICTRC vmsvgaWritePort(PPDMDEVINS pDevIns, PVGASTATE pThis, uint32_t u32)
     1517static VBOXSTRICTRC vmsvgaWritePort(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC, uint32_t u32)
    15111518{
    15121519#ifdef IN_RING3
     
    15141521#endif
    15151522    VBOXSTRICTRC rc = VINF_SUCCESS;
     1523    RT_NOREF(pThisCC);
    15161524
    15171525    /* Rough index register validation. */
     
    15571565                pThis->svga.u32SVGAId = u32;
    15581566            else
    1559                 PDMDevHlpDBGFStop(pThis->CTX_SUFF(pDevIns), RT_SRC_POS, "Trying to set SVGA_REG_ID to %#x (%d)\n", u32, u32);
     1567                PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "Trying to set SVGA_REG_ID to %#x (%d)\n", u32, u32);
    15601568            break;
    15611569
     
    15681576                /* Make a backup copy of the first 512kb in order to save font data etc. */
    15691577                /** @todo should probably swap here, rather than copy + zero */
    1570                 memcpy(pThis->svga.pbVgaFrameBufferR3, pThis->vram_ptrR3, VMSVGA_VGA_FB_BACKUP_SIZE);
    1571                 memset(pThis->vram_ptrR3, 0, VMSVGA_VGA_FB_BACKUP_SIZE);
     1578                memcpy(pThis->svga.pbVgaFrameBufferR3, pThisCC->pbVRam, VMSVGA_VGA_FB_BACKUP_SIZE);
     1579                memset(pThisCC->pbVRam, 0, VMSVGA_VGA_FB_BACKUP_SIZE);
    15721580            }
    15731581
     
    15801588                {
    15811589                    /* Keep the current mode. */
    1582                     pThis->svga.uWidth  = pThis->pDrv->cx;
    1583                     pThis->svga.uHeight = pThis->pDrv->cy;
    1584                     pThis->svga.uBpp    = (pThis->pDrv->cBits + 7) & ~7;
     1590                    pThis->svga.uWidth  = pThisCC->pDrv->cx;
     1591                    pThis->svga.uHeight = pThisCC->pDrv->cy;
     1592                    pThis->svga.uBpp    = (pThisCC->pDrv->cBits + 7) & ~7;
    15851593                }
    15861594
     
    15961604
    15971605                /* Disable or enable dirty page tracking according to the current fTraces value. */
    1598                 vmsvgaR3SetTraces(pThis, !!pThis->svga.fTraces);
     1606                vmsvgaR3SetTraces(pDevIns, pThis, !!pThis->svga.fTraces);
    15991607
    16001608                /* bird: Whatever this is was added to make screenshot work, ask sunlover should explain... */
    16011609                for (uint32_t idScreen = 0; idScreen < pThis->cMonitors; ++idScreen)
    1602                     pThis->pDrv->pfnVBVAEnable(pThis->pDrv, idScreen, NULL /*pHostFlags*/);
     1610                    pThisCC->pDrv->pfnVBVAEnable(pThisCC->pDrv, idScreen, NULL /*pHostFlags*/);
    16031611            }
    16041612            else
    16051613            {
    16061614                /* Restore the text mode backup. */
    1607                 memcpy(pThis->vram_ptrR3, pThis->svga.pbVgaFrameBufferR3, VMSVGA_VGA_FB_BACKUP_SIZE);
    1608 
    1609                 pThis->pDrv->pfnLFBModeChange(pThis->pDrv, false);
     1615                memcpy(pThisCC->pbVRam, pThis->svga.pbVgaFrameBufferR3, VMSVGA_VGA_FB_BACKUP_SIZE);
     1616
     1617                pThisCC->pDrv->pfnLFBModeChange(pThisCC->pDrv, false);
    16101618
    16111619                /* Enable dirty page tracking again when going into legacy mode. */
    1612                 vmsvgaR3SetTraces(pThis, true);
     1620                vmsvgaR3SetTraces(pDevIns, pThis, true);
    16131621
    16141622                /* bird: Whatever this is was added to make screenshot work, ask sunlover should explain... */
    16151623                for (uint32_t idScreen = 0; idScreen < pThis->cMonitors; ++idScreen)
    1616                     pThis->pDrv->pfnVBVADisable(pThis->pDrv, idScreen);
     1624                    pThisCC->pDrv->pfnVBVADisable(pThisCC->pDrv, idScreen);
    16171625
    16181626                /* Clear the pitch lock. */
     
    16831691            if (!pThis->svga.fConfigured)
    16841692                pThis->svga.fTraces = true;
    1685             vmsvgaR3SetTraces(pThis, !!pThis->svga.fTraces);
     1693            vmsvgaR3SetTraces(pDevIns, pThis, !!pThis->svga.fTraces);
    16861694#else
    16871695            rc = VINF_IOM_R3_IOPORT_WRITE;
     
    17351743            {
    17361744                Log(("SVGA_REG_IRQMASK: Trigger interrupt with status %x\n", pThis->svga.u32IrqStatus));
    1737                 PDMDevHlpPCISetIrqNoWait(pThis->CTX_SUFF(pDevIns), 0, 1);
     1745                PDMDevHlpPCISetIrqNoWait(pDevIns, 0, 1);
    17381746            }
    17391747            else
    1740                 PDMDevHlpPCISetIrqNoWait(pThis->CTX_SUFF(pDevIns), 0, 0);
     1748                PDMDevHlpPCISetIrqNoWait(pDevIns, 0, 0);
    17411749            break;
    17421750
     
    18141822                /* Read descriptor. */
    18151823                SVGAGuestMemDescriptor desc;
    1816                 rc = PDMDevHlpPhysRead(pThis->CTX_SUFF(pDevIns), GCPhys, &desc, sizeof(desc));
     1824                rc = PDMDevHlpPhysRead(pDevIns, GCPhys, &desc, sizeof(desc));
    18171825                AssertRCBreak(VBOXSTRICTRC_VAL(rc));
    18181826
     
    18731881
    18741882#ifdef IN_RING3
    1875             vmsvgaR3SetTraces(pThis, !!u32);
     1883            vmsvgaR3SetTraces(pDevIns, pThis, !!u32);
    18761884#else
    18771885            rc = VINF_IOM_R3_IOPORT_WRITE;
     
    19581966DECLCALLBACK(VBOXSTRICTRC) vmsvgaIORead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t *pu32, unsigned cb)
    19591967{
    1960     PVGASTATE   pThis = PDMINS_2_DATA(pDevIns, PVGASTATE);
     1968    PVGASTATE   pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
    19611969    RT_NOREF_PV(pvUser);
    19621970
     
    20022010DECLCALLBACK(VBOXSTRICTRC) vmsvgaIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb)
    20032011{
    2004     PVGASTATE   pThis = PDMINS_2_DATA(pDevIns, PVGASTATE);
     2012    PVGASTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     2013    PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
    20052014    RT_NOREF_PV(pvUser);
    20062015
     
    20142023
    20152024            case SVGA_VALUE_PORT:
    2016                 return vmsvgaWritePort(pDevIns, pThis, u32);
     2025                return vmsvgaWritePort(pDevIns, pThis, pThisCC, u32);
    20172026
    20182027            case SVGA_BIOS_PORT:
     
    20482057 * @returns VBox status code.
    20492058 * @param   pVM             VM handle.
    2050  * @param   pThis           VGA device instance data.
     2059 * @param   pThis           The shared VGA/VMSVGA instance data.
    20512060 * @param   GCPhys          The access physical address.
    20522061 * @param   fWriteAccess    Read or write access
     
    24972506static DECLCALLBACK(int) vmsvgaR3RegisterGmr(PPDMDEVINS pDevIns, uint32_t gmrId)
    24982507{
    2499     PVGASTATE       pThis = PDMINS_2_DATA(pDevIns, PVGASTATE);
     2508    PVGASTATE       pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
    25002509    PVMSVGAR3STATE  pSVGAState = pThis->svga.pSvgaR3State;
    25012510    PGMR pGMR = &pSVGAState->paGMR[gmrId];
     
    25042513    for (uint32_t i = 0; i < pGMR->numDescriptors; i++)
    25052514    {
    2506         rc = PGMHandlerPhysicalRegister(PDMDevHlpGetVM(pThis->pDevInsR3),
     2515        rc = PGMHandlerPhysicalRegister(PDMDevHlpGetVM(pDevIns),
    25072516                                        pGMR->paDesc[i].GCPhys, pGMR->paDesc[i].GCPhys + pGMR->paDesc[i].numPages * PAGE_SIZE - 1,
    25082517                                        pThis->svga.hGmrAccessHandlerType, pThis, NIL_RTR0PTR, NIL_RTRCPTR, "VMSVGA GMR");
     
    25152524static DECLCALLBACK(int) vmsvgaR3DeregisterGmr(PPDMDEVINS pDevIns, uint32_t gmrId)
    25162525{
    2517     PVGASTATE       pThis = PDMINS_2_DATA(pDevIns, PVGASTATE);
     2526    PVGASTATE       pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
    25182527    PVMSVGAR3STATE  pSVGAState = pThis->svga.pSvgaR3State;
    25192528    PGMR pGMR = &pSVGAState->paGMR[gmrId];
     
    25212530    for (uint32_t i = 0; i < pGMR->numDescriptors; i++)
    25222531    {
    2523         int rc = PGMHandlerPhysicalDeregister(PDMDevHlpGetVM(pThis->pDevInsR3), pGMR->paDesc[i].GCPhys);
     2532        int rc = PGMHandlerPhysicalDeregister(PDMDevHlpGetVM(pDevIns), pGMR->paDesc[i].GCPhys);
    25242533        AssertRC(rc);
    25252534    }
     
    25402549            for (uint32_t j = 0; j < pGMR->numDescriptors; j++)
    25412550            {
    2542                 int rc = PGMHandlerPhysicalReset(PDMDevHlpGetVM(pThis->pDevInsR3), pGMR->paDesc[j].GCPhys);
     2551                int rc = PGMHandlerPhysicalReset(PDMDevHlpGetVM(pDevIns), pGMR->paDesc[j].GCPhys);
    25432552                AssertRC(rc);
    25442553            }
     
    25592568 * Common worker for changing the pointer shape.
    25602569 *
    2561  * @param   pThis               The VGA instance data.
     2570 * @param   pThisCC             The VGA/VMSVGA state for ring-3.
    25622571 * @param   pSVGAState          The VMSVGA ring-3 instance data.
    25632572 * @param   fAlpha              Whether there is alpha or not.
     
    25692578 * @param   cbData              The size of the data.
    25702579 */
    2571 static void vmsvgaR3InstallNewCursor(PVGASTATE pThis, PVMSVGAR3STATE pSVGAState, bool fAlpha,
     2580static void vmsvgaR3InstallNewCursor(PVGASTATECC pThisCC, PVMSVGAR3STATE pSVGAState, bool fAlpha,
    25722581                                     uint32_t xHot, uint32_t yHot, uint32_t cx, uint32_t cy, uint8_t *pbData, uint32_t cbData)
    25732582{
     
    26162625# endif
    26172626
    2618     int rc = pThis->pDrv->pfnVBVAMousePointerShape(pThis->pDrv, true /*fVisible*/, fAlpha, xHot, yHot, cx, cy, pbData);
     2627    int rc = pThisCC->pDrv->pfnVBVAMousePointerShape(pThisCC->pDrv, true /*fVisible*/, fAlpha, xHot, yHot, cx, cy, pbData);
    26192628    AssertRC(rc);
    26202629
     
    26352644 * Handles the SVGA_CMD_DEFINE_CURSOR command.
    26362645 *
    2637  * @param   pThis               The VGA instance data.
     2646 * @param   pThis               The shared VGA/VMSVGA state.
     2647 * @param   pThisCC             The VGA/VMSVGA state for ring-3.
    26382648 * @param   pSVGAState          The VMSVGA ring-3 instance data.
    26392649 * @param   pCursor             The cursor.
     
    26432653 * @param   cbSrcXorLine        The scanline length of the XOR mask.
    26442654 */
    2645 static void vmsvgaR3CmdDefineCursor(PVGASTATE pThis, PVMSVGAR3STATE pSVGAState, SVGAFifoCmdDefineCursor const *pCursor,
     2655static void vmsvgaR3CmdDefineCursor(PVGASTATE pThis, PVGASTATECC pThisCC, PVMSVGAR3STATE pSVGAState,
     2656                                    SVGAFifoCmdDefineCursor const *pCursor,
    26462657                                    uint8_t const *pbSrcAndMask, uint32_t cbSrcAndLine,
    26472658                                    uint8_t const *pbSrcXorMask, uint32_t cbSrcXorLine)
     
    28742885     * Pass it to the frontend/whatever.
    28752886     */
    2876     vmsvgaR3InstallNewCursor(pThis, pSVGAState, false /*fAlpha*/, pCursor->hotspotX, pCursor->hotspotY, cx, cy, pbCopy, cbCopy);
     2887    vmsvgaR3InstallNewCursor(pThisCC, pSVGAState, false /*fAlpha*/, pCursor->hotspotX, pCursor->hotspotY, cx, cy, pbCopy, cbCopy);
    28772888}
    28782889
     
    28812892 * Worker for vmsvgaR3FifoThread that handles an external command.
    28822893 *
    2883  * @param   pThis           VGA device instance data.
     2894 * @param   pDevIns         The device instance.
     2895 * @param   pThis           The shared VGA/VMSVGA instance data.
     2896 * @param   pThisCC         The VGA/VMSVGA state for ring-3.
    28842897 */
    2885 static void vmsvgaR3FifoHandleExtCmd(PVGASTATE pThis)
     2898static void vmsvgaR3FifoHandleExtCmd(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC)
    28862899{
    28872900    uint8_t uExtCmd = pThis->svga.u8FIFOExtCommand;
     
    29172930            PSSMHANDLE pSSM = (PSSMHANDLE)pThis->svga.pvFIFOExtCmdParam;
    29182931            AssertLogRelMsgBreak(RT_VALID_PTR(pSSM), ("pSSM=%p\n", pSSM));
    2919             vmsvgaR3SaveExecFifo(pThis->pDevInsR3->pHlpR3, pThis, pSSM);
     2932            vmsvgaR3SaveExecFifo(pDevIns->pHlpR3, pThis, pSSM);
    29202933# ifdef VBOX_WITH_VMSVGA3D
    29212934            if (pThis->svga.f3DEnabled)
    2922                 vmsvga3dSaveExec(pThis->pDevInsR3, pThis, pSSM);
     2935                vmsvga3dSaveExec(pDevIns, pThis, pSSM);
    29232936# endif
    29242937            break;
     
    29302943            PVMSVGA_STATE_LOAD pLoadState = (PVMSVGA_STATE_LOAD)pThis->svga.pvFIFOExtCmdParam;
    29312944            AssertLogRelMsgBreak(RT_VALID_PTR(pLoadState), ("pLoadState=%p\n", pLoadState));
    2932             vmsvgaR3LoadExecFifo(pThis->pDevInsR3->pHlpR3, pThis, pLoadState->pSSM, pLoadState->uVersion, pLoadState->uPass);
     2945            vmsvgaR3LoadExecFifo(pDevIns->pHlpR3, pThis, pLoadState->pSSM, pLoadState->uVersion, pLoadState->uPass);
    29332946# ifdef VBOX_WITH_VMSVGA3D
    29342947            if (pThis->svga.f3DEnabled)
    2935                 vmsvga3dLoadExec(pThis->pDevInsR3, pThis, pLoadState->pSSM, pLoadState->uVersion, pLoadState->uPass);
     2948                vmsvga3dLoadExec(pDevIns, pThis, pThisCC, pLoadState->pSSM, pLoadState->uVersion, pLoadState->uPass);
    29362949# endif
    29372950            break;
     
    29702983 * @returns VBox status code (fully asserted).
    29712984 * @param   pDevIns         The device instance.
    2972  * @param   pThis           VGA device instance data.
     2985 * @param   pThis           The shared VGA/VMSVGA instance data.
    29732986 * @param   uExtCmd         The command to execute on the FIFO thread.
    29742987 * @param   pvParam         Pointer to command parameters.
     
    30643077 * Marks the FIFO non-busy, notifying any waiting EMTs.
    30653078 *
    3066  * @param   pThis           The VGA state.
     3079 * @param   pDevIns         The device instance.
     3080 * @param   pThis           The shared VGA/VMSVGA instance data.
    30673081 * @param   pSVGAState      Pointer to the ring-3 only SVGA state data.
    30683082 * @param   offFifoMin      The start byte offset of the command FIFO.
    30693083 */
    3070 static void vmsvgaR3FifoSetNotBusy(PVGASTATE pThis, PVMSVGAR3STATE pSVGAState, uint32_t offFifoMin)
     3084static void vmsvgaR3FifoSetNotBusy(PPDMDEVINS pDevIns, PVGASTATE pThis, PVMSVGAR3STATE pSVGAState, uint32_t offFifoMin)
    30713085{
    30723086    ASMAtomicAndU32(&pThis->svga.fBusy, ~VMSVGA_BUSY_F_FIFO);
     
    30783092    {
    30793093# ifdef VMSVGA_USE_EMT_HALT_CODE
    3080         PVM pVM = PDMDevHlpGetVM(pThis->pDevInsR3);
     3094        PVM pVM = PDMDevHlpGetVM(pDevIns);
    30813095        VMCPUID idCpu = VMCpuSetFindLastPresentInternal(&pSVGAState->BusyDelayedEmts);
    30823096        if (idCpu != NIL_VMCPUID)
     
    31113125 *                          buffer. (We will NEVER re-read anything.)
    31123126 * @param   pThread         The calling PDM thread handle.
    3113  * @param   pThis           The VGA state.
     3127 * @param   pThis           The shared VGA/VMSVGA instance data.
    31143128 * @param   pSVGAState      Pointer to the ring-3 only SVGA state data. For
    31153129 *                          statistics collection.
     
    32583272 */
    32593273static uint32_t
    3260 vmsvgaR3FifoUpdateCursor(PVGASTATE pVGAState, PVMSVGAR3STATE  pSVGAState, uint32_t RT_UNTRUSTED_VOLATILE_GUEST *pFIFO,
     3274vmsvgaR3FifoUpdateCursor(PVGASTATECC pThisCC, PVMSVGAR3STATE  pSVGAState, uint32_t RT_UNTRUSTED_VOLATILE_GUEST *pFIFO,
    32613275                         uint32_t offFifoMin,  uint32_t uCursorUpdateCount,
    32623276                         uint32_t *pxLast, uint32_t *pyLast, uint32_t *pfLastVisible)
     
    33083322            LogRel2(("vmsvgaR3FifoUpdateCursor: fVisible %d fLastVisible %d (%d,%d)\n", fVisible, *pfLastVisible, x, y));
    33093323            *pfLastVisible = fVisible;
    3310             pVGAState->pDrv->pfnVBVAMousePointerShape(pVGAState->pDrv, RT_BOOL(fVisible), false, 0, 0, 0, 0, NULL);
     3324            pThisCC->pDrv->pfnVBVAMousePointerShape(pThisCC->pDrv, RT_BOOL(fVisible), false, 0, 0, 0, 0, NULL);
    33113325            STAM_REL_COUNTER_INC(&pSVGAState->StatFifoCursorVisiblity);
    33123326        }
    3313         pVGAState->pDrv->pfnVBVAReportCursorPosition(pVGAState->pDrv, fFlags, idScreen, x, y);
     3327        pThisCC->pDrv->pfnVBVAReportCursorPosition(pThisCC->pDrv, fFlags, idScreen, x, y);
    33143328        STAM_REL_COUNTER_INC(&pSVGAState->StatFifoCursorPosition);
    33153329    }
     
    33473361 * Called by the VGA refresh timer to wake up the FIFO thread when needed.
    33483362 *
    3349  * @param   pThis   The VGA state.
     3363 * @param   pThis   The shared VGA/VMSVGA instance data.
    33503364 */
    33513365void vmsvgaR3FifoWatchdogTimer(PPDMDEVINS pDevIns, PVGASTATE pThis)
     
    33703384static DECLCALLBACK(int) vmsvgaR3FifoLoop(PPDMDEVINS pDevIns, PPDMTHREAD pThread)
    33713385{
    3372     PVGASTATE       pThis = (PVGASTATE)pThread->pvUser;
     3386    PVGASTATE       pThis      = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     3387    PVGASTATER3     pThisCC    = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
    33733388    PVMSVGAR3STATE  pSVGAState = pThis->svga.pSvgaR3State;
    33743389    int             rc;
     
    33843399    if (pThis->svga.fFifoExtCommandWakeup)
    33853400    {
    3386         vmsvgaR3FifoHandleExtCmd(pThis);
     3401        vmsvgaR3FifoHandleExtCmd(pDevIns, pThis, pThisCC);
    33873402        while (pThread->enmState == PDMTHREADSTATE_RUNNING)
    33883403            if (pThis->svga.u8FIFOExtCommand == VMSVGA_FIFO_EXTCMD_NONE)
    33893404                PDMDevHlpSUPSemEventWaitNoResume(pDevIns, pThis->svga.hFIFORequestSem, RT_MS_1MIN);
    33903405            else
    3391                 vmsvgaR3FifoHandleExtCmd(pThis);
     3406                vmsvgaR3FifoHandleExtCmd(pDevIns, pThis, pThisCC);
    33923407        return VINF_SUCCESS;
    33933408    }
     
    35153530        if (pThis->svga.u8FIFOExtCommand != VMSVGA_FIFO_EXTCMD_NONE)
    35163531        {
    3517             vmsvgaR3FifoHandleExtCmd(pThis);
     3532            vmsvgaR3FifoHandleExtCmd(pDevIns, pThis, pThisCC);
    35183533            continue;
    35193534        }
     
    35253540            || !pThis->svga.fConfigured)
    35263541        {
    3527             vmsvgaR3FifoSetNotBusy(pThis, pSVGAState, pFIFO[SVGA_FIFO_MIN]);
     3542            vmsvgaR3FifoSetNotBusy(pDevIns, pThis, pSVGAState, pFIFO[SVGA_FIFO_MIN]);
    35283543            fBadOrDisabledFifo = true;
    35293544            cMsSleep           = cMsMaxSleep; /* cheat */
     
    35513566            STAM_REL_COUNTER_INC(&pSVGAState->StatFifoErrors);
    35523567            LogRelMax(8, ("vmsvgaR3FifoLoop: Bad fifo: min=%#x stop=%#x max=%#x\n", offFifoMin, offCurrentCmd, offFifoMax));
    3553             vmsvgaR3FifoSetNotBusy(pThis, pSVGAState, offFifoMin);
     3568            vmsvgaR3FifoSetNotBusy(pDevIns, pThis, pSVGAState, offFifoMin);
    35543569            fBadOrDisabledFifo = true;
    35553570            continue;
     
    35743589            else
    35753590            {
    3576                 uint32_t const uLastCursorCount = vmsvgaR3FifoUpdateCursor(pThis, pSVGAState, pFIFO, offFifoMin, uCursorUpdateCount,
    3577                                                                          &xLastCursor, &yLastCursor, &fLastCursorVisible);
    3578                 ASMAtomicWriteU32(&pThis->svga.uLastCursorUpdateCount, uLastCursorCount);
     3591                uint32_t const uNewCount = vmsvgaR3FifoUpdateCursor(pThisCC, pSVGAState, pFIFO, offFifoMin, uCursorUpdateCount,
     3592                                                                    &xLastCursor, &yLastCursor, &fLastCursorVisible);
     3593                ASMAtomicWriteU32(&pThis->svga.uLastCursorUpdateCount, uNewCount);
    35793594            }
    35803595        }
     
    36373652            if (ASMBitTestAndClear(&pThis->svga.u32ActionFlags, VMSVGA_ACTION_CHANGEMODE_BIT))
    36383653            {
    3639                 vmsvgaR3ChangeMode(pThis);
     3654                vmsvgaR3ChangeMode(pThis, pThisCC);
    36403655# ifdef VBOX_WITH_VMSVGA3D
    36413656                if (pThis->svga.p3dState != NULL)
     
    37033718                VMSVGASCREENOBJECT *pScreen = vmsvgaR3GetScreenObject(pThis, 0);
    37043719                AssertBreak(pScreen);
    3705                 vmsvgaR3UpdateScreen(pThis, pScreen, pUpdate->x, pUpdate->y, pUpdate->width, pUpdate->height);
     3720                vmsvgaR3UpdateScreen(pThisCC, pScreen, pUpdate->x, pUpdate->y, pUpdate->width, pUpdate->height);
    37063721                break;
    37073722            }
     
    37283743                VMSVGAFIFO_GET_MORE_CMD_BUFFER_BREAK(pCursor, SVGAFifoCmdDefineCursor, sizeof(*pCursor) + cbAndMask + cbXorMask);
    37293744
    3730                 vmsvgaR3CmdDefineCursor(pThis, pSVGAState, pCursor, (uint8_t const *)(pCursor + 1), cbAndLine,
     3745                vmsvgaR3CmdDefineCursor(pThis, pThisCC, pSVGAState, pCursor, (uint8_t const *)(pCursor + 1), cbAndLine,
    37313746                                        (uint8_t const *)(pCursor + 1) + cbAndMask, cbXorLine);
    37323747                break;
     
    37683783                memcpy(pCursorCopy + cbAndMask, (pCursor + 1), pCursor->width * pCursor->height * sizeof(uint32_t));
    37693784
    3770                 vmsvgaR3InstallNewCursor(pThis, pSVGAState, true /*fAlpha*/, pCursor->hotspotX, pCursor->hotspotY,
     3785                vmsvgaR3InstallNewCursor(pThisCC, pSVGAState, true /*fAlpha*/, pCursor->hotspotX, pCursor->hotspotY,
    37713786                                         pCursor->width, pCursor->height, pCursorCopy, cbCursorShape);
    37723787                break;
     
    40174032
    40184033#  ifdef DEBUG_GMR_ACCESS
    4019                 VMR3ReqCallWaitU(PDMDevHlpGetUVM(pThis->pDevInsR3), VMCPUID_ANY, (PFNRT)vmsvgaR3RegisterGmr, 2, pThis->pDevInsR3, pCmd->gmrId);
     4034                VMR3ReqCallWaitU(PDMDevHlpGetUVM(pDevIns), VMCPUID_ANY, (PFNRT)vmsvgaR3RegisterGmr, 2, pDevIns, pCmd->gmrId);
    40204035#  endif
    40214036                break;
     
    40884103
    40894104                pThis->svga.fGFBRegisters = false;
    4090                 vmsvgaR3ChangeMode(pThis);
     4105                vmsvgaR3ChangeMode(pThis, pThisCC);
    40914106                break;
    40924107            }
     
    41094124                pScreen->idScreen  = idScreen;
    41104125
    4111                 vmsvgaR3ChangeMode(pThis);
     4126                vmsvgaR3ChangeMode(pThis, pThisCC);
    41124127                break;
    41134128            }
     
    41724187                 * Important are pbHstBuf and cbHstBuf. offHst and cbHstPitch are verified by vmsvgaR3GmrTransfer.
    41734188                 */
    4174                 uint8_t * const pbHstBuf = (uint8_t *)pThis->CTX_SUFF(vram_ptr) + pScreen->offVRAM;
     4189                uint8_t * const pbHstBuf = (uint8_t *)pThisCC->pbVRam + pScreen->offVRAM;
    41754190                uint32_t const cbScanline = pScreen->cbPitch ? pScreen->cbPitch :
    41764191                                                               width * (RT_ALIGN(pScreen->cBpp, 8) / 8);
     
    41884203                int32_t const cbGstPitch = pSVGAState->GMRFB.bytesPerLine;
    41894204
    4190                 rc = vmsvgaR3GmrTransfer(pThis, SVGA3D_WRITE_HOST_VRAM,
    4191                                        pbHstBuf, cbHstBuf, offHst, cbHstPitch,
    4192                                        gstPtr, offGst, cbGstPitch,
    4193                                        (width * RT_ALIGN(pScreen->cBpp, 8)) / 8, height);
     4205                rc = vmsvgaR3GmrTransfer(pThis, pThisCC, SVGA3D_WRITE_HOST_VRAM,
     4206                                         pbHstBuf, cbHstBuf, offHst, cbHstPitch,
     4207                                         gstPtr, offGst, cbGstPitch,
     4208                                         (width * RT_ALIGN(pScreen->cBpp, 8)) / 8, height);
    41944209                AssertRC(rc);
    4195                 vmsvgaR3UpdateScreen(pThis, pScreen, clipRect.left, clipRect.top, width, height);
     4210                vmsvgaR3UpdateScreen(pThisCC, pScreen, clipRect.left, clipRect.top, width, height);
    41964211                break;
    41974212            }
     
    42444259                 * Important are pbHstBuf and cbHstBuf. offHst and cbHstPitch are verified by vmsvgaR3GmrTransfer.
    42454260                 */
    4246                 uint8_t * const pbHstBuf = (uint8_t *)pThis->CTX_SUFF(vram_ptr) + pScreen->offVRAM;
     4261                uint8_t * const pbHstBuf = (uint8_t *)pThisCC->pbVRam + pScreen->offVRAM;
    42474262                uint32_t const cbScanline = pScreen->cbPitch ? pScreen->cbPitch :
    42484263                                                               width * (RT_ALIGN(pScreen->cBpp, 8) / 8);
     
    42604275                int32_t const cbGstPitch = pSVGAState->GMRFB.bytesPerLine;
    42614276
    4262                 rc = vmsvgaR3GmrTransfer(pThis, SVGA3D_READ_HOST_VRAM,
     4277                rc = vmsvgaR3GmrTransfer(pThis, pThisCC, SVGA3D_READ_HOST_VRAM,
    42634278                                         pbHstBuf, cbHstBuf, offHst, cbHstPitch,
    42644279                                         gstPtr, offGst, cbGstPitch,
     
    43364351                                                   SVGA3D_TEX_FILTER_NONE, cMipLevels, (SVGA3dSize *)(pCmd + 1));
    43374352#  ifdef DEBUG_GMR_ACCESS
    4338                         VMR3ReqCallWaitU(PDMDevHlpGetUVM(pThis->pDevInsR3), VMCPUID_ANY, (PFNRT)vmsvgaR3ResetGmrHandlers, 1, pThis);
     4353                        VMR3ReqCallWaitU(PDMDevHlpGetUVM(pDevIns), VMCPUID_ANY, (PFNRT)vmsvgaR3ResetGmrHandlers, 1, pThis);
    43394354#  endif
    43404355                        break;
     
    43954410                        cCopyBoxes = (pHdr->size - sizeof(*pCmd)) / sizeof(SVGA3dCopyBox);
    43964411                        STAM_PROFILE_START(&pSVGAState->StatR3Cmd3dSurfaceDmaProf, a);
    4397                         rc = vmsvga3dSurfaceDMA(pThis, pCmd->guest, pCmd->host, pCmd->transfer, cCopyBoxes, (SVGA3dCopyBox *)(pCmd + 1));
     4412                        rc = vmsvga3dSurfaceDMA(pThis, pThisCC, pCmd->guest, pCmd->host, pCmd->transfer,
     4413                                                cCopyBoxes, (SVGA3dCopyBox *)(pCmd + 1));
    43984414                        STAM_PROFILE_STOP(&pSVGAState->StatR3Cmd3dSurfaceDmaProf, a);
    43994415                        break;
     
    44084424
    44094425                        cRects = (pHdr->size - sizeof(*pCmd)) / sizeof(SVGASignedRect);
    4410                         rc = vmsvga3dSurfaceBlitToScreen(pThis, pCmd->destScreenId, pCmd->destRect, pCmd->srcImage, pCmd->srcRect, cRects, (SVGASignedRect *)(pCmd + 1));
     4426                        rc = vmsvga3dSurfaceBlitToScreen(pThis, pThisCC, pCmd->destScreenId, pCmd->destRect, pCmd->srcImage,
     4427                                                         pCmd->srcRect, cRects, (SVGASignedRect *)(pCmd + 1));
    44114428                        break;
    44124429                    }
     
    45604577
    45614578                        STAM_PROFILE_START(&pSVGAState->StatR3Cmd3dPresentProf, a);
    4562                         rc = vmsvga3dCommandPresent(pThis, pCmd->sid, cRects, (SVGA3dCopyRect *)(pCmd + 1));
     4579                        rc = vmsvga3dCommandPresent(pThis, pThisCC, pCmd->sid, cRects, (SVGA3dCopyRect *)(pCmd + 1));
    45634580                        STAM_PROFILE_STOP(&pSVGAState->StatR3Cmd3dPresentProf, a);
    45644581                        break;
     
    46714688                        STAM_REL_COUNTER_INC(&pSVGAState->StatR3Cmd3dWaitForQuery);
    46724689
    4673                         rc = vmsvga3dQueryWait(pThis, pCmd->cid, pCmd->type, pCmd->guestResult);
     4690                        rc = vmsvga3dQueryWait(pThis, pThisCC, pCmd->cid, pCmd->type, pCmd->guestResult);
    46744691                        break;
    46754692                    }
     
    47544771        {
    47554772            Log(("vmsvgaR3FifoLoop: emptied the FIFO next=%x stop=%x\n", pFIFO[SVGA_FIFO_NEXT_CMD], offCurrentCmd));
    4756             vmsvgaR3FifoSetNotBusy(pThis, pSVGAState, offFifoMin);
     4773            vmsvgaR3FifoSetNotBusy(pDevIns, pThis, pSVGAState, offFifoMin);
    47574774        }
    47584775    }
     
    47694786 * Free the specified GMR
    47704787 *
    4771  * @param   pThis           VGA device instance data.
     4788 * @param   pThis           The shared VGA/VMSVGA instance data.
    47724789 * @param   idGMR           GMR id
    47734790 */
     
    47824799    {
    47834800# ifdef DEBUG_GMR_ACCESS
    4784         VMR3ReqCallWaitU(PDMDevHlpGetUVM(pThis->pDevInsR3), VMCPUID_ANY, (PFNRT)vmsvgaR3DeregisterGmr, 2, pThis->pDevInsR3, idGMR);
     4801        VMR3ReqCallWaitU(PDMDevHlpGetUVM(pDevIns), VMCPUID_ANY, (PFNRT)vmsvgaR3DeregisterGmr, 2, pDevIns, idGMR);
    47854802# endif
    47864803
     
    48004817 *
    48014818 * @returns VBox status code.
    4802  * @param   pThis           VGA device instance data.
     4819 * @param   pThis           The shared VGA/VMSVGA instance data.
     4820 * @param   pThisCC         The VGA/VMSVGA state for ring-3.
    48034821 * @param   enmTransferType Transfer type (read/write)
    48044822 * @param   pbHstBuf        Host buffer pointer (valid)
     
    48124830 * @param   cHeight         Number of scanllines to copy
    48134831 */
    4814 int vmsvgaR3GmrTransfer(PVGASTATE pThis, const SVGA3dTransferType enmTransferType,
     4832int vmsvgaR3GmrTransfer(PVGASTATE pThis, PVGASTATECC pThisCC, const SVGA3dTransferType enmTransferType,
    48154833                        uint8_t *pbHstBuf, uint32_t cbHstBuf, uint32_t offHst, int32_t cbHstPitch,
    48164834                        SVGAGuestPtr gstPtr, uint32_t offGst, int32_t cbGstPitch,
    48174835                        uint32_t cbWidth, uint32_t cHeight)
    48184836{
    4819     PVMSVGAR3STATE pSVGAState = pThis->svga.pSvgaR3State;
    4820     int            rc;
     4837    PVMSVGAR3STATE  pSVGAState = pThis->svga.pSvgaR3State;
     4838    PPDMDEVINS      pDevIns = pThisCC->pDevIns; /* simpler */
     4839    int             rc;
    48214840
    48224841    LogFunc(("%s host %p size=%d offset %d pitch=%d; guest gmr=%#x:%#x offset=%d pitch=%d cbWidth=%d cHeight=%d\n",
     
    49374956    if (gstPtr.gmrId == SVGA_GMR_FRAMEBUFFER)
    49384957    {
    4939         uint8_t *pbGst = pThis->CTX_SUFF(vram_ptr) + offGmr;
     4958        uint8_t *pbGst = pThisCC->pbVRam + offGmr;
    49404959
    49414960        uint8_t const *pbSrc;
     
    50205039
    50215040            if (enmTransferType == SVGA3D_WRITE_HOST_VRAM)
    5022                 rc = PDMDevHlpPhysRead(pThis->CTX_SUFF(pDevIns), GCPhys, pbCurrentHost, cbToCopy);
     5041                rc = PDMDevHlpPhysRead(pDevIns, GCPhys, pbCurrentHost, cbToCopy);
    50235042            else
    5024                 rc = PDMDevHlpPhysWrite(pThis->CTX_SUFF(pDevIns), GCPhys, pbCurrentHost, cbToCopy);
     5043                rc = PDMDevHlpPhysWrite(pDevIns, GCPhys, pbCurrentHost, cbToCopy);
    50255044            AssertRCBreak(rc);
    50265045
     
    51975216 * Enables or disables dirty page tracking for the framebuffer
    51985217 *
    5199  * @param   pThis           VGA device instance data.
     5218 * @param   pDevIns         The device instance.
     5219 * @param   pThis           The shared VGA/VMSVGA instance data.
    52005220 * @param   fTraces         Enable/disable traces
    52015221 */
    5202 static void vmsvgaR3SetTraces(PVGASTATE pThis, bool fTraces)
     5222static void vmsvgaR3SetTraces(PPDMDEVINS pDevIns, PVGASTATE pThis, bool fTraces)
    52035223{
    52045224    if (    (!pThis->svga.fConfigured || !pThis->svga.fEnabled)
     
    52305250        {
    52315251            Log(("vmsvgaR3SetTraces: enable frame buffer dirty page tracking. (%x bytes; vram %x)\n", cbFrameBuffer, pThis->vram_size));
    5232             vgaR3RegisterVRAMHandler(pThis, cbFrameBuffer);
     5252            vgaR3RegisterVRAMHandler(pDevIns, pThis, cbFrameBuffer);
    52335253            pThis->svga.fVRAMTracking = true;
    52345254        }
     
    52395259        {
    52405260            Log(("vmsvgaR3SetTraces: disable frame buffer dirty page tracking\n"));
    5241             vgaR3UnregisterVRAMHandler(pThis);
     5261            vgaR3UnregisterVRAMHandler(pDevIns, pThis);
    52425262            pThis->svga.fVRAMTracking = false;
    52435263        }
     
    52515271                                                  RTGCPHYS GCPhysAddress, RTGCPHYS cb, PCIADDRESSSPACE enmType)
    52525272{
    5253     PVGASTATE   pThis = PDMINS_2_DATA(pDevIns, PVGASTATE);
     5273    PVGASTATE   pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
    52545274    int         rc;
    52555275    RT_NOREF(pPciDev);
     
    53095329 *
    53105330 * @param   pDevIns             The device instance.
    5311  * @param   pThis               The VGA device instance data.
     5331 * @param   pThis               The The shared VGA/VMSVGA instance data.
    53125332 * @param   sid                 Either UINT32_MAX or the ID of a specific
    53135333 *                              surface.  If UINT32_MAX is used, all surfaces
     
    53615381        fInvY = true;
    53625382
    5363     vmsvga3dInfoSurfaceWorker(pDevIns, PDMINS_2_DATA(pDevIns, PVGASTATE), pHlp, sid, fVerbose, cxAscii, fInvY, NULL);
     5383    vmsvga3dInfoSurfaceWorker(pDevIns, PDMDEVINS_2_DATA(pDevIns, PVGASTATE), pHlp, sid, fVerbose, cxAscii, fInvY, NULL);
    53645384}
    53655385
     
    53865406    const uint32_t cxAscii = 0; /* No ASCII */
    53875407    const bool fInvY = false;   /* Do not invert. */
    5388     vmsvga3dInfoSurfaceWorker(pDevIns, PDMINS_2_DATA(pDevIns, PVGASTATE), pHlp, sid, fVerbose, cxAscii, fInvY, pszBitmapPath);
     5408    vmsvga3dInfoSurfaceWorker(pDevIns, PDMDEVINS_2_DATA(pDevIns, PVGASTATE), pHlp, sid, fVerbose, cxAscii, fInvY, pszBitmapPath);
    53895409}
    53905410
     
    54085428        fVerbose = false;
    54095429
    5410     vmsvga3dInfoContextWorker(PDMINS_2_DATA(pDevIns, PVGASTATE), pHlp, sid, fVerbose);
     5430    vmsvga3dInfoContextWorker(PDMDEVINS_2_DATA(pDevIns, PVGASTATE), pHlp, sid, fVerbose);
    54115431}
    54125432
     
    54185438static DECLCALLBACK(void) vmsvgaR3Info(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
    54195439{
    5420     RT_NOREF(pszArgs);
    5421     PVGASTATE       pThis = PDMINS_2_DATA(pDevIns, PVGASTATE);
     5440    PVGASTATE       pThis      = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     5441    PVGASTATECC     pThisCC    = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
    54225442    PVMSVGAR3STATE  pSVGAState = pThis->svga.pSvgaR3State;
    54235443    uint32_t RT_UNTRUSTED_VOLATILE_GUEST *pFIFO = pThis->svga.pFIFOR3;
     5444    RT_NOREF(pszArgs);
    54245445
    54255446    pHlp->pfnPrintf(pHlp, "Extension enabled:  %RTbool\n", pThis->svga.fEnabled);
     
    54575478    pHlp->pfnPrintf(pHlp, "3D enabled:         %RTbool\n", pThis->svga.f3DEnabled);
    54585479# endif
    5459     if (pThis->pDrv)
    5460     {
    5461         pHlp->pfnPrintf(pHlp, "Driver mode:        %ux%u %ubpp\n", pThis->pDrv->cx, pThis->pDrv->cy, pThis->pDrv->cBits);
    5462         pHlp->pfnPrintf(pHlp, "Driver pitch:       %u (%#x)\n", pThis->pDrv->cbScanline, pThis->pDrv->cbScanline);
     5480    if (pThisCC->pDrv)
     5481    {
     5482        pHlp->pfnPrintf(pHlp, "Driver mode:        %ux%u %ubpp\n", pThisCC->pDrv->cx, pThisCC->pDrv->cy, pThisCC->pDrv->cBits);
     5483        pHlp->pfnPrintf(pHlp, "Driver pitch:       %u (%#x)\n", pThisCC->pDrv->cbScanline, pThisCC->pDrv->cbScanline);
    54635484    }
    54645485}
     
    55295550{
    55305551    RT_NOREF(uPass);
    5531     PVGASTATE       pThis      = PDMINS_2_DATA(pDevIns, PVGASTATE);
     5552    PVGASTATE       pThis      = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
    55325553    PVMSVGAR3STATE  pSVGAState = pThis->svga.pSvgaR3State;
    55335554    PCPDMDEVHLPR3   pHlp       = pDevIns->pHlpR3;
     
    56165637
    56175638#  ifdef RT_OS_DARWIN  /** @todo r=bird: this is normally done on the EMT, so for DARWIN we do that when loading saved state too now. See DevVGA-SVGA3d-shared.h. */
    5618     vmsvga3dPowerOn(pThis);
     5639    vmsvga3dPowerOn(pDevIns, pThis, pThisCC);
    56195640#  endif
    56205641
     
    56345655int vmsvgaR3LoadDone(PPDMDEVINS pDevIns)
    56355656{
    5636     PVGASTATE       pThis      = PDMINS_2_DATA(pDevIns, PVGASTATE);
     5657    PVGASTATE       pThis      = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     5658    PVGASTATECC     pThisCC    = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
    56375659    PVMSVGAR3STATE  pSVGAState = pThis->svga.pSvgaR3State;
    56385660
     
    56425664    if (pSVGAState->Cursor.fActive)
    56435665    {
    5644         int rc;
    5645 
    5646         rc = pThis->pDrv->pfnVBVAMousePointerShape(pThis->pDrv,
    5647                                                    true,
    5648                                                    true,
    5649                                                    pSVGAState->Cursor.xHotspot,
    5650                                                    pSVGAState->Cursor.yHotspot,
    5651                                                    pSVGAState->Cursor.width,
    5652                                                    pSVGAState->Cursor.height,
    5653                                                    pSVGAState->Cursor.pData);
     5666        int rc = pThisCC->pDrv->pfnVBVAMousePointerShape(pThisCC->pDrv,
     5667                                                         true /*fVisible*/,
     5668                                                         true /*fAlpha*/,
     5669                                                         pSVGAState->Cursor.xHotspot,
     5670                                                         pSVGAState->Cursor.yHotspot,
     5671                                                         pSVGAState->Cursor.width,
     5672                                                         pSVGAState->Cursor.height,
     5673                                                         pSVGAState->Cursor.pData);
    56545674        AssertRC(rc);
    56555675    }
     
    56925712int vmsvgaR3SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
    56935713{
    5694     PVGASTATE       pThis      = PDMINS_2_DATA(pDevIns, PVGASTATE);
     5714    PVGASTATE       pThis      = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
    56955715    PVMSVGAR3STATE  pSVGAState = pThis->svga.pSvgaR3State;
    56965716    PCPDMDEVHLPR3   pHlp       = pDevIns->pHlpR3;
     
    59916011int vmsvgaR3Reset(PPDMDEVINS pDevIns)
    59926012{
    5993     PVGASTATE       pThis = PDMINS_2_DATA(pDevIns, PVGASTATE);
     6013    PVGASTATE       pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
    59946014    PVMSVGAR3STATE  pSVGAState = pThis->svga.pSvgaR3State;
    59956015
     
    60436063int vmsvgaR3Destruct(PPDMDEVINS pDevIns)
    60446064{
    6045     PVGASTATE pThis = PDMINS_2_DATA(pDevIns, PVGASTATE);
     6065    PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
    60466066
    60476067    /*
     
    60996119int vmsvgaR3Init(PPDMDEVINS pDevIns)
    61006120{
    6101     PVGASTATE       pThis = PDMINS_2_DATA(pDevIns, PVGASTATE);
     6121    PVGASTATE       pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     6122    PVGASTATECC     pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
    61026123    PVMSVGAR3STATE  pSVGAState;
    61036124    int             rc;
     
    61346155    if (pThis->svga.f3DEnabled)
    61356156    {
    6136         rc = vmsvga3dInit(pThis);
     6157        rc = vmsvga3dInit(pDevIns, pThis, pThisCC);
    61376158        if (RT_FAILURE(rc))
    61386159        {
     
    61626183# ifdef DEBUG_GMR_ACCESS
    61636184    /* Register the GMR access handler type. */
    6164     rc = PGMR3HandlerPhysicalTypeRegister(PDMDevHlpGetVM(pThis->pDevInsR3), PGMPHYSHANDLERKIND_WRITE,
     6185    rc = PGMR3HandlerPhysicalTypeRegister(PDMDevHlpGetVM(pDevIns), PGMPHYSHANDLERKIND_WRITE,
    61656186                                          vmsvgaR3GmrAccessHandler,
    61666187                                          NULL, NULL, NULL,
     
    61746195       debugging FIFO access, this is also used to facilitate
    61756196       extended fifo thread sleeps. */
    6176     rc = PGMR3HandlerPhysicalTypeRegister(PDMDevHlpGetVM(pThis->pDevInsR3),
     6197    rc = PGMR3HandlerPhysicalTypeRegister(PDMDevHlpGetVM(pDevIns),
    61776198#  ifdef DEBUG_FIFO_ACCESS
    61786199                                          PGMPHYSHANDLERKIND_ALL,
     
    63956416{
    63966417# ifdef VBOX_WITH_VMSVGA3D
    6397     PVGASTATE pThis = PDMINS_2_DATA(pDevIns, PVGASTATE);
     6418    PVGASTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     6419    PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
    63986420    if (pThis->svga.f3DEnabled)
    63996421    {
    6400         int rc = vmsvga3dPowerOn(pThis);
     6422        int rc = vmsvga3dPowerOn(pDevIns, pThis, pThisCC);
    64016423
    64026424        if (RT_SUCCESS(rc))
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.h

    r82089 r82109  
    359359} VMSVGAState;
    360360
    361 typedef struct VGAState *PVGASTATE;
     361typedef struct VGAState   *PVGASTATE;
     362typedef struct VGASTATER3 *PVGASTATER3;
     363typedef struct VGASTATER0 *PVGASTATER0;
     364typedef struct VGASTATERC *PVGASTATERC;
     365typedef CTX_SUFF(PVGASTATE) PVGASTATECC;
    362366
    363367DECLCALLBACK(int) vmsvgaR3PciIORegionFifoMapUnmap(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion,
     
    381385#ifdef IN_RING3
    382386VMSVGASCREENOBJECT *vmsvgaR3GetScreenObject(PVGASTATE pThis, uint32_t idScreen);
    383 int vmsvgaR3UpdateScreen(PVGASTATE pThis, VMSVGASCREENOBJECT *pScreen, int x, int y, int w, int h);
     387int vmsvgaR3UpdateScreen(PVGASTATECC pThisCC, VMSVGASCREENOBJECT *pScreen, int x, int y, int w, int h);
    384388#endif
    385389
    386390void vmsvgaR3GmrFree(PVGASTATE pThis, uint32_t idGMR);
    387 int vmsvgaR3GmrTransfer(PVGASTATE pThis, const SVGA3dTransferType enmTransferType,
     391int vmsvgaR3GmrTransfer(PVGASTATE pThis, PVGASTATECC pThisCC, const SVGA3dTransferType enmTransferType,
    388392                        uint8_t *pbHstBuf, uint32_t cbHstBuf, uint32_t offHst, int32_t cbHstPitch,
    389393                        SVGAGuestPtr gstPtr, uint32_t offGst, int32_t cbGstPitch,
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-info.cpp

    r82099 r82109  
    512512 * Updates the heap buffers for all surfaces or one specific one.
    513513 *
    514  * @param   pThis               The VGA device instance data.
     514 * @param   pThis               The shared VGA instance data.
    515515 * @param   sid                 The surface ID, UINT32_MAX if all.
    516516 * @thread  VMSVGAFIFO
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-internal.h

    r82101 r82109  
    12281228                                   PVMSVGA3DSURFACE pSrcSurface, uint32_t uSrcFace, uint32_t uSrcMipmap, SVGA3dBox const *pSrcBox,
    12291229                                   SVGA3dStretchBltMode enmMode, PVMSVGA3DCONTEXT pContext);
    1230 int  vmsvga3dBackSurfaceDMACopyBox(PVGASTATE pThis, PVMSVGA3DSTATE pState, PVMSVGA3DSURFACE pSurface,
     1230int  vmsvga3dBackSurfaceDMACopyBox(PVGASTATE pThis, PVGASTATECC pThisCC, PVMSVGA3DSTATE pState, PVMSVGA3DSURFACE pSurface,
    12311231                                   PVMSVGA3DMIPMAPLEVEL pMipLevel, uint32_t uHostFace, uint32_t uHostMipmap,
    12321232                                   SVGAGuestPtr GuestPtr, uint32_t cbGuestPitch, SVGA3dTransferType transfer,
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-ogl.cpp

    r82101 r82109  
    583583 *
    584584 * @returns VBox status code.
    585  * @param   pThis   The VGA device state where svga.p3dState will be modified.
     585 * @param   pDevIns     The device instance.
     586 * @param   pThis       The shared VGA/VMSVGA state where svga.p3dState will be
     587 *                      modified.
     588 * @param   pThisCC     The VGA/VMSVGA state for ring-3.
    586589 */
    587 int vmsvga3dInit(PVGASTATE pThis)
     590int vmsvga3dInit(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC)
    588591{
    589592    int rc;
     593    RT_NOREF(pThisCC);
    590594
    591595    AssertCompile(GL_TRUE == 1);
     
    593597
    594598#ifdef VMSVGA3D_DYNAMIC_LOAD
    595     rc = glLdrInit(pThis->pDevInsR3);
     599    rc = glLdrInit(pDevIns);
    596600    if (RT_FAILURE(rc))
    597601    {
     
    809813
    810814/* We must delay window creation until the PowerOn phase. Init is too early and will cause failures. */
    811 int vmsvga3dPowerOn(PVGASTATE pThis)
     815int vmsvga3dPowerOn(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC)
    812816{
    813817    PVMSVGA3DSTATE pState = pThis->svga.p3dState;
     
    818822#endif
    819823    int              rc;
     824    RT_NOREF(pDevIns, pThisCC);
    820825
    821826    if (pState->rsGLVersion != 0.0)
     
    833838#ifdef VMSVGA3D_DYNAMIC_LOAD
    834839    /* Context is set and it is possible now to resolve extension functions. */
    835     rc = glLdrGetExtFunctions(pThis->pDevInsR3);
     840    rc = glLdrGetExtFunctions(pDevIns);
    836841    if (RT_FAILURE(rc))
    837842    {
     
    28122817 *
    28132818 * @returns Failure status code or @a rc.
    2814  * @param   pThis               The VGA device instance data.
     2819 * @param   pThis               The shared VGA instance data.
     2820 * @param   pThisCC             The VGA/VMSVGA state for ring-3.
    28152821 * @param   pState              The VMSVGA3d state.
    28162822 * @param   pSurface            The host surface.
     
    28262832 * @param   iBox                The current box number (for Direct 3D).
    28272833 */
    2828 int vmsvga3dBackSurfaceDMACopyBox(PVGASTATE pThis, PVMSVGA3DSTATE pState, PVMSVGA3DSURFACE pSurface,
     2834int vmsvga3dBackSurfaceDMACopyBox(PVGASTATE pThis, PVGASTATECC pThisCC, PVMSVGA3DSTATE pState, PVMSVGA3DSURFACE pSurface,
    28292835                                  PVMSVGA3DMIPMAPLEVEL pMipLevel, uint32_t uHostFace, uint32_t uHostMipmap,
    28302836                                  SVGAGuestPtr GuestPtr, uint32_t cbGuestPitch, SVGA3dTransferType transfer,
     
    29242930
    29252931        rc = vmsvgaR3GmrTransfer(pThis,
     2932                                 pThisCC,
    29262933                                 transfer,
    29272934                                 pDoubleBuffer,
     
    30723079
    30733080                rc = vmsvgaR3GmrTransfer(pThis,
     3081                                         pThisCC,
    30743082                                         transfer,
    30753083                                         pbData,
     
    32003208 *
    32013209 * @returns VBox status code.
    3202  * @param   pThis           VGA device instance data.
     3210 * @param   pThis           The shared VGA instance data.
    32033211 * @param   cid             Context id
    32043212 * @param   fFlags          VMSVGA3D_DEF_CTX_F_XXX.
     
    34353443 *
    34363444 * @returns VBox status code.
    3437  * @param   pThis           VGA device instance data.
     3445 * @param   pThis           The shared VGA instance data.
    34383446 * @param   cid             Context id
    34393447 */
     
    34473455 *
    34483456 * @returns VBox status code.
    3449  * @param   pThis           VGA device instance data.
     3457 * @param   pThis           The shared VGA instance data.
    34503458 * @param   pContext        The context to destroy.
    34513459 * @param   cid             Context id
     
    35453553 *
    35463554 * @returns VBox status code.
    3547  * @param   pThis           VGA device instance data.
     3555 * @param   pThis           The shared VGA instance data.
    35483556 * @param   cid             Context id
    35493557 */
     
    35673575 * Worker for vmsvga3dChangeMode that resizes a context.
    35683576 *
    3569  * @param   pThis               The VGA device instance data.
     3577 * @param   pThis               The shared VGA instance data.
    35703578 * @param   pState              The VMSVGA3d state.
    35713579 * @param   pContext            The context.
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-savedstate.cpp

    r82095 r82109  
    147147}
    148148
    149 int vmsvga3dLoadExec(PPDMDEVINS pDevIns, PVGASTATE pThis, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
     149int vmsvga3dLoadExec(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
    150150{
    151151    RT_NOREF(uPass);
     
    159159#ifndef RT_OS_DARWIN /** @todo r=bird: this is normally done on the EMT, so for DARWIN we do that when loading saved state too now. See DevVGA-SVGA.cpp */
    160160    /* Must initialize now as the recreation calls below rely on an initialized 3d subsystem. */
    161     vmsvga3dPowerOn(pThis);
     161    vmsvga3dPowerOn(pDevIns, pThis, pThisCC);
    162162#endif
    163163
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-win.cpp

    r82095 r82109  
    161161
    162162
    163 int vmsvga3dInit(PVGASTATE pThis)
    164 {
     163int vmsvga3dInit(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC)
     164{
     165    RT_NOREF(pDevIns, pThisCC);
     166
    165167    PVMSVGA3DSTATE pState;
    166     int rc;
    167 
    168168    pThis->svga.p3dState = pState = (PVMSVGA3DSTATE)RTMemAllocZ(sizeof(VMSVGA3DSTATE));
    169169    AssertReturn(pThis->svga.p3dState, VERR_NO_MEMORY);
    170170
    171171    /* Create event semaphore. */
    172     rc = RTSemEventCreate(&pState->WndRequestSem);
     172    int rc = RTSemEventCreate(&pState->WndRequestSem);
    173173    if (RT_FAILURE(rc))
    174174    {
     
    188188}
    189189
    190 int vmsvga3dPowerOn(PVGASTATE pThis)
     190int vmsvga3dPowerOn(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC)
    191191{
    192192    PVMSVGA3DSTATE pState = pThis->svga.p3dState;
    193193    AssertReturn(pThis->svga.p3dState, VERR_NO_MEMORY);
    194194    HRESULT hr;
     195    RT_NOREF(pDevIns, pThisCC);
    195196
    196197    if (pState->pD3D9)
     
    205206    PFNDIRECT3DCREATE9EX pfnDirect3dCreate9Ex = (PFNDIRECT3DCREATE9EX)RTLdrGetSystemSymbol("d3d9.dll", "Direct3DCreate9Ex");
    206207    if (!pfnDirect3dCreate9Ex)
    207         return PDMDevHlpVMSetError(pThis->CTX_SUFF(pDevIns), VERR_SYMBOL_NOT_FOUND, RT_SRC_POS,
     208        return PDMDevHlpVMSetError(pDevIns, VERR_SYMBOL_NOT_FOUND, RT_SRC_POS,
    208209                                   "vmsvga3d: Unable to locate Direct3DCreate9Ex. This feature requires Vista and later.");
    209210    hr = pfnDirect3dCreate9Ex(D3D_SDK_VERSION, &pState->pD3D9);
     
    23192320 *
    23202321 * @returns Failure status code or @a rc.
    2321  * @param   pThis               The VGA device instance data.
     2322 * @param   pThis               The shared VGA instance data.
     2323 * @param   pThisCC             The VGA/VMSVGA state for ring-3.
    23222324 * @param   pState              The VMSVGA3d state.
    23232325 * @param   pSurface            The host surface.
     
    23332335 * @param   iBox                The current box number (for Direct 3D).
    23342336 */
    2335 int vmsvga3dBackSurfaceDMACopyBox(PVGASTATE pThis, PVMSVGA3DSTATE pState, PVMSVGA3DSURFACE pSurface,
     2337int vmsvga3dBackSurfaceDMACopyBox(PVGASTATE pThis, PVGASTATECC pThisCC, PVMSVGA3DSTATE pState, PVMSVGA3DSURFACE pSurface,
    23362338                                  PVMSVGA3DMIPMAPLEVEL pMipLevel, uint32_t uHostFace, uint32_t uHostMipmap,
    23372339                                  SVGAGuestPtr GuestPtr, uint32_t cbGuestPitch, SVGA3dTransferType transfer,
     
    24142416
    24152417        rc = vmsvgaR3GmrTransfer(pThis,
     2418                                 pThisCC,
    24162419                                 transfer,
    24172420                                 pu8LockedBuf,
     
    24812484        /* Copy data between the guest and the host buffer. */
    24822485        rc = vmsvgaR3GmrTransfer(pThis,
     2486                                 pThisCC,
    24832487                                 transfer,
    24842488                                 (uint8_t *)pMipLevel->pSurfaceData,
     
    25582562 *
    25592563 * @returns VBox status code.
    2560  * @param   pThis           VGA device instance data.
     2564 * @param   pThis           The shared VGA instance data.
    25612565 * @param   cid             Context id
    25622566 */
     
    26562660 *
    26572661 * @returns VBox status code.
    2658  * @param   pThis           VGA device instance data.
     2662 * @param   pThis           The shared VGA instance data.
    26592663 * @param   cid             Context id
    26602664 */
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d.cpp

    r82095 r82109  
    4646 *
    4747 * @returns VBox status code (currently ignored).
    48  * @param   pThis               The VGA device instance data.
     48 * @param   pThis               The shared VGA instance data.
    4949 * @param   sid                 The ID of the surface to (re-)define.
    5050 * @param   surfaceFlags        .
     
    330330 *
    331331 * @returns VBox status code (currently ignored).
    332  * @param   pThis               The VGA device instance data.
     332 * @param   pThis               The shared VGA instance data.
    333333 * @param   sid                 The ID of the surface to destroy.
    334334 */
     
    379379 *
    380380 * @returns VBox status code (currently ignored).
    381  * @param   pThis               The VGA device instance data.
     381 * @param   pThis               The shared VGA instance data.
    382382 * @param   pDstSfcImg
    383383 * @param   pDstBox
     
    472472 *
    473473 * @returns VBox status code (currently ignored).
    474  * @param   pThis               The VGA device instance data.
     474 * @param   pThis               The shared VGA instance data.
     475 * @param   pThisCC             The VGA/VMSVGA state for ring-3.
    475476 * @param   guest               .
    476477 * @param   host                .
     
    479480 * @param   paBoxes             .
    480481 */
    481 int vmsvga3dSurfaceDMA(PVGASTATE pThis, SVGA3dGuestImage guest, SVGA3dSurfaceImageId host, SVGA3dTransferType transfer,
    482                        uint32_t cCopyBoxes, SVGA3dCopyBox *paBoxes)
     482int vmsvga3dSurfaceDMA(PVGASTATE pThis, PVGASTATECC pThisCC, SVGA3dGuestImage guest, SVGA3dSurfaceImageId host,
     483                       SVGA3dTransferType transfer, uint32_t cCopyBoxes, SVGA3dCopyBox *paBoxes)
    483484{
    484485    PVMSVGA3DSTATE pState = pThis->svga.p3dState;
     
    629630            {
    630631                rc = vmsvgaR3GmrTransfer(pThis,
     632                                         pThisCC,
    631633                                         transfer,
    632634                                         (uint8_t *)pMipLevel->pSurfaceData,
     
    661663            clipBox.srcy = srcy;
    662664            clipBox.srcz = srcz;
    663             rc = vmsvga3dBackSurfaceDMACopyBox(pThis, pState, pSurface, pMipLevel, host.face, host.mipmap,
     665            rc = vmsvga3dBackSurfaceDMACopyBox(pThis, pThisCC, pState, pSurface, pMipLevel, host.face, host.mipmap,
    664666                                               guest.ptr, cbGuestPitch, transfer,
    665667                                               &clipBox, pContext, rc, i);
     
    677679}
    678680
    679 static int vmsvga3dQueryWriteResult(PVGASTATE pThis, SVGAGuestPtr guestResult, SVGA3dQueryState enmState, uint32_t u32Result)
     681static int vmsvga3dQueryWriteResult(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAGuestPtr guestResult,
     682                                    SVGA3dQueryState enmState, uint32_t u32Result)
    680683{
    681684    SVGA3dQueryResult queryResult;
     
    684687    queryResult.result32 = u32Result;
    685688
    686     int rc = vmsvgaR3GmrTransfer(pThis, SVGA3D_READ_HOST_VRAM,
     689    int rc = vmsvgaR3GmrTransfer(pThis, pThisCC, SVGA3D_READ_HOST_VRAM,
    687690                                 (uint8_t *)&queryResult, sizeof(queryResult), 0, sizeof(queryResult),
    688691                                 guestResult, 0, sizeof(queryResult), sizeof(queryResult), 1);
     
    756759}
    757760
    758 int vmsvga3dQueryWait(PVGASTATE pThis, uint32_t cid, SVGA3dQueryType type, SVGAGuestPtr guestResult)
     761int vmsvga3dQueryWait(PVGASTATE pThis, PVGASTATECC pThisCC, uint32_t cid, SVGA3dQueryType type, SVGAGuestPtr guestResult)
    759762{
    760763    PVMSVGA3DSTATE pState = pThis->svga.p3dState;
     
    789792            {
    790793                /* Return data to the guest. */
    791                 vmsvga3dQueryWriteResult(pThis, guestResult, SVGA3D_QUERYSTATE_SUCCEEDED, p->u32QueryResult);
     794                vmsvga3dQueryWriteResult(pThis, pThisCC, guestResult, SVGA3D_QUERYSTATE_SUCCEEDED, p->u32QueryResult);
    792795                return VINF_SUCCESS;
    793796            }
     
    805808    }
    806809
    807     vmsvga3dQueryWriteResult(pThis, guestResult, SVGA3D_QUERYSTATE_FAILED, 0);
     810    vmsvga3dQueryWriteResult(pThis, pThisCC, guestResult, SVGA3D_QUERYSTATE_FAILED, 0);
    808811    AssertFailedReturn(rc);
    809812}
    810813
    811 int vmsvga3dSurfaceBlitToScreen(PVGASTATE pThis, uint32_t idDstScreen, SVGASignedRect destRect, SVGA3dSurfaceImageId src, SVGASignedRect srcRect, uint32_t cRects, SVGASignedRect *pRect)
     814int vmsvga3dSurfaceBlitToScreen(PVGASTATE pThis, PVGASTATECC pThisCC, uint32_t idDstScreen, SVGASignedRect destRect,
     815                                SVGA3dSurfaceImageId src, SVGASignedRect srcRect, uint32_t cRects, SVGASignedRect *pRect)
    812816{
    813817    /* Requires SVGA_FIFO_CAP_SCREEN_OBJECT support */
     
    859863        box.srcy    = destRect.top;
    860864
    861         int rc = vmsvga3dSurfaceDMA(pThis, dest, src, SVGA3D_READ_HOST_VRAM, 1, &box);
     865        int rc = vmsvga3dSurfaceDMA(pThis, pThisCC, dest, src, SVGA3D_READ_HOST_VRAM, 1, &box);
    862866        AssertRCReturn(rc, rc);
    863867
    864868        /* Update the guest image, which is at box.src. */
    865         vmsvgaR3UpdateScreen(pThis, pScreen, box.srcx, box.srcy, box.w, box.h);
     869        vmsvgaR3UpdateScreen(pThisCC, pScreen, box.srcx, box.srcy, box.w, box.h);
    866870    }
    867871    else
     
    884888            box.srcy = destRect.top  + pRect[i].top;
    885889
    886             int rc = vmsvga3dSurfaceDMA(pThis, dest, src, SVGA3D_READ_HOST_VRAM, 1, &box);
     890            int rc = vmsvga3dSurfaceDMA(pThis, pThisCC, dest, src, SVGA3D_READ_HOST_VRAM, 1, &box);
    887891            AssertRCReturn(rc, rc);
    888892
    889893            /* Update the guest image, which is at box.src. */
    890             vmsvgaR3UpdateScreen(pThis, pScreen, box.srcx, box.srcy, box.w, box.h);
     894            vmsvgaR3UpdateScreen(pThisCC, pScreen, box.srcx, box.srcy, box.w, box.h);
    891895        }
    892896    }
     
    895899}
    896900
    897 int vmsvga3dCommandPresent(PVGASTATE pThis, uint32_t sid, uint32_t cRects, SVGA3dCopyRect *pRect)
     901int vmsvga3dCommandPresent(PVGASTATE pThis, PVGASTATECC pThisCC, uint32_t sid, uint32_t cRects, SVGA3dCopyRect *pRect)
    898902{
    899903    /* Deprecated according to svga3d_reg.h. */
     
    949953
    950954        /* Entire rect. */
    951         rc = vmsvga3dSurfaceBlitToScreen(pThis, idDstScreen, destRect, src, srcRect, 0, NULL);
     955        rc = vmsvga3dSurfaceBlitToScreen(pThis, pThisCC, idDstScreen, destRect, src, srcRect, 0, NULL);
    952956        AssertRCReturn(rc, rc);
    953957    }
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d.h

    r82089 r82109  
    5656
    5757/* DevVGA-SVGA3d-ogl.cpp & DevVGA-SVGA3d-win.cpp: */
    58 int vmsvga3dInit(PVGASTATE pThis);
    59 int vmsvga3dPowerOn(PVGASTATE pThis);
    60 int vmsvga3dLoadExec(PPDMDEVINS pDevIns, PVGASTATE pThis, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass);
     58int vmsvga3dInit(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC);
     59int vmsvga3dPowerOn(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC);
     60int vmsvga3dLoadExec(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass);
    6161int vmsvga3dSaveExec(PPDMDEVINS pDevIns, PVGASTATE pThis, PSSMHANDLE pSSM);
    6262int vmsvga3dTerminate(PVGASTATE pThis);
     
    7070int vmsvga3dSurfaceStretchBlt(PVGASTATE pThis, SVGA3dSurfaceImageId const *pDstSfcImg, SVGA3dBox const *pDstBox,
    7171                              SVGA3dSurfaceImageId const *pSrcSfcImg, SVGA3dBox const *pSrcBox, SVGA3dStretchBltMode enmMode);
    72 int vmsvga3dSurfaceDMA(PVGASTATE pThis, SVGA3dGuestImage guest, SVGA3dSurfaceImageId host, SVGA3dTransferType transfer, uint32_t cCopyBoxes, SVGA3dCopyBox *pBoxes);
    73 int vmsvga3dSurfaceBlitToScreen(PVGASTATE pThis, uint32_t dest, SVGASignedRect destRect, SVGA3dSurfaceImageId src, SVGASignedRect srcRect, uint32_t cRects, SVGASignedRect *pRect);
     72int vmsvga3dSurfaceDMA(PVGASTATE pThis, PVGASTATECC pThisCC, SVGA3dGuestImage guest, SVGA3dSurfaceImageId host, SVGA3dTransferType transfer, uint32_t cCopyBoxes, SVGA3dCopyBox *pBoxes);
     73int vmsvga3dSurfaceBlitToScreen(PVGASTATE pThis, PVGASTATECC pThisCC, uint32_t dest, SVGASignedRect destRect, SVGA3dSurfaceImageId src, SVGASignedRect srcRect, uint32_t cRects, SVGASignedRect *pRect);
    7474
    7575int vmsvga3dContextDefine(PVGASTATE pThis, uint32_t cid);
     
    8989int vmsvga3dSetClipPlane(PVGASTATE pThis, uint32_t cid,  uint32_t index, float plane[4]);
    9090int vmsvga3dCommandClear(PVGASTATE pThis, uint32_t cid, SVGA3dClearFlag clearFlag, uint32_t color, float depth, uint32_t stencil, uint32_t cRects, SVGA3dRect *pRect);
    91 int vmsvga3dCommandPresent(PVGASTATE pThis, uint32_t sid, uint32_t cRects, SVGA3dCopyRect *pRect);
     91int vmsvga3dCommandPresent(PVGASTATE pThis, PVGASTATECC pThisCC, uint32_t sid, uint32_t cRects, SVGA3dCopyRect *pRect);
    9292int vmsvga3dDrawPrimitives(PVGASTATE pThis, uint32_t cid, uint32_t numVertexDecls, SVGA3dVertexDecl *pVertexDecl, uint32_t numRanges, SVGA3dPrimitiveRange *pNumRange, uint32_t cVertexDivisor, SVGA3dVertexDivisor *pVertexDivisor);
    9393int vmsvga3dSetScissorRect(PVGASTATE pThis, uint32_t cid, SVGA3dRect *pRect);
     
    101101int vmsvga3dQueryBegin(PVGASTATE pThis, uint32_t cid, SVGA3dQueryType type);
    102102int vmsvga3dQueryEnd(PVGASTATE pThis, uint32_t cid, SVGA3dQueryType type, SVGAGuestPtr guestResult);
    103 int vmsvga3dQueryWait(PVGASTATE pThis, uint32_t cid, SVGA3dQueryType type, SVGAGuestPtr guestResult);
     103int vmsvga3dQueryWait(PVGASTATE pThis, PVGASTATECC pThisCC, uint32_t cid, SVGA3dQueryType type, SVGAGuestPtr guestResult);
    104104
    105105/* DevVGA-SVGA3d-shared.h: */
  • trunk/src/VBox/Devices/Graphics/DevVGA.cpp

    r82102 r82109  
    5454#define PCIDEV_2_VGASTATE(pPciDev)      ((PVGASTATE)((uintptr_t)pPciDev - RT_OFFSETOF(VGASTATE, Dev)))
    5555#endif /* VBOX_WITH_HGSMI */
    56 /** Converts a vga adaptor state pointer to a device instance pointer. */
    57 #define VGASTATE2DEVINS(pVgaState)      ((pVgaState)->CTX_SUFF(pDevIns))
    5856
    5957/* VGA text mode blinking constants (cursor and blinking chars). */
     
    514512}
    515513
    516 static uint8_t vga_retrace(PVGASTATE pThis)
     514static uint8_t vga_retrace(PPDMDEVINS pDevIns, PVGASTATE pThis)
    517515{
    518516    vga_retrace_s   *r = &pThis->retrace_state;
     
    523521        uint64_t    time_ns;
    524522
    525         time_ns = PDMDevHlpTMTimeVirtGetNano(VGASTATE2DEVINS(pThis));
     523        time_ns = PDMDevHlpTMTimeVirtGetNano(pDevIns);
    526524
    527525        /* Determine the time within the frame. */
     
    558556}
    559557
    560 static uint32_t vga_ioport_read(PVGASTATE pThis, uint32_t addr)
     558static uint32_t vga_ioport_read(PPDMDEVINS pDevIns, PVGASTATE pThis, uint32_t addr)
    561559{
    562560    int val, index;
     
    630628        case 0x3ba:
    631629        case 0x3da:
    632             val = pThis->st01 = vga_retrace(pThis);
     630            val = pThis->st01 = vga_retrace(pDevIns, pThis);
    633631            pThis->ar_flip_flop = 0;
    634632            break;
     
    642640}
    643641
    644 static void vga_ioport_write(PVGASTATE pThis, uint32_t addr, uint32_t val)
     642static void vga_ioport_write(PPDMDEVINS pDevIns, PVGASTATE pThis, uint32_t addr, uint32_t val)
    645643{
    646644    int index;
     
    715713            if (pThis->fRemappedVGA)
    716714            {
    717                 PPDMDEVINS pDevIns = pThis->CTX_SUFF(pDevIns);
    718715                IOMMmioResetRegion(PDMDevHlpGetVM(pDevIns), pDevIns, pThis->hMmioLegacy);
    719716                pThis->fRemappedVGA = false;
     
    755752            if (pThis->fRemappedVGA)
    756753            {
    757                 PPDMDEVINS pDevIns = pThis->CTX_SUFF(pDevIns);
    758754                IOMMmioResetRegion(PDMDevHlpGetVM(pDevIns), pDevIns, pThis->hMmioLegacy);
    759755                pThis->fRemappedVGA = false;
     
    961957}
    962958
    963 static VBOXSTRICTRC vbe_ioport_write_data(PVGASTATE pThis, uint32_t addr, uint32_t val)
     959static VBOXSTRICTRC vbe_ioport_write_data(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC, uint32_t addr, uint32_t val)
    964960{
    965961    uint32_t max_bank;
    966     NOREF(addr);
     962    RT_NOREF(pThisCC, addr);
    967963
    968964    if (pThis->vbe_index <= VBE_DISPI_INDEX_NB) {
     
    10271023            if (pThis->fRemappedVGA)
    10281024            {
    1029                 PPDMDEVINS pDevIns = pThis->CTX_SUFF(pDevIns);
    10301025                IOMMmioResetRegion(PDMDevHlpGetVM(pDevIns), pDevIns, pThis->hMmioLegacy);
    10311026                pThis->fRemappedVGA = false;
     
    10711066                                         pThis->vbe_regs[VBE_DISPI_INDEX_VIRT_HEIGHT]);
    10721067                    uint16_t cbLinePitch = pThis->vbe_line_offset;
    1073                     memset(pThis->CTX_SUFF(vram_ptr), 0,
     1068                    memset(pThisCC->pbVRam, 0,
    10741069                           cY * cbLinePitch);
    10751070                }
     
    11291124             * and reset VBVA.
    11301125             */
    1131             pThis->pDrv->pfnLFBModeChange(pThis->pDrv, (val & VBE_DISPI_ENABLED) != 0);
     1126            pThisCC->pDrv->pfnLFBModeChange(pThisCC->pDrv, (val & VBE_DISPI_ENABLED) != 0);
    11321127#  ifdef VBOX_WITH_HGSMI
    1133             VBVAOnVBEChanged(pThis);
     1128            VBVAOnVBEChanged(pThis, pThisCC);
    11341129#  endif
    11351130
     
    11371132            if (pThis->fRemappedVGA)
    11381133            {
    1139                 PPDMDEVINS pDevIns = pThis->CTX_SUFF(pDevIns);
    11401134                IOMMmioResetRegion(PDMDevHlpGetVM(pDevIns), pDevIns, pThis->hMmioLegacy);
    11411135                pThis->fRemappedVGA = false;
     
    11581152            /* Changes in the VGA device are minimal. The device is bypassed. The driver does all work. */
    11591153            if (val == VBOX_VIDEO_DISABLE_ADAPTER_MEMORY)
    1160                 pThis->pDrv->pfnProcessAdapterData(pThis->pDrv, NULL, 0);
     1154                pThisCC->pDrv->pfnProcessAdapterData(pThisCC->pDrv, NULL, 0);
    11611155            else if (val == VBOX_VIDEO_INTERPRET_ADAPTER_MEMORY)
    1162                 pThis->pDrv->pfnProcessAdapterData(pThis->pDrv, pThis->CTX_SUFF(vram_ptr), pThis->vram_size);
     1156                pThisCC->pDrv->pfnProcessAdapterData(pThisCC->pDrv, pThisCC->pbVRam, pThis->vram_size);
    11631157            else if ((val & 0xFFFF0000) == VBOX_VIDEO_INTERPRET_DISPLAY_MEMORY_BASE)
    1164                 pThis->pDrv->pfnProcessDisplayData(pThis->pDrv, pThis->CTX_SUFF(vram_ptr), val & 0xFFFF);
     1158                pThisCC->pDrv->pfnProcessDisplayData(pThisCC->pDrv, pThisCC->pbVRam, val & 0xFFFF);
    11651159# endif /* IN_RING3 */
    11661160            break;
     
    11811175
    11821176/* called for accesses between 0xa0000 and 0xc0000 */
    1183 static uint32_t vga_mem_readb(PVGASTATE pThis, RTGCPHYS addr, int *prc)
     1177static uint32_t vga_mem_readb(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC, RTGCPHYS addr, int *prc)
    11841178{
    11851179    int plane;
     
    12391233            /** @todo only allow read access (doesn't work now) */
    12401234            STAM_COUNTER_INC(&pThis->StatMapPage);
    1241             PPDMDEVINS pDevIns = pThis->CTX_SUFF(pDevIns);
    12421235            IOMMmioMapMmio2Page(PDMDevHlpGetVM(pDevIns), pDevIns, pThis->hMmioLegacy, GCPhys - 0xa0000,
    12431236                                pThis->hMmio2VRam, addr, X86_PTE_RW | X86_PTE_P);
     
    12491242        VERIFY_VRAM_READ_OFF_RETURN(pThis, addr, *prc);
    12501243#ifdef VMSVGA_WITH_VGA_FB_BACKUP_AND_IN_RING3
    1251         ret = !pThis->svga.fEnabled            ? pThis->CTX_SUFF(vram_ptr)[addr]
     1244        ret = !pThis->svga.fEnabled            ? pThisCC->pbVRam[addr]
    12521245            : addr < VMSVGA_VGA_FB_BACKUP_SIZE ? pThis->svga.pbVgaFrameBufferR3[addr] : 0xff;
    12531246#else
    1254         ret = pThis->CTX_SUFF(vram_ptr)[addr];
     1247        ret = pThisCC->pbVRam[addr];
    12551248#endif
    12561249    } else if (!(pThis->sr[4] & 0x04)) {    /* Host access is controlled by SR4, not GR5! */
     
    12611254        VERIFY_VRAM_READ_OFF_RETURN(pThis, off, *prc);
    12621255#ifdef VMSVGA_WITH_VGA_FB_BACKUP_AND_IN_RING3
    1263         ret = !pThis->svga.fEnabled           ? pThis->CTX_SUFF(vram_ptr)[off]
     1256        ret = !pThis->svga.fEnabled           ? pThisCC->pbVRam[off]
    12641257            : off < VMSVGA_VGA_FB_BACKUP_SIZE ? pThis->svga.pbVgaFrameBufferR3[off] : 0xff;
    12651258#else
    1266         ret = pThis->CTX_SUFF(vram_ptr)[off];
     1259        ret = pThisCC->pbVRam[off];
    12671260#endif
    12681261    } else {
     
    12701263        VERIFY_VRAM_READ_OFF_RETURN(pThis, addr * 4 + 3, *prc);
    12711264#ifdef VMSVGA_WITH_VGA_FB_BACKUP_AND_IN_RING3
    1272         pThis->latch = !pThis->svga.fEnabled            ? ((uint32_t *)pThis->CTX_SUFF(vram_ptr))[addr]
     1265        pThis->latch = !pThis->svga.fEnabled            ? ((uint32_t *)pThisCC->pbVRam)[addr]
    12731266                     : addr < VMSVGA_VGA_FB_BACKUP_SIZE ? ((uint32_t *)pThis->svga.pbVgaFrameBufferR3)[addr] : UINT32_MAX;
    12741267#else
    1275         pThis->latch = ((uint32_t *)pThis->CTX_SUFF(vram_ptr))[addr];
     1268        pThis->latch = ((uint32_t *)pThisCC->pbVRam)[addr];
    12761269#endif
    12771270        if (!(pThis->gr[5] & 0x08)) {
     
    12941287 * called for accesses between 0xa0000 and 0xc0000
    12951288 */
    1296 static VBOXSTRICTRC vga_mem_writeb(PVGASTATE pThis, RTGCPHYS addr, uint32_t val)
     1289static VBOXSTRICTRC vga_mem_writeb(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC, RTGCPHYS addr, uint32_t val)
    12971290{
    12981291    int plane, write_mode, b, func_select, mask;
     
    13481341            {
    13491342                STAM_COUNTER_INC(&pThis->StatMapPage);
    1350                 PPDMDEVINS pDevIns = pThis->CTX_SUFF(pDevIns);
    13511343                IOMMmioMapMmio2Page(PDMDevHlpGetVM(pDevIns), pDevIns, pThis->hMmioLegacy, GCPhys - 0xa0000,
    13521344                                    pThis->hMmio2VRam, addr, X86_PTE_RW | X86_PTE_P);
     
    13581350#ifdef VMSVGA_WITH_VGA_FB_BACKUP_AND_IN_RING3
    13591351            if (!pThis->svga.fEnabled)
    1360                 pThis->CTX_SUFF(vram_ptr)[addr]      = val;
     1352                pThisCC->pbVRam[addr]      = val;
    13611353            else if (addr < VMSVGA_VGA_FB_BACKUP_SIZE)
    13621354                pThis->svga.pbVgaFrameBufferR3[addr] = val;
     
    13671359            }
    13681360#else
    1369             pThis->CTX_SUFF(vram_ptr)[addr] = val;
     1361            pThisCC->pbVRam[addr] = val;
    13701362#endif
    13711363            Log3(("vga: chain4: [0x%x]\n", addr));
     
    13871379#ifdef VMSVGA_WITH_VGA_FB_BACKUP_AND_IN_RING3
    13881380            if (!pThis->svga.fEnabled)
    1389                 pThis->CTX_SUFF(vram_ptr)[addr]      = val;
     1381                pThisCC->pbVRam[addr]      = val;
    13901382            else if (addr < VMSVGA_VGA_FB_BACKUP_SIZE)
    13911383                pThis->svga.pbVgaFrameBufferR3[addr] = val;
     
    13961388            }
    13971389#else
    1398             pThis->CTX_SUFF(vram_ptr)[addr] = val;
     1390            pThisCC->pbVRam[addr] = val;
    13991391#endif
    14001392            Log3(("vga: odd/even: [0x%x]\n", addr));
     
    14721464        uint32_t *pu32Dst;
    14731465        if (!pThis->svga.fEnabled)
    1474             pu32Dst = &((uint32_t *)pThis->CTX_SUFF(vram_ptr))[addr];
     1466            pu32Dst = &((uint32_t *)pThisCC->pbVRam)[addr];
    14751467        else if (addr * 4 + 3 < VMSVGA_VGA_FB_BACKUP_SIZE)
    14761468            pu32Dst = &((uint32_t *)pThis->svga.pbVgaFrameBufferR3)[addr];
     
    14821474        *pu32Dst = (*pu32Dst & ~write_mask) | (val & write_mask);
    14831475#else
    1484         ((uint32_t *)pThis->CTX_SUFF(vram_ptr))[addr] = (((uint32_t *)pThis->CTX_SUFF(vram_ptr))[addr] & ~write_mask)
     1476        ((uint32_t *)pThisCC->pbVRam)[addr] = (((uint32_t *)pThisCC->pbVRam)[addr] & ~write_mask)
    14851477                                                      | (val & write_mask);
    14861478#endif
     
    15011493                                  const uint8_t *font_ptr, int h,
    15021494                                  uint32_t fgcol, uint32_t bgcol, int dup9);
    1503 typedef void vga_draw_line_func(PVGASTATE pThis, uint8_t *pbDst, const uint8_t *pbSrc, int width);
     1495typedef void vga_draw_line_func(PVGASTATE pThis, PVGASTATECC pThisCC, uint8_t *pbDst, const uint8_t *pbSrc, int width);
    15041496
    15051497static inline unsigned int rgb_to_pixel8(unsigned int r, unsigned int g, unsigned b)
     
    15661558
    15671559/** return true if the palette was modified */
    1568 static bool vgaR3UpdatePalette16(PVGASTATE pThis)
     1560static bool vgaR3UpdatePalette16(PVGASTATE pThis, PVGASTATER3 pThisCC)
    15691561{
    15701562    bool full_update = false;
     
    15801572            v = ((pThis->ar[0x14] & 0xc) << 4) | (v & 0x3f);
    15811573        v = v * 3;
    1582         col = pThis->rgb_to_pixel(c6_to_8(pThis->palette[v]),
    1583                                   c6_to_8(pThis->palette[v + 1]),
    1584                                   c6_to_8(pThis->palette[v + 2]));
     1574        col = pThisCC->rgb_to_pixel(c6_to_8(pThis->palette[v]),
     1575                                    c6_to_8(pThis->palette[v + 1]),
     1576                                    c6_to_8(pThis->palette[v + 2]));
    15851577        if (col != palette[i]) {
    15861578            full_update = true;
     
    15921584
    15931585/** return true if the palette was modified */
    1594 static bool vgaR3UpdatePalette256(PVGASTATE pThis)
     1586static bool vgaR3UpdatePalette256(PVGASTATE pThis, PVGASTATER3 pThisCC)
    15951587{
    15961588    bool full_update = false;
     
    16051597    for(i = 0; i < 256; i++) {
    16061598        if (wide_dac)
    1607             col = pThis->rgb_to_pixel(pThis->palette[v],
    1608                                       pThis->palette[v + 1],
    1609                                       pThis->palette[v + 2]);
     1599            col = pThisCC->rgb_to_pixel(pThis->palette[v],
     1600                                        pThis->palette[v + 1],
     1601                                        pThis->palette[v + 2]);
    16101602        else
    1611             col = pThis->rgb_to_pixel(c6_to_8(pThis->palette[v]),
    1612                                       c6_to_8(pThis->palette[v + 1]),
    1613                                       c6_to_8(pThis->palette[v + 2]));
     1603            col = pThisCC->rgb_to_pixel(c6_to_8(pThis->palette[v]),
     1604                                        c6_to_8(pThis->palette[v + 1]),
     1605                                        c6_to_8(pThis->palette[v + 2]));
    16141606        if (col != palette[i]) {
    16151607            full_update = true;
     
    16581650
    16591651/** update start_addr and line_offset. Return TRUE if modified */
    1660 static bool vgaR3UpdateBasicParams(PVGASTATE pThis)
     1652static bool vgaR3UpdateBasicParams(PVGASTATE pThis, PVGASTATER3 pThisCC)
    16611653{
    16621654    bool full_update = false;
    16631655    uint32_t start_addr, line_offset, line_compare;
    16641656
    1665     pThis->get_offsets(pThis, &line_offset, &start_addr, &line_compare);
     1657    pThisCC->get_offsets(pThis, &line_offset, &start_addr, &line_compare);
    16661658
    16671659    if (line_offset != pThis->line_offset ||
     
    17381730 * - underline
    17391731 */
    1740 static int vgaR3DrawText(PVGASTATE pThis, bool full_update, bool fFailOnResize, bool reset_dirty, PDMIDISPLAYCONNECTOR *pDrv)
     1732static int vgaR3DrawText(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATER3 pThisCC, bool full_update,
     1733                         bool fFailOnResize, bool reset_dirty, PDMIDISPLAYCONNECTOR *pDrv)
    17411734{
    17421735    int cx, cy, cheight, cw, ch, cattr, height, width, ch_attr;
     
    17551748    bool blink_enabled, blink_do_redraw;
    17561749
    1757     full_update |= vgaR3UpdatePalette16(pThis);
     1750    full_update |= vgaR3UpdatePalette16(pThis, pThisCC);
    17581751    palette = pThis->last_palette;
    17591752
     
    17651758        full_update = true;
    17661759    }
    1767     font_base[0] = pThis->CTX_SUFF(vram_ptr) + offset;
     1760    font_base[0] = pThisCC->pbVRam + offset;
    17681761
    17691762    offset = (((v >> 5) & 1) | ((v >> 1) & 6)) * 8192 * 4 + 2;
    1770     font_base[1] = pThis->CTX_SUFF(vram_ptr) + offset;
     1763    font_base[1] = pThisCC->pbVRam + offset;
    17711764    if (offset != pThis->font_offsets[1]) {
    17721765        pThis->font_offsets[1] = offset;
     
    17791772        full_update = true;
    17801773    }
    1781     full_update |= vgaR3UpdateBasicParams(pThis);
     1774    full_update |= vgaR3UpdateBasicParams(pThis, pThisCC);
    17821775
    17831776    line_offset = pThis->line_offset;
    1784     s1 = pThis->CTX_SUFF(vram_ptr) + (pThis->start_addr * 8); /** @todo r=bird: Add comment why we do *8 instead of *4, it's not so obvious... */
     1777    s1 = pThisCC->pbVRam + (pThis->start_addr * 8); /** @todo r=bird: Add comment why we do *8 instead of *4, it's not so obvious... */
    17851778
    17861779    /* double scanning - not for 9-wide modes */
     
    18441837        pThis->cursor_end = pThis->cr[0xb];
    18451838    }
    1846     cursor_ptr = pThis->CTX_SUFF(vram_ptr) + (pThis->start_addr + cursor_offset) * 8;
     1839    cursor_ptr = pThisCC->pbVRam + (pThis->start_addr + cursor_offset) * 8;
    18471840    depth_index = vgaR3GetDepthIndex(pDrv->cBits);
    18481841    if (cw == 16)
     
    18601853
    18611854    /* Figure out if we're in the visible period of the blink cycle. */
    1862     time_ns  = PDMDevHlpTMTimeVirtGetNano(VGASTATE2DEVINS(pThis));
     1855    time_ns  = PDMDevHlpTMTimeVirtGetNano(pDevIns);
    18631856    blink_on = (time_ns % VGA_BLINK_PERIOD_FULL) < VGA_BLINK_PERIOD_ON;
    18641857    chr_blink_flip = false;
     
    20842077 * @returns VINF_SUCCESS on success.
    20852078 * @returns VINF_VGA_RESIZE_IN_PROGRESS if the operation wasn't complete.
    2086  * @param   pThis   Pointer to the vga state.
     2079 * @param   pThis   Pointer to the shared VGA state.
     2080 * @param   pThisCC Pointer to the ring-3 VGA state.
    20872081 * @param   cx      The width.
    20882082 * @param   cy      The height.
    20892083 * @param   pDrv    The display connector.
    20902084 */
    2091 static int vgaR3ResizeGraphic(PVGASTATE pThis, int cx, int cy, PDMIDISPLAYCONNECTOR *pDrv)
    2092 {
    2093     const unsigned cBits = pThis->get_bpp(pThis);
     2085static int vgaR3ResizeGraphic(PVGASTATE pThis, PVGASTATER3 pThisCC, int cx, int cy, PDMIDISPLAYCONNECTOR *pDrv)
     2086{
     2087    const unsigned cBits = pThisCC->get_bpp(pThis);
    20942088
    20952089    int rc;
     
    21092103     *
    21102104     * The reason for doing this for WDDM driver only now is to avoid regressions of the current code */
    2111     PVBOXVDMAHOST pVdma = pThis->pVdma;
     2105    PVBOXVDMAHOST pVdma = pThisCC->pVdma;
    21122106    if (pVdma && vboxVDMAIsEnabled(pVdma))
    21132107        rc = VINF_SUCCESS;
     
    21182112        if (pThis->start_addr * 4 + pThis->line_offset * cy < pThis->vram_size)
    21192113            /* Take into account the programmed start address (in DWORDs) of the visible screen. */
    2120             rc = pDrv->pfnResize(pDrv, cBits, pThis->CTX_SUFF(vram_ptr) + pThis->start_addr * 4, pThis->line_offset, cx, cy);
     2114            rc = pDrv->pfnResize(pDrv, cBits, pThisCC->pbVRam + pThis->start_addr * 4, pThis->line_offset, cx, cy);
    21212115        else
    21222116        {
     
    21402134    switch (pDrv->cBits)
    21412135    {
    2142         case 32:    pThis->rgb_to_pixel = rgb_to_pixel32_dup; break;
     2136        case 32:    pThisCC->rgb_to_pixel = rgb_to_pixel32_dup; break;
    21432137        case 16:
    2144         default:    pThis->rgb_to_pixel = rgb_to_pixel16_dup; break;
    2145         case 15:    pThis->rgb_to_pixel = rgb_to_pixel15_dup; break;
    2146         case 8:     pThis->rgb_to_pixel = rgb_to_pixel8_dup;  break;
     2138        default:    pThisCC->rgb_to_pixel = rgb_to_pixel16_dup; break;
     2139        case 15:    pThisCC->rgb_to_pixel = rgb_to_pixel15_dup; break;
     2140        case 8:     pThisCC->rgb_to_pixel = rgb_to_pixel8_dup;  break;
    21472141    }
    21482142    if (pThis->shift_control == 0)
    2149         vgaR3UpdatePalette16(pThis);
     2143        vgaR3UpdatePalette16(pThis, pThisCC);
    21502144    else if (pThis->shift_control == 1)
    2151         vgaR3UpdatePalette16(pThis);
     2145        vgaR3UpdatePalette16(pThis, pThisCC);
    21522146    return VINF_SUCCESS;
    21532147}
     
    22252219 * graphic modes
    22262220 */
    2227 static int vmsvgaR3DrawGraphic(PVGASTATE pThis, bool fFullUpdate, bool fFailOnResize, bool reset_dirty,
    2228                                PDMIDISPLAYCONNECTOR *pDrv)
     2221static int vmsvgaR3DrawGraphic(PVGASTATE pThis, PVGASTATER3 pThisCC, bool fFullUpdate,
     2222                               bool fFailOnResize, bool reset_dirty, PDMIDISPLAYCONNECTOR *pDrv)
    22292223{
    22302224    RT_NOREF1(fFailOnResize);
     
    22752269    vga_draw_line_func *pfnVgaDrawLine = vga_draw_line_table[v * 4 + vgaR3GetDepthIndex(pDrv->cBits)];
    22762270
    2277     Assert(!pThis->cursor_invalidate);
    2278     Assert(!pThis->cursor_draw_line);
    2279     //not used// if (pThis->cursor_invalidate)
    2280     //not used//     pThis->cursor_invalidate(pThis);
     2271    Assert(!pThisCC->cursor_invalidate);
     2272    Assert(!pThisCC->cursor_draw_line);
     2273    //not used// if (pThisCC->cursor_invalidate)
     2274    //not used//     pThisCC->cursor_invalidate(pThis);
    22812275
    22822276    uint8_t    *pbDst          = pDrv->pbData;
     
    23122306                offPageMax = offPage1;
    23132307            if (pThis->fRenderVRAM)
    2314                 pfnVgaDrawLine(pThis, pbDst, pThis->CTX_SUFF(vram_ptr) + offSrcLine, cx);
    2315             //not used// if (pThis->cursor_draw_line)
    2316             //not used//     pThis->cursor_draw_line(pThis, pbDst, y);
     2308                pfnVgaDrawLine(pThis, pThisCC, pbDst, pThisCC->pbVRam + offSrcLine, cx);
     2309            //not used// if (pThisCC->cursor_draw_line)
     2310            //not used//     pThisCC->cursor_draw_line(pThis, pbDst, y);
    23172311        }
    23182312        else if (yUpdateRectTop != UINT32_MAX)
     
    23452339 * graphic modes
    23462340 */
    2347 static int vgaR3DrawGraphic(PVGASTATE pThis, bool full_update, bool fFailOnResize, bool reset_dirty,
     2341static int vgaR3DrawGraphic(PVGASTATE pThis, PVGASTATER3 pThisCC, bool full_update, bool fFailOnResize, bool reset_dirty,
    23482342                            PDMIDISPLAYCONNECTOR *pDrv)
    23492343{
     
    23532347    uint8_t *d;
    23542348    uint32_t v, addr1, addr;
    2355     vga_draw_line_func *vga_draw_line;
    2356 
    2357     bool offsets_changed = vgaR3UpdateBasicParams(pThis);
     2349    vga_draw_line_func *pfnVgaDrawLine;
     2350
     2351    bool offsets_changed = vgaR3UpdateBasicParams(pThis, pThisCC);
    23582352
    23592353    full_update |= offsets_changed;
    23602354
    2361     pThis->get_resolution(pThis, &width, &height);
     2355    pThisCC->get_resolution(pThis, &width, &height);
    23622356    disp_width = width;
    23632357
     
    23732367
    23742368    if (shift_control == 0) {
    2375         full_update |= vgaR3UpdatePalette16(pThis);
     2369        full_update |= vgaR3UpdatePalette16(pThis, pThisCC);
    23762370        if (pThis->sr[0x01] & 8) {
    23772371            v = VGA_DRAW_LINE4D2;
     
    23822376        bits = 4;
    23832377    } else if (shift_control == 1) {
    2384         full_update |= vgaR3UpdatePalette16(pThis);
     2378        full_update |= vgaR3UpdatePalette16(pThis, pThisCC);
    23852379        if (pThis->sr[0x01] & 8) {
    23862380            v = VGA_DRAW_LINE2D2;
     
    23912385        bits = 4;
    23922386    } else {
    2393         switch(pThis->get_bpp(pThis)) {
     2387        switch(pThisCC->get_bpp(pThis)) {
    23942388        default:
    23952389        case 0:
    2396             full_update |= vgaR3UpdatePalette256(pThis);
     2390            full_update |= vgaR3UpdatePalette256(pThis, pThisCC);
    23972391            v = VGA_DRAW_LINE8D2;
    23982392            bits = 4;
    23992393            break;
    24002394        case 8:
    2401             full_update |= vgaR3UpdatePalette256(pThis);
     2395            full_update |= vgaR3UpdatePalette256(pThis, pThisCC);
    24022396            v = VGA_DRAW_LINE8;
    24032397            bits = 8;
     
    24232417    if (    disp_width     != (int)pThis->last_width
    24242418        ||  height         != (int)pThis->last_height
    2425         ||  pThis->get_bpp(pThis)  != (int)pThis->last_bpp
     2419        ||  pThisCC->get_bpp(pThis)  != (int)pThis->last_bpp
    24262420        || (offsets_changed && !pThis->fRenderVRAM))
    24272421    {
     
    24312425            return VERR_TRY_AGAIN;
    24322426        }
    2433         int rc = vgaR3ResizeGraphic(pThis, disp_width, height, pDrv);
     2427        int rc = vgaR3ResizeGraphic(pThis, pThisCC, disp_width, height, pDrv);
    24342428        if (rc != VINF_SUCCESS)  /* Return any rc, particularly VINF_VGA_RESIZE_IN_PROGRESS, to the caller. */
    24352429            return rc;
     
    24532447    }
    24542448
    2455     vga_draw_line = vga_draw_line_table[v * 4 + vgaR3GetDepthIndex(pDrv->cBits)];
    2456 
    2457     if (pThis->cursor_invalidate)
    2458         pThis->cursor_invalidate(pThis);
     2449    pfnVgaDrawLine = vga_draw_line_table[v * 4 + vgaR3GetDepthIndex(pDrv->cBits)];
     2450
     2451    if (pThisCC->cursor_invalidate)
     2452        pThisCC->cursor_invalidate(pThis);
    24592453
    24602454    line_offset = pThis->line_offset;
     
    25112505                page_max = page1;
    25122506            if (pThis->fRenderVRAM)
    2513                 vga_draw_line(pThis, d, pThis->CTX_SUFF(vram_ptr) + addr, width);
    2514             if (pThis->cursor_draw_line)
    2515                 pThis->cursor_draw_line(pThis, d, y);
     2507                pfnVgaDrawLine(pThis, pThisCC, d, pThisCC->pbVRam + addr, width);
     2508            if (pThisCC->cursor_draw_line)
     2509                pThisCC->cursor_draw_line(pThis, d, y);
    25162510        } else {
    25172511            if (y_start >= 0) {
     
    25542548 * blanked modes
    25552549 */
    2556 static int vgaR3DrawBlank(PVGASTATE pThis, bool full_update, bool fFailOnResize, bool reset_dirty,
    2557                           PDMIDISPLAYCONNECTOR *pDrv)
     2550static int vgaR3DrawBlank(PVGASTATE pThis, PVGASTATER3 pThisCC, bool full_update,
     2551                          bool fFailOnResize, bool reset_dirty, PDMIDISPLAYCONNECTOR *pDrv)
    25582552{
    25592553    int i, w, val;
     
    25852579        vgaR3ResetDirty(pThis, page_min, page_max + PAGE_SIZE);
    25862580    }
    2587     if (pDrv->pbData == pThis->vram_ptrR3) /* Do not clear the VRAM itself. */
     2581    if (pDrv->pbData == pThisCC->pbVRam) /* Do not clear the VRAM itself. */
    25882582        return VINF_SUCCESS;
    25892583    if (!full_update)
     
    25922586        return VINF_SUCCESS;
    25932587    if (pDrv->cBits == 8)
    2594         val = pThis->rgb_to_pixel(0, 0, 0);
     2588        val = pThisCC->rgb_to_pixel(0, 0, 0);
    25952589    else
    25962590        val = 0;
     
    26202614 * vgaR3PortTakeScreenshot().
    26212615 */
    2622 static int vgaR3UpdateDisplay(PVGASTATE pThis, bool fUpdateAll, bool fFailOnResize, bool reset_dirty,
    2623                               PDMIDISPLAYCONNECTOR *pDrv, int32_t *pcur_graphic_mode)
     2616static int vgaR3UpdateDisplay(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATER3 pThisCC, bool fUpdateAll,
     2617                              bool fFailOnResize, bool reset_dirty, PDMIDISPLAYCONNECTOR *pDrv, int32_t *pcur_graphic_mode)
    26242618{
    26252619    int rc = VINF_SUCCESS;
     
    26312625        switch(pDrv->cBits) {
    26322626        case 8:
    2633             pThis->rgb_to_pixel = rgb_to_pixel8_dup;
     2627            pThisCC->rgb_to_pixel = rgb_to_pixel8_dup;
    26342628            break;
    26352629        case 15:
    2636             pThis->rgb_to_pixel = rgb_to_pixel15_dup;
     2630            pThisCC->rgb_to_pixel = rgb_to_pixel15_dup;
    26372631            break;
    26382632        default:
    26392633        case 16:
    2640             pThis->rgb_to_pixel = rgb_to_pixel16_dup;
     2634            pThisCC->rgb_to_pixel = rgb_to_pixel16_dup;
    26412635            break;
    26422636        case 32:
    2643             pThis->rgb_to_pixel = rgb_to_pixel32_dup;
     2637            pThisCC->rgb_to_pixel = rgb_to_pixel32_dup;
    26442638            break;
    26452639        }
     
    26622656        switch(graphic_mode) {
    26632657        case GMODE_TEXT:
    2664             rc = vgaR3DrawText(pThis, full_update, fFailOnResize, reset_dirty, pDrv);
     2658            rc = vgaR3DrawText(pDevIns, pThis, pThisCC, full_update, fFailOnResize, reset_dirty, pDrv);
    26652659            break;
    26662660        case GMODE_GRAPH:
    2667             rc = vgaR3DrawGraphic(pThis, full_update, fFailOnResize, reset_dirty, pDrv);
     2661            rc = vgaR3DrawGraphic(pThis, pThisCC, full_update, fFailOnResize, reset_dirty, pDrv);
    26682662            break;
    26692663#ifdef VBOX_WITH_VMSVGA
    26702664        case GMODE_SVGA:
    2671             rc = vmsvgaR3DrawGraphic(pThis, full_update, fFailOnResize, reset_dirty, pDrv);
     2665            rc = vmsvgaR3DrawGraphic(pThis, pThisCC, full_update, fFailOnResize, reset_dirty, pDrv);
    26722666            break;
    26732667#endif
    26742668        case GMODE_BLANK:
    26752669        default:
    2676             rc = vgaR3DrawBlank(pThis, full_update, fFailOnResize, reset_dirty, pDrv);
     2670            rc = vgaR3DrawBlank(pThis, pThisCC, full_update, fFailOnResize, reset_dirty, pDrv);
    26772671            break;
    26782672        }
     
    28422836        NOREF(pvUser); \
    28432837        if (cb == 1) \
    2844             vga_ioport_write(pThis, offPort, u32); \
     2838            vga_ioport_write(pDevIns, pThis, offPort, u32); \
    28452839        else if (cb == 2) \
    28462840        { \
    2847             vga_ioport_write(pThis, offPort, u32 & 0xff); \
    2848             vga_ioport_write(pThis, offPort + 1, u32 >> 8); \
     2841            vga_ioport_write(pDevIns, pThis, offPort, u32 & 0xff); \
     2842            vga_ioport_write(pDevIns, pThis, offPort + 1, u32 >> 8); \
    28492843        } \
    28502844        return VINF_SUCCESS; \
     
    28582852        NOREF(pvUser); \
    28592853        if (cb == 1) \
    2860             *pu32 = vga_ioport_read(pThis, offPort); \
     2854            *pu32 = vga_ioport_read(pDevIns, pThis, offPort); \
    28612855        else if (cb == 2) \
    28622856        { \
    2863             uint32_t u32 = vga_ioport_read(pThis, offPort); \
    2864             u32 |= vga_ioport_read(pThis, offPort + 1) << 8; \
     2857            uint32_t u32 = vga_ioport_read(pDevIns, pThis, offPort); \
     2858            u32 |= vga_ioport_read(pDevIns, pThis, offPort + 1) << 8; \
    28652859            *pu32 = u32; \
    28662860        } \
     
    30713065vgaIoPortWriteVbeData(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb)
    30723066{
    3073     PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     3067    PVGASTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     3068    PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
    30743069    Assert(PDMDevHlpCritSectIsOwner(pDevIns, pDevIns->CTX_SUFF(pCritSectRo)));
    30753070
     
    30963091            {
    30973092                pThis->fWriteVBEData = false;
    3098                 return vbe_ioport_write_data(pThis, offPort, u32 & 0xFF);
     3093                return vbe_ioport_write_data(pDevIns, pThis, pThisCC, offPort, u32 & 0xFF);
    30993094            }
    31003095
     
    31103105#endif
    31113106    if (cb == 2 || cb == 4)
    3112         return vbe_ioport_write_data(pThis, offPort, u32);
     3107        return vbe_ioport_write_data(pDevIns, pThis, pThisCC, offPort, u32);
    31133108    AssertMsgFailed(("vgaIoPortWriteVbeData: offPort=%#x cb=%d u32=%#x\n", offPort, cb, u32));
    31143109
     
    32313226vgaR3IOPortHgsmiWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb)
    32323227{
    3233     PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     3228    PVGASTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     3229    PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
    32343230    Assert(PDMDevHlpCritSectIsOwner(pDevIns, pDevIns->CTX_SUFF(pCritSectRo)));
    32353231    LogFlowFunc(("offPort=0x%x u32=0x%x cb=%u\n", offPort, u32, cb));
     
    32513247                    {
    32523248                        PDMDevHlpPCISetIrqNoWait(pDevIns, 0, PDM_IRQ_LEVEL_LOW);
    3253                         HGSMIClearHostGuestFlags(pThis->pHGSMI,
     3249                        HGSMIClearHostGuestFlags(pThisCC->pHGSMI,
    32543250                                                 HGSMIHOSTFLAGS_IRQ
    32553251                                                 | HGSMIHOSTFLAGS_VSYNC
     
    32593255                    else
    32603256                    {
    3261                         HGSMISetHostGuestFlags(pThis->pHGSMI, HGSMIHOSTFLAGS_IRQ | pThis->fu32PendingGuestFlags);
     3257                        HGSMISetHostGuestFlags(pThisCC->pHGSMI, HGSMIHOSTFLAGS_IRQ | pThis->fu32PendingGuestFlags);
    32623258                        pThis->fu32PendingGuestFlags = 0;
    32633259                        /* Keep the IRQ unchanged. */
     
    32693265# endif
    32703266                {
    3271                     HGSMIHostWrite(pThis->pHGSMI, u32);
     3267                    HGSMIHostWrite(pThisCC->pHGSMI, u32);
    32723268                }
    32733269                break;
     
    32753271
    32763272            case VGA_PORT_HGSMI_GUEST: /* Guest */
    3277                 HGSMIGuestWrite(pThis->pHGSMI, u32);
     3273                HGSMIGuestWrite(pThisCC->pHGSMI, u32);
    32783274                break;
    32793275
     
    33073303vgaR3IOPortHgmsiRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t *pu32, unsigned cb)
    33083304{
    3309     PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     3305    PVGASTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     3306    PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
    33103307    Assert(PDMDevHlpCritSectIsOwner(pDevIns, pDevIns->CTX_SUFF(pCritSectRo)));
    33113308    LogFlowFunc(("offPort=0x%x cb=%d\n", offPort, cb));
     
    33193316        {
    33203317            case VGA_PORT_HGSMI_HOST: /* Host */
    3321                 *pu32 = HGSMIHostRead(pThis->pHGSMI);
     3318                *pu32 = HGSMIHostRead(pThisCC->pHGSMI);
    33223319                break;
    33233320            case VGA_PORT_HGSMI_GUEST: /* Guest */
    3324                 *pu32 = HGSMIGuestRead(pThis->pHGSMI);
     3321                *pu32 = HGSMIGuestRead(pThisCC->pHGSMI);
    33253322                break;
    33263323            default:
     
    33893386 * @param   cItems      Number of data items to write.
    33903387 */
    3391 static int vgaInternalMMIOFill(PVGASTATE pThis, void *pvUser, RTGCPHYS GCPhysAddr,
     3388static int vgaInternalMMIOFill(PVGASTATE pThis, PVGASTATECC pThisCC, void *pvUser, RTGCPHYS GCPhysAddr,
    33923389                               uint32_t u32Item, unsigned cbItem, unsigned cItems)
    33933390{
     
    34373434                if (pThis->sr[2] & (1 << (GCPhysAddr & 3)))
    34383435                {
    3439                     pThis->CTX_SUFF(vram_ptr)[GCPhysAddr] = aVal[i];
     3436                    pThisCC->pbVRam[GCPhysAddr] = aVal[i];
    34403437                    vgaR3MarkDirty(pThis, GCPhysAddr);
    34413438                }
     
    34513448                if (pThis->sr[2] & (1 << plane)) {
    34523449                    RTGCPHYS PhysAddr2 = ((GCPhysAddr & ~1) * 4) | plane;
    3453                     pThis->CTX_SUFF(vram_ptr)[PhysAddr2] = aVal[i];
     3450                    pThisCC->pbVRam[PhysAddr2] = aVal[i];
    34543451                    vgaR3MarkDirty(pThis, PhysAddr2);
    34553452                }
     
    35233520            while (cItems-- > 0)
    35243521            {
    3525                 ((uint32_t *)pThis->CTX_SUFF(vram_ptr))[GCPhysAddr] = (((uint32_t *)pThis->CTX_SUFF(vram_ptr))[GCPhysAddr] & ~write_mask) | (aVal[0] & write_mask);
     3522                ((uint32_t *)pThisCC->pbVRam)[GCPhysAddr] = (((uint32_t *)pThisCC->pbVRam)[GCPhysAddr] & ~write_mask) | (aVal[0] & write_mask);
    35263523                vgaR3MarkDirty(pThis, GCPhysAddr * 4);
    35273524                GCPhysAddr++;
     
    35333530            while (cItems-- > 0)
    35343531            {
    3535                 ((uint32_t *)pThis->CTX_SUFF(vram_ptr))[GCPhysAddr] = (((uint32_t *)pThis->CTX_SUFF(vram_ptr))[GCPhysAddr] & ~write_mask) | (aVal[0] & write_mask);
     3532                ((uint32_t *)pThisCC->pbVRam)[GCPhysAddr] = (((uint32_t *)pThisCC->pbVRam)[GCPhysAddr] & ~write_mask) | (aVal[0] & write_mask);
    35363533                vgaR3MarkDirty(pThis, GCPhysAddr * 4);
    35373534                GCPhysAddr++;
    35383535
    3539                 ((uint32_t *)pThis->CTX_SUFF(vram_ptr))[GCPhysAddr] = (((uint32_t *)pThis->CTX_SUFF(vram_ptr))[GCPhysAddr] & ~write_mask) | (aVal[1] & write_mask);
     3536                ((uint32_t *)pThisCC->pbVRam)[GCPhysAddr] = (((uint32_t *)pThisCC->pbVRam)[GCPhysAddr] & ~write_mask) | (aVal[1] & write_mask);
    35403537                vgaR3MarkDirty(pThis, GCPhysAddr * 4);
    35413538                GCPhysAddr++;
     
    35493546                for (i = 0; i < cbItem; i++)
    35503547                {
    3551                     ((uint32_t *)pThis->CTX_SUFF(vram_ptr))[GCPhysAddr] = (((uint32_t *)pThis->CTX_SUFF(vram_ptr))[GCPhysAddr] & ~write_mask) | (aVal[i] & write_mask);
     3548                    ((uint32_t *)pThisCC->pbVRam)[GCPhysAddr] = (((uint32_t *)pThisCC->pbVRam)[GCPhysAddr] & ~write_mask) | (aVal[i] & write_mask);
    35523549                    vgaR3MarkDirty(pThis, GCPhysAddr * 4);
    35533550                    GCPhysAddr++;
     
    35693566vgaMmioFill(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, uint32_t u32Item, unsigned cbItem, unsigned cItems)
    35703567{
    3571     PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     3568    PVGASTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     3569    PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
    35723570    Assert(PDMDevHlpCritSectIsOwner(pDevIns, pDevIns->CTX_SUFF(pCritSectRo)));
    35733571
    3574     return vgaInternalMMIOFill(pThis, pvUser, off, u32Item, cbItem, cItems);
     3572    return vgaInternalMMIOFill(pThis, pThisCC, pvUser, off, u32Item, cbItem, cItems);
    35753573}
    35763574
     
    35823580static DECLCALLBACK(VBOXSTRICTRC) vgaMmioRead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void *pv, unsigned cb)
    35833581{
    3584     PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     3582    PVGASTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     3583    PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
    35853584    STAM_PROFILE_START(&pThis->CTX_MID_Z(Stat,MemoryRead), a);
    35863585    Assert(PDMDevHlpCritSectIsOwner(pDevIns, pDevIns->CTX_SUFF(pCritSectRo)));
     
    35913590    {
    35923591        case 1:
    3593             *(uint8_t  *)pv = vga_mem_readb(pThis, off, &rc);
     3592            *(uint8_t  *)pv = vga_mem_readb(pDevIns, pThis, pThisCC, off, &rc);
    35943593            break;
    35953594        case 2:
     
    35973596 *        crossing the 512KB VRAM boundrary if the access is handled in
    35983597 *        ring-0 and operating in latched mode. */
    3599             *(uint16_t *)pv = vga_mem_readb(pThis, off, &rc)
    3600                            | (vga_mem_readb(pThis, off + 1, &rc) << 8);
     3598            *(uint16_t *)pv = vga_mem_readb(pDevIns, pThis, pThisCC, off, &rc)
     3599                           | (vga_mem_readb(pDevIns, pThis, pThisCC, off + 1, &rc) << 8);
    36013600            break;
    36023601        case 4:
    3603             *(uint32_t *)pv = vga_mem_readb(pThis, off, &rc)
    3604                            | (vga_mem_readb(pThis, off + 1, &rc) <<  8)
    3605                            | (vga_mem_readb(pThis, off + 2, &rc) << 16)
    3606                            | (vga_mem_readb(pThis, off + 3, &rc) << 24);
     3602            *(uint32_t *)pv = vga_mem_readb(pDevIns, pThis, pThisCC, off, &rc)
     3603                           | (vga_mem_readb(pDevIns, pThis, pThisCC, off + 1, &rc) <<  8)
     3604                           | (vga_mem_readb(pDevIns, pThis, pThisCC, off + 2, &rc) << 16)
     3605                           | (vga_mem_readb(pDevIns, pThis, pThisCC, off + 3, &rc) << 24);
    36073606            break;
    36083607
    36093608        case 8:
    3610             *(uint64_t *)pv = (uint64_t)vga_mem_readb(pThis, off, &rc)
    3611                            | ((uint64_t)vga_mem_readb(pThis, off + 1, &rc) <<  8)
    3612                            | ((uint64_t)vga_mem_readb(pThis, off + 2, &rc) << 16)
    3613                            | ((uint64_t)vga_mem_readb(pThis, off + 3, &rc) << 24)
    3614                            | ((uint64_t)vga_mem_readb(pThis, off + 4, &rc) << 32)
    3615                            | ((uint64_t)vga_mem_readb(pThis, off + 5, &rc) << 40)
    3616                            | ((uint64_t)vga_mem_readb(pThis, off + 6, &rc) << 48)
    3617                            | ((uint64_t)vga_mem_readb(pThis, off + 7, &rc) << 56);
     3609            *(uint64_t *)pv = (uint64_t)vga_mem_readb(pDevIns, pThis, pThisCC, off, &rc)
     3610                           | ((uint64_t)vga_mem_readb(pDevIns, pThis, pThisCC, off + 1, &rc) <<  8)
     3611                           | ((uint64_t)vga_mem_readb(pDevIns, pThis, pThisCC, off + 2, &rc) << 16)
     3612                           | ((uint64_t)vga_mem_readb(pDevIns, pThis, pThisCC, off + 3, &rc) << 24)
     3613                           | ((uint64_t)vga_mem_readb(pDevIns, pThis, pThisCC, off + 4, &rc) << 32)
     3614                           | ((uint64_t)vga_mem_readb(pDevIns, pThis, pThisCC, off + 5, &rc) << 40)
     3615                           | ((uint64_t)vga_mem_readb(pDevIns, pThis, pThisCC, off + 6, &rc) << 48)
     3616                           | ((uint64_t)vga_mem_readb(pDevIns, pThis, pThisCC, off + 7, &rc) << 56);
    36183617            break;
    36193618
     
    36233622            while (cb-- > 0)
    36243623            {
    3625                 *pbData++ = vga_mem_readb(pThis, off++, &rc);
     3624                *pbData++ = vga_mem_readb(pDevIns, pThis, pThisCC, off++, &rc);
    36263625                if (RT_UNLIKELY(rc != VINF_SUCCESS))
    36273626                    break;
     
    36403639static DECLCALLBACK(VBOXSTRICTRC) vgaMmioWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void const *pv, unsigned cb)
    36413640{
    3642     PVGASTATE      pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
    3643     uint8_t const *pbSrc = (uint8_t const *)pv;
     3641    PVGASTATE     pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     3642    PVGASTATECC   pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
     3643    uint8_t const *pbSrc  = (uint8_t const *)pv;
    36443644    NOREF(pvUser);
    36453645    STAM_PROFILE_START(&pThis->CTX_MID_Z(Stat,MemoryWrite), a);
     
    36503650    {
    36513651        case 1:
    3652             rc = vga_mem_writeb(pThis, off, *pbSrc);
     3652            rc = vga_mem_writeb(pDevIns, pThis, pThisCC, off, *pbSrc);
    36533653            break;
    36543654#if 1
    36553655        case 2:
    3656             rc = vga_mem_writeb(pThis, off + 0, pbSrc[0]);
     3656            rc = vga_mem_writeb(pDevIns, pThis, pThisCC, off + 0, pbSrc[0]);
    36573657            if (RT_LIKELY(rc == VINF_SUCCESS))
    3658                 rc = vga_mem_writeb(pThis, off + 1, pbSrc[1]);
     3658                rc = vga_mem_writeb(pDevIns, pThis, pThisCC, off + 1, pbSrc[1]);
    36593659            break;
    36603660        case 4:
    3661             rc = vga_mem_writeb(pThis, off + 0, pbSrc[0]);
     3661            rc = vga_mem_writeb(pDevIns, pThis, pThisCC, off + 0, pbSrc[0]);
    36623662            if (RT_LIKELY(rc == VINF_SUCCESS))
    3663                 rc = vga_mem_writeb(pThis, off + 1, pbSrc[1]);
     3663                rc = vga_mem_writeb(pDevIns, pThis, pThisCC, off + 1, pbSrc[1]);
    36643664            if (RT_LIKELY(rc == VINF_SUCCESS))
    3665                 rc = vga_mem_writeb(pThis, off + 2, pbSrc[2]);
     3665                rc = vga_mem_writeb(pDevIns, pThis, pThisCC, off + 2, pbSrc[2]);
    36663666            if (RT_LIKELY(rc == VINF_SUCCESS))
    3667                 rc = vga_mem_writeb(pThis, off + 3, pbSrc[3]);
     3667                rc = vga_mem_writeb(pDevIns, pThis, pThisCC, off + 3, pbSrc[3]);
    36683668            break;
    36693669        case 8:
    3670             rc = vga_mem_writeb(pThis, off + 0, pbSrc[0]);
     3670            rc = vga_mem_writeb(pDevIns, pThis, pThisCC, off + 0, pbSrc[0]);
    36713671            if (RT_LIKELY(rc == VINF_SUCCESS))
    3672                 rc = vga_mem_writeb(pThis, off + 1, pbSrc[1]);
     3672                rc = vga_mem_writeb(pDevIns, pThis, pThisCC, off + 1, pbSrc[1]);
    36733673            if (RT_LIKELY(rc == VINF_SUCCESS))
    3674                 rc = vga_mem_writeb(pThis, off + 2, pbSrc[2]);
     3674                rc = vga_mem_writeb(pDevIns, pThis, pThisCC, off + 2, pbSrc[2]);
    36753675            if (RT_LIKELY(rc == VINF_SUCCESS))
    3676                 rc = vga_mem_writeb(pThis, off + 3, pbSrc[3]);
     3676                rc = vga_mem_writeb(pDevIns, pThis, pThisCC, off + 3, pbSrc[3]);
    36773677            if (RT_LIKELY(rc == VINF_SUCCESS))
    3678                 rc = vga_mem_writeb(pThis, off + 4, pbSrc[4]);
     3678                rc = vga_mem_writeb(pDevIns, pThis, pThisCC, off + 4, pbSrc[4]);
    36793679            if (RT_LIKELY(rc == VINF_SUCCESS))
    3680                 rc = vga_mem_writeb(pThis, off + 5, pbSrc[5]);
     3680                rc = vga_mem_writeb(pDevIns, pThis, pThisCC, off + 5, pbSrc[5]);
    36813681            if (RT_LIKELY(rc == VINF_SUCCESS))
    3682                 rc = vga_mem_writeb(pThis, off + 6, pbSrc[6]);
     3682                rc = vga_mem_writeb(pDevIns, pThis, pThisCC, off + 6, pbSrc[6]);
    36833683            if (RT_LIKELY(rc == VINF_SUCCESS))
    3684                 rc = vga_mem_writeb(pThis, off + 7, pbSrc[7]);
     3684                rc = vga_mem_writeb(pDevIns, pThis, pThisCC, off + 7, pbSrc[7]);
    36853685            break;
    36863686#else
     
    36983698            rc = VINF_SUCCESS;
    36993699            while (cb-- > 0 && rc == VINF_SUCCESS)
    3700                 rc = vga_mem_writeb(pThis, off++, *pbSrc++);
     3700                rc = vga_mem_writeb(pDevIns, pThis, pThisCC, off++, *pbSrc++);
    37013701            break;
    37023702
     
    37123712 * @returns Strict VBox status code.
    37133713 * @param   pVM         VM handle.
    3714  * @param   pThis       VGA device instance data.
     3714 * @param   pDevIns     The device instance.
     3715 * @param   pThis       The shared VGA instance data.
    37153716 * @param   GCPhys      The access physical address.
    37163717 * @param   GCPtr       The access virtual address (only GC).
    37173718 */
    3718 static VBOXSTRICTRC vgaLFBAccess(PVMCC pVM, PVGASTATE pThis, RTGCPHYS GCPhys, RTGCPTR GCPtr)
    3719 {
    3720     VBOXSTRICTRC rc = PDMDevHlpCritSectEnter(pThis->CTX_SUFF(pDevIns), &pThis->CritSect, VINF_EM_RAW_EMULATE_INSTR);
     3719static VBOXSTRICTRC vgaLFBAccess(PVMCC pVM, PPDMDEVINS pDevIns, PVGASTATE pThis, RTGCPHYS GCPhys, RTGCPTR GCPtr)
     3720{
     3721    VBOXSTRICTRC rc = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VINF_EM_RAW_EMULATE_INSTR);
    37213722    if (rc == VINF_SUCCESS)
    37223723    {
     
    37363737        {
    37373738#ifndef IN_RING3
    3738             rc = PGMShwMakePageWritable(PDMDevHlpGetVMCPU(pThis->CTX_SUFF(pDevIns)), GCPtr,
     3739            rc = PGMShwMakePageWritable(PDMDevHlpGetVMCPU(pDevIns), GCPtr,
    37393740                                        PGM_MK_PG_IS_MMIO2 | PGM_MK_PG_IS_WRITE_FAULT);
    3740             PDMDevHlpCritSectLeave(pThis->CTX_SUFF(pDevIns), &pThis->CritSect);
     3741            PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
    37413742            AssertMsgReturn(    rc == VINF_SUCCESS
    37423743                            /* In the SMP case the page table might be removed while we wait for the PGM lock in the trap handler. */
     
    37463747                            VBOXSTRICTRC_VAL(rc));
    37473748#else  /* IN_RING3 - We don't have any virtual page address of the access here. */
    3748             PDMDevHlpCritSectLeave(pThis->CTX_SUFF(pDevIns), &pThis->CritSect);
     3749            PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
    37493750            Assert(GCPtr == 0);
    37503751            RT_NOREF1(GCPtr);
     
    37533754        }
    37543755
    3755         PDMDevHlpCritSectLeave(pThis->CTX_SUFF(pDevIns), &pThis->CritSect);
     3756        PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
    37563757        AssertMsgFailed(("PGMHandlerPhysicalPageTempOff -> rc=%d\n", VBOXSTRICTRC_VAL(rc)));
    37573758    }
     
    37673768                                                  RTGCPTR pvFault, RTGCPHYS GCPhysFault, void *pvUser)
    37683769{
    3769     PVGASTATE   pThis = (PVGASTATE)pvUser;
    3770     AssertPtr(pThis);
     3770    PPDMDEVINS  pDevIns = (PPDMDEVINS)pvUser;
     3771    PVGASTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     3772    //PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
    37713773    Assert(GCPhysFault >= pThis->GCPhysVRAM);
    37723774    AssertMsg(uErrorCode & X86_TRAP_PF_RW, ("uErrorCode=%#x\n", uErrorCode));
    37733775    RT_NOREF3(pVCpu, pRegFrame, uErrorCode);
    37743776
    3775     return vgaLFBAccess(pVM, pThis, GCPhysFault, pvFault);
     3777    return vgaLFBAccess(pVM, pDevIns, pThis, GCPhysFault, pvFault);
    37763778}
    37773779#endif /* !IN_RING3 */
     
    37863788                                                  PGMACCESSORIGIN enmOrigin, void *pvUser)
    37873789{
    3788     PVGASTATE pThis = (PVGASTATE)pvUser;
    3789     Assert(pThis);
     3790    PPDMDEVINS  pDevIns = (PPDMDEVINS)pvUser;
     3791    PVGASTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     3792    //PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
    37903793    Assert(GCPhys >= pThis->GCPhysVRAM);
    37913794    RT_NOREF(pVCpu, pvPhys, pvBuf, cbBuf, enmAccessType, enmOrigin);
    37923795
    3793     VBOXSTRICTRC rc = vgaLFBAccess(pVM, pThis, GCPhys, 0);
     3796    VBOXSTRICTRC rc = vgaLFBAccess(pVM, pDevIns, pThis, GCPhys, 0);
    37943797    if (rc == VINF_SUCCESS)
    37953798        rc = VINF_PGM_HANDLER_DO_DEFAULT;
     
    38683871vbeR3IOPortWriteVbeExtra(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb)
    38693872{
    3870     PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     3873    PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
    38713874    Assert(PDMDevHlpCritSectIsOwner(pDevIns, pDevIns->CTX_SUFF(pCritSectRo)));
    38723875    RT_NOREF(offPort, pvUser);
     
    38753878    {
    38763879        Log(("vbeR3IOPortWriteVbeExtra: addr=%#RX32\n", u32));
    3877         pThis->u16VBEExtraAddress = u32;
     3880        pThisCC->u16VBEExtraAddress = u32;
    38783881    }
    38793882    else
     
    38913894vbeR3IoPortReadVbeExtra(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t *pu32, unsigned cb)
    38923895{
    3893     PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     3896    PVGASTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     3897    PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
    38943898    Assert(PDMDevHlpCritSectIsOwner(pDevIns, pDevIns->CTX_SUFF(pCritSectRo)));
    38953899    RT_NOREF(offPort, pvUser);
    38963900
    38973901    int rc = VINF_SUCCESS;
    3898     if (pThis->u16VBEExtraAddress == 0xffff)
     3902    if (pThisCC->u16VBEExtraAddress == 0xffff)
    38993903    {
    39003904        Log(("vbeR3IoPortReadVbeExtra: Requested number of 64k video banks\n"));
    39013905        *pu32 = pThis->vram_size / _64K;
    39023906    }
    3903     else if (   pThis->u16VBEExtraAddress >= pThis->cbVBEExtraData
    3904              || pThis->u16VBEExtraAddress + cb > pThis->cbVBEExtraData)
     3907    else if (   pThisCC->u16VBEExtraAddress >= pThisCC->cbVBEExtraData
     3908             || pThisCC->u16VBEExtraAddress + cb > pThisCC->cbVBEExtraData)
    39053909    {
    39063910        *pu32 = 0;
    39073911        Log(("vbeR3IoPortReadVbeExtra: Requested address is out of VBE data!!! Address=%#x(%d) cbVBEExtraData=%#x(%d)\n",
    3908              pThis->u16VBEExtraAddress, pThis->u16VBEExtraAddress, pThis->cbVBEExtraData, pThis->cbVBEExtraData));
     3912             pThisCC->u16VBEExtraAddress, pThisCC->u16VBEExtraAddress, pThisCC->cbVBEExtraData, pThisCC->cbVBEExtraData));
    39093913    }
    39103914    else
     
    39133917        if (cb == 1)
    39143918        {
    3915             *pu32 = pThis->pbVBEExtraData[pThis->u16VBEExtraAddress] & 0xFF;
     3919            *pu32 = pThisCC->pbVBEExtraData[pThisCC->u16VBEExtraAddress] & 0xFF;
    39163920
    39173921            Log(("vbeR3IoPortReadVbeExtra: cb=%#x %.*Rhxs\n", cb, cb, pu32));
     
    39193923        else if (cb == 2)
    39203924        {
    3921             *pu32 =           pThis->pbVBEExtraData[pThis->u16VBEExtraAddress]
    3922                   | (uint32_t)pThis->pbVBEExtraData[pThis->u16VBEExtraAddress + 1] << 8;
     3925            *pu32 =           pThisCC->pbVBEExtraData[pThisCC->u16VBEExtraAddress]
     3926                  | (uint32_t)pThisCC->pbVBEExtraData[pThisCC->u16VBEExtraAddress + 1] << 8;
    39233927
    39243928            Log(("vbeR3IoPortReadVbeExtra: cb=%#x %.*Rhxs\n", cb, cb, pu32));
     
    39423946 * @param   pThis       The VGA instance data.
    39433947 */
    3944 static int vbeR3ParseBitmap(PVGASTATE pThis)
     3948static int vbeR3ParseBitmap(PVGASTATECC pThisCC)
    39453949{
    39463950    /*
    39473951     * Get bitmap header data
    39483952     */
    3949     PBMPINFO pBmpInfo = (PBMPINFO)(pThis->pbLogo + sizeof(LOGOHDR));
    3950     PWINHDR  pWinHdr  = (PWINHDR)(pThis->pbLogo + sizeof(LOGOHDR) + sizeof(BMPINFO));
     3953    PBMPINFO pBmpInfo = (PBMPINFO)(pThisCC->pbLogo + sizeof(LOGOHDR));
     3954    PWINHDR  pWinHdr  = (PWINHDR)(pThisCC->pbLogo + sizeof(LOGOHDR) + sizeof(BMPINFO));
    39513955
    39523956    if (pBmpInfo->Type == BMP_ID)
     
    39573961            {
    39583962                POS2HDR pOs2Hdr = (POS2HDR)pWinHdr;
    3959                 pThis->cxLogo = pOs2Hdr->Width;
    3960                 pThis->cyLogo = pOs2Hdr->Height;
    3961                 pThis->cLogoPlanes = pOs2Hdr->Planes;
    3962                 pThis->cLogoBits = pOs2Hdr->BitCount;
    3963                 pThis->LogoCompression = BMP_COMPRESS_NONE;
    3964                 pThis->cLogoUsedColors = 0;
     3963                pThisCC->cxLogo = pOs2Hdr->Width;
     3964                pThisCC->cyLogo = pOs2Hdr->Height;
     3965                pThisCC->cLogoPlanes = pOs2Hdr->Planes;
     3966                pThisCC->cLogoBits = pOs2Hdr->BitCount;
     3967                pThisCC->LogoCompression = BMP_COMPRESS_NONE;
     3968                pThisCC->cLogoUsedColors = 0;
    39653969                break;
    39663970            }
     
    39693973            {
    39703974                POS22HDR pOs22Hdr = (POS22HDR)pWinHdr;
    3971                 pThis->cxLogo = pOs22Hdr->Width;
    3972                 pThis->cyLogo = pOs22Hdr->Height;
    3973                 pThis->cLogoPlanes = pOs22Hdr->Planes;
    3974                 pThis->cLogoBits = pOs22Hdr->BitCount;
    3975                 pThis->LogoCompression = pOs22Hdr->Compression;
    3976                 pThis->cLogoUsedColors = pOs22Hdr->ClrUsed;
     3975                pThisCC->cxLogo = pOs22Hdr->Width;
     3976                pThisCC->cyLogo = pOs22Hdr->Height;
     3977                pThisCC->cLogoPlanes = pOs22Hdr->Planes;
     3978                pThisCC->cLogoBits = pOs22Hdr->BitCount;
     3979                pThisCC->LogoCompression = pOs22Hdr->Compression;
     3980                pThisCC->cLogoUsedColors = pOs22Hdr->ClrUsed;
    39773981                break;
    39783982            }
    39793983
    39803984            case BMP_HEADER_WIN3:
    3981                 pThis->cxLogo = pWinHdr->Width;
    3982                 pThis->cyLogo = pWinHdr->Height;
    3983                 pThis->cLogoPlanes = pWinHdr->Planes;
    3984                 pThis->cLogoBits = pWinHdr->BitCount;
    3985                 pThis->LogoCompression = pWinHdr->Compression;
    3986                 pThis->cLogoUsedColors = pWinHdr->ClrUsed;
     3985                pThisCC->cxLogo = pWinHdr->Width;
     3986                pThisCC->cyLogo = pWinHdr->Height;
     3987                pThisCC->cLogoPlanes = pWinHdr->Planes;
     3988                pThisCC->cLogoBits = pWinHdr->BitCount;
     3989                pThisCC->LogoCompression = pWinHdr->Compression;
     3990                pThisCC->cLogoUsedColors = pWinHdr->ClrUsed;
    39873991                break;
    39883992
     
    39933997        }
    39943998
    3995         AssertLogRelMsgReturn(pThis->cxLogo <= LOGO_MAX_WIDTH && pThis->cyLogo <= LOGO_MAX_HEIGHT,
    3996                               ("Bitmap %ux%u is too big.\n", pThis->cxLogo, pThis->cyLogo),
     3999        AssertLogRelMsgReturn(pThisCC->cxLogo <= LOGO_MAX_WIDTH && pThisCC->cyLogo <= LOGO_MAX_HEIGHT,
     4000                              ("Bitmap %ux%u is too big.\n", pThisCC->cxLogo, pThisCC->cyLogo),
    39974001                              VERR_INVALID_PARAMETER);
    39984002
    3999         AssertLogRelMsgReturn(pThis->cLogoPlanes == 1,
    4000                               ("Bitmap planes %u != 1.\n", pThis->cLogoPlanes),
     4003        AssertLogRelMsgReturn(pThisCC->cLogoPlanes == 1,
     4004                              ("Bitmap planes %u != 1.\n", pThisCC->cLogoPlanes),
    40014005                              VERR_INVALID_PARAMETER);
    40024006
    4003         AssertLogRelMsgReturn(pThis->cLogoBits == 4 || pThis->cLogoBits == 8 || pThis->cLogoBits == 24,
    4004                               ("Unsupported %u depth.\n", pThis->cLogoBits),
     4007        AssertLogRelMsgReturn(pThisCC->cLogoBits == 4 || pThisCC->cLogoBits == 8 || pThisCC->cLogoBits == 24,
     4008                              ("Unsupported %u depth.\n", pThisCC->cLogoBits),
    40054009                              VERR_INVALID_PARAMETER);
    40064010
    4007         AssertLogRelMsgReturn(pThis->cLogoUsedColors <= 256,
    4008                               ("Unsupported %u colors.\n", pThis->cLogoUsedColors),
     4011        AssertLogRelMsgReturn(pThisCC->cLogoUsedColors <= 256,
     4012                              ("Unsupported %u colors.\n", pThisCC->cLogoUsedColors),
    40094013                              VERR_INVALID_PARAMETER);
    40104014
    4011         AssertLogRelMsgReturn(pThis->LogoCompression == BMP_COMPRESS_NONE,
    4012                                ("Unsupported %u compression.\n", pThis->LogoCompression),
     4015        AssertLogRelMsgReturn(pThisCC->LogoCompression == BMP_COMPRESS_NONE,
     4016                               ("Unsupported %u compression.\n", pThisCC->LogoCompression),
    40134017                               VERR_INVALID_PARAMETER);
    40144018
     
    40164020         * Read bitmap palette
    40174021         */
    4018         if (!pThis->cLogoUsedColors)
    4019             pThis->cLogoPalEntries = 1 << (pThis->cLogoPlanes * pThis->cLogoBits);
     4022        if (!pThisCC->cLogoUsedColors)
     4023            pThisCC->cLogoPalEntries = 1 << (pThisCC->cLogoPlanes * pThisCC->cLogoBits);
    40204024        else
    4021             pThis->cLogoPalEntries = pThis->cLogoUsedColors;
    4022 
    4023         if (pThis->cLogoPalEntries)
     4025            pThisCC->cLogoPalEntries = pThisCC->cLogoUsedColors;
     4026
     4027        if (pThisCC->cLogoPalEntries)
    40244028        {
    4025             const uint8_t *pbPal = pThis->pbLogo + sizeof(LOGOHDR) + sizeof(BMPINFO) + pWinHdr->Size; /* ASSUMES Size location (safe) */
    4026 
    4027             for (uint16_t i = 0; i < pThis->cLogoPalEntries; i++)
     4029            const uint8_t *pbPal = pThisCC->pbLogo + sizeof(LOGOHDR) + sizeof(BMPINFO) + pWinHdr->Size; /* ASSUMES Size location (safe) */
     4030
     4031            for (uint16_t i = 0; i < pThisCC->cLogoPalEntries; i++)
    40284032            {
    40294033                uint16_t j;
     
    40384042
    40394043                pbPal++; /* skip unused byte */
    4040                 pThis->au32LogoPalette[i] = u32Pal;
     4044                pThisCC->au32LogoPalette[i] = u32Pal;
    40414045            }
    40424046        }
     
    40454049         * Bitmap data offset
    40464050         */
    4047         pThis->pbLogoBitmap = pThis->pbLogo + sizeof(LOGOHDR) + pBmpInfo->Offset;
     4051        pThisCC->pbLogoBitmap = pThisCC->pbLogo + sizeof(LOGOHDR) + pBmpInfo->Offset;
    40484052    }
    40494053    else
     
    42084212vbeR3IoPortWriteCmdLogo(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb)
    42094213{
    4210     PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     4214    PVGASTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     4215    PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
    42114216    RT_NOREF(pvUser, offPort);
    42124217
     
    42194224        {
    42204225            case LOGO_CMD_SET_OFFSET:
    4221                 pThis->offLogoData = u32 & 0xFF;
     4226                pThisCC->offLogoData = u32 & 0xFF;
    42224227                break;
    42234228
     
    42254230            {
    42264231                uint8_t         iStep = u32 & 0xFF;
    4227                 const uint8_t  *pbSrc = pThis->pbLogoBitmap;
     4232                const uint8_t  *pbSrc = pThisCC->pbLogoBitmap;
    42284233                uint8_t        *pbDst;
    4229                 PCLOGOHDR       pLogoHdr = (PCLOGOHDR)pThis->pbLogo;
     4234                PCLOGOHDR       pLogoHdr = (PCLOGOHDR)pThisCC->pbLogo;
    42304235                uint32_t        offDirty = 0;
    4231                 uint16_t        xLogo = (LOGO_MAX_WIDTH - pThis->cxLogo) / 2;
    4232                 uint16_t        yLogo = LOGO_MAX_HEIGHT - (LOGO_MAX_HEIGHT - pThis->cyLogo) / 2;
     4236                uint16_t        xLogo = (LOGO_MAX_WIDTH - pThisCC->cxLogo) / 2;
     4237                uint16_t        yLogo = LOGO_MAX_HEIGHT - (LOGO_MAX_HEIGHT - pThisCC->cyLogo) / 2;
    42334238
    42344239                /* Check VRAM size */
     
    42374242
    42384243                if (pThis->vram_size >= LOGO_MAX_SIZE * 2)
    4239                     pbDst = pThis->vram_ptrR3 + LOGO_MAX_SIZE;
     4244                    pbDst = pThisCC->pbVRam + LOGO_MAX_SIZE;
    42404245                else
    4241                     pbDst = pThis->vram_ptrR3;
     4246                    pbDst = pThisCC->pbVRam;
    42424247
    42434248                /* Clear screen - except on power on... */
    4244                 if (!pThis->fLogoClearScreen)
     4249                if (!pThisCC->fLogoClearScreen)
    42454250                {
    42464251                    /* Clear vram */
     
    42494254                        for (int j = 0; j < LOGO_MAX_HEIGHT; j++)
    42504255                            *pu32Dst++ = 0;
    4251                     pThis->fLogoClearScreen = true;
     4256                    pThisCC->fLogoClearScreen = true;
    42524257                }
    42534258
    42544259                /* Show the bitmap. */
    4255                 vbeR3ShowBitmap(pThis->cLogoBits, xLogo, yLogo,
    4256                               pThis->cxLogo, pThis->cyLogo,
    4257                               false, iStep, &pThis->au32LogoPalette[0],
    4258                               pbSrc, pbDst);
     4260                vbeR3ShowBitmap(pThisCC->cLogoBits, xLogo, yLogo,
     4261                                pThisCC->cxLogo, pThisCC->cyLogo,
     4262                                false, iStep, &pThisCC->au32LogoPalette[0],
     4263                                pbSrc, pbDst);
    42594264
    42604265                /* Show the 'Press F12...' text. */
    42614266                if (pLogoHdr->fu8ShowBootMenu == 2)
    42624267                    vbeR3ShowBitmap(1, LOGO_F12TEXT_X, LOGO_F12TEXT_Y,
    4263                                   LOGO_F12TEXT_WIDTH, LOGO_F12TEXT_HEIGHT,
    4264                                   pThis->fBootMenuInverse, iStep, &pThis->au32LogoPalette[0],
    4265                                   &g_abLogoF12BootText[0], pbDst);
     4268                                    LOGO_F12TEXT_WIDTH, LOGO_F12TEXT_HEIGHT,
     4269                                    pThisCC->fBootMenuInverse, iStep, &pThisCC->au32LogoPalette[0],
     4270                                    &g_abLogoF12BootText[0], pbDst);
    42664271
    42674272                /* Blit the offscreen buffer. */
    42684273                if (pThis->vram_size >= LOGO_MAX_SIZE * 2)
    42694274                {
    4270                     uint32_t *pu32TmpDst = (uint32_t *)pThis->vram_ptrR3;
    4271                     uint32_t *pu32TmpSrc = (uint32_t *)(pThis->vram_ptrR3 + LOGO_MAX_SIZE);
     4275                    uint32_t *pu32TmpDst = (uint32_t *)pThisCC->pbVRam;
     4276                    uint32_t *pu32TmpSrc = (uint32_t *)(pThisCC->pbVRam + LOGO_MAX_SIZE);
    42724277                    for (int i = 0; i < LOGO_MAX_WIDTH; i++)
    42734278                    {
     
    42884293            default:
    42894294                Log(("vbeR3IoPortWriteCmdLogo: invalid command %d\n", u32));
    4290                 pThis->LogoCommand = LOGO_CMD_NOP;
     4295                pThisCC->LogoCommand = LOGO_CMD_NOP;
    42914296                break;
    42924297        }
     
    43074312vbeR3IoPortReadCmdLogo(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t *pu32, unsigned cb)
    43084313{
    4309     PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     4314    PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
    43104315    RT_NOREF(pvUser, offPort);
    43114316
    4312     if (pThis->offLogoData + cb > pThis->cbLogo)
     4317    if (pThisCC->offLogoData + cb > pThisCC->cbLogo)
    43134318    {
    43144319        Log(("vbeR3IoPortReadCmdLogo: Requested address is out of Logo data!!! offLogoData=%#x(%d) cbLogo=%#x(%d)\n",
    4315              pThis->offLogoData, pThis->offLogoData, pThis->cbLogo, pThis->cbLogo));
     4320             pThisCC->offLogoData, pThisCC->offLogoData, pThisCC->cbLogo, pThisCC->cbLogo));
    43164321        return VINF_SUCCESS;
    43174322    }
    43184323    RT_UNTRUSTED_VALIDATED_FENCE();
    43194324
    4320     PCRTUINT64U p = (PCRTUINT64U)&pThis->pbLogo[pThis->offLogoData];
     4325    PCRTUINT64U p = (PCRTUINT64U)&pThisCC->pbLogo[pThisCC->offLogoData];
    43214326    switch (cb)
    43224327    {
     
    43274332        default: AssertFailed(); break;
    43284333    }
    4329     Log(("vbeR3IoPortReadCmdLogo: LogoOffset=%#x(%d) cb=%#x %.*Rhxs\n", pThis->offLogoData, pThis->offLogoData, cb, cb, pu32));
    4330 
    4331     pThis->LogoCommand = LOGO_CMD_NOP;
    4332     pThis->offLogoData += cb;
     4334    Log(("vbeR3IoPortReadCmdLogo: LogoOffset=%#x(%d) cb=%#x %.*Rhxs\n", pThisCC->offLogoData, pThisCC->offLogoData, cb, cb, pu32));
     4335
     4336    pThisCC->LogoCommand = LOGO_CMD_NOP;
     4337    pThisCC->offLogoData += cb;
    43334338
    43344339    return VINF_SUCCESS;
     
    44544459 * Worker for vgaR3InfoText.
    44554460 *
    4456  * @param   pThis       The vga state.
     4461 * @param   pThis       The shared VGA state.
     4462 * @param   pThisCC     The VGA state for ring-3.
    44574463 * @param   pHlp        Callback functions for doing output.
    44584464 * @param   offStart    Where to start dumping (relative to the VRAM).
     
    44644470 *                      (exclusive).
    44654471 */
    4466 static void vgaR3InfoTextWorker(PVGASTATE pThis, PCDBGFINFOHLP pHlp,
     4472static void vgaR3InfoTextWorker(PVGASTATE pThis, PVGASTATER3 pThisCC, PCDBGFINFOHLP pHlp,
    44674473                                uint32_t offStart, uint32_t cbLine,
    44684474                                uint32_t cCols, uint32_t cRows,
     
    44784484
    44794485    /* Do the dumping. */
    4480     uint8_t const *pbSrcOuter = pThis->CTX_SUFF(vram_ptr) + offStart;
     4486    uint8_t const *pbSrcOuter = pThisCC->pbVRam + offStart;
    44814487    uint32_t iRow;
    44824488    for (iRow = 0; iRow < cRows; iRow++, pbSrcOuter += cbLine)
    44834489    {
    4484         if ((uintptr_t)(pbSrcOuter + cbLine - pThis->CTX_SUFF(vram_ptr)) > pThis->vram_size) {
     4490        if ((uintptr_t)(pbSrcOuter + cbLine - pThisCC->pbVRam) > pThis->vram_size) {
    44854491            pHlp->pfnPrintf(pHlp, "The last %u row/rows is/are outside the VRAM.\n", cRows - iRow);
    44864492            break;
     
    45184524static DECLCALLBACK(void) vgaR3InfoText(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
    45194525{
    4520     PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     4526    PVGASTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     4527    PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
    45214528
    45224529    /*
     
    45424549    if (!(pThis->gr[6] & 1))
    45434550    {
    4544         uint8_t *pbSrc = pThis->vram_ptrR3;
     4551        uint8_t *pbSrc = pThisCC->pbVRam;
    45454552        if (pbSrc)
    45464553        {
     
    45734580
    45744581            if (fAll)
    4575                 vgaR3InfoTextWorker(pThis, pHlp, offStart - iScrBegin * cbLine, cbLine,
     4582                vgaR3InfoTextWorker(pThis, pThisCC, pHlp, offStart - iScrBegin * cbLine, cbLine,
    45764583                                    cCols, cRows, iScrBegin, iScrBegin + cScrRows);
    45774584            else
    4578                 vgaR3InfoTextWorker(pThis, pHlp, offStart, cbLine, cCols, cScrRows, 0, cScrRows);
     4585                vgaR3InfoTextWorker(pThis, pThisCC, pHlp, offStart, cbLine, cCols, cScrRows, 0, cScrRows);
    45794586        }
    45804587        else
     
    47464753static DECLCALLBACK(void *) vgaR3PortQueryInterface(PPDMIBASE pInterface, const char *pszIID)
    47474754{
    4748     PVGASTATE pThis = RT_FROM_MEMBER(pInterface, VGASTATE, IBase);
    4749     PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis->IBase);
    4750     PDMIBASE_RETURN_INTERFACE(pszIID, PDMIDISPLAYPORT, &pThis->IPort);
     4755    PVGASTATECC pThisCC = RT_FROM_MEMBER(pInterface, VGASTATECC, IBase);
     4756    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThisCC->IBase);
     4757    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIDISPLAYPORT, &pThisCC->IPort);
    47514758# if defined(VBOX_WITH_HGSMI) && (defined(VBOX_WITH_VIDEOHWACCEL) || defined(VBOX_WITH_CRHGSMI))
    4752     PDMIBASE_RETURN_INTERFACE(pszIID, PDMIDISPLAYVBVACALLBACKS, &pThis->IVBVACallbacks);
     4759    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIDISPLAYVBVACALLBACKS, &pThisCC->IVBVACallbacks);
    47534760# endif
    4754     PDMIBASE_RETURN_INTERFACE(pszIID, PDMILEDPORTS, &pThis->ILeds);
     4761    PDMIBASE_RETURN_INTERFACE(pszIID, PDMILEDPORTS, &pThisCC->ILeds);
    47554762    return NULL;
    47564763}
     
    47644771static DECLCALLBACK(int) vgaR3PortQueryStatusLed(PPDMILEDPORTS pInterface, unsigned iLUN, PPDMLED *ppLed)
    47654772{
    4766     PVGASTATE pThis = RT_FROM_MEMBER(pInterface, VGASTATE, ILeds);
     4773    PVGASTATECC pThisCC = RT_FROM_MEMBER(pInterface, VGASTATECC, ILeds);
     4774    PPDMDEVINS  pDevIns = pThisCC->pDevIns;
     4775    PVGASTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
    47674776    switch (iLUN)
    47684777    {
     
    48154824/* -=-=-=-=-=- Ring 3: IDisplayPort -=-=-=-=-=- */
    48164825
    4817 /** Converts a display port interface pointer to a vga state pointer. */
    4818 # define IDISPLAYPORT_2_VGASTATE(pInterface) ( (PVGASTATE)((uintptr_t)pInterface - RT_OFFSETOF(VGASTATE, IPort)) )
    4819 
    4820 
    48214826/**
    48224827 * @interface_method_impl{PDMIDISPLAYPORT,pfnUpdateDisplay}
     
    48244829static DECLCALLBACK(int) vgaR3PortUpdateDisplay(PPDMIDISPLAYPORT pInterface)
    48254830{
    4826     PVGASTATE pThis = IDISPLAYPORT_2_VGASTATE(pInterface);
    4827     PDMDEV_ASSERT_EMT(VGASTATE2DEVINS(pThis));
    4828     PPDMDEVINS pDevIns = pThis->CTX_SUFF(pDevIns);
     4831    PVGASTATECC pThisCC = RT_FROM_MEMBER(pInterface, VGASTATECC, IPort);
     4832    PPDMDEVINS  pDevIns = pThisCC->pDevIns;
     4833    PVGASTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     4834    PDMDEV_ASSERT_EMT(pDevIns);
    48294835
    48304836    int rc = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_SEM_BUSY);
     
    48444850    /* This should be called only in non VBVA mode. */
    48454851# else
    4846     if (VBVAUpdateDisplay(pThis) == VINF_SUCCESS)
     4852    if (VBVAUpdateDisplay(pThis, pThisCC) == VINF_SUCCESS)
    48474853    {
    48484854        PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
     
    48634869    }
    48644870
    4865     rc = vgaR3UpdateDisplay(pThis, false /*fUpdateAll*/, false /*fFailOnResize*/, true /*reset_dirty*/,
    4866                             pThis->pDrv, &pThis->graphic_mode);
     4871    rc = vgaR3UpdateDisplay(pDevIns, pThis, pThisCC, false /*fUpdateAll*/, false /*fFailOnResize*/, true /*reset_dirty*/,
     4872                            pThisCC->pDrv, &pThis->graphic_mode);
    48674873    PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
    48684874    return rc;
     
    48734879 * Internal vgaR3PortUpdateDisplayAll worker called under pThis->CritSect.
    48744880 */
    4875 static int vboxR3UpdateDisplayAllInternal(PVGASTATE pThis, bool fFailOnResize)
    4876 {
    4877     PPDMDEVINS pDevIns = pThis->CTX_SUFF(pDevIns);
    4878 
     4881static int vboxR3UpdateDisplayAllInternal(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC, bool fFailOnResize)
     4882{
    48794883# ifdef VBOX_WITH_VMSVGA
    48804884    if (    !pThis->svga.fEnabled
     
    48964900    pThis->graphic_mode = -1; /* force full update */
    48974901
    4898     return vgaR3UpdateDisplay(pThis, true /*fUpdateAll*/, fFailOnResize, true /*reset_dirty*/, pThis->pDrv, &pThis->graphic_mode);
     4902    return vgaR3UpdateDisplay(pDevIns, pThis, pThisCC, true /*fUpdateAll*/, fFailOnResize,
     4903                              true /*reset_dirty*/, pThisCC->pDrv, &pThis->graphic_mode);
    48994904}
    49004905
     
    49054910static DECLCALLBACK(int) vgaR3PortUpdateDisplayAll(PPDMIDISPLAYPORT pInterface, bool fFailOnResize)
    49064911{
    4907     PVGASTATE pThis = IDISPLAYPORT_2_VGASTATE(pInterface);
    4908     PPDMDEVINS pDevIns = pThis->CTX_SUFF(pDevIns);
     4912    PVGASTATECC pThisCC = RT_FROM_MEMBER(pInterface, VGASTATECC, IPort);
     4913    PPDMDEVINS  pDevIns = pThisCC->pDevIns;
     4914    PVGASTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
    49094915    PDMDEV_ASSERT_EMT(pDevIns);
    49104916
     
    49184924    AssertRC(rc);
    49194925
    4920     rc = vboxR3UpdateDisplayAllInternal(pThis, fFailOnResize);
     4926    rc = vboxR3UpdateDisplayAllInternal(pDevIns, pThis, pThisCC, fFailOnResize);
    49214927
    49224928    PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
     
    49304936static DECLCALLBACK(int) vgaR3PortSetRefreshRate(PPDMIDISPLAYPORT pInterface, uint32_t cMilliesInterval)
    49314937{
    4932     PVGASTATE  pThis   = IDISPLAYPORT_2_VGASTATE(pInterface);
    4933     PPDMDEVINS pDevIns = pThis->pDevInsR3;
     4938    PVGASTATECC pThisCC = RT_FROM_MEMBER(pInterface, VGASTATECC, IPort);
     4939    PPDMDEVINS  pDevIns = pThisCC->pDevIns;
     4940    PVGASTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
    49344941
    49354942    /*
     
    49554962static DECLCALLBACK(int) vgaR3PortQueryVideoMode(PPDMIDISPLAYPORT pInterface, uint32_t *pcBits, uint32_t *pcx, uint32_t *pcy)
    49564963{
    4957     PVGASTATE pThis = IDISPLAYPORT_2_VGASTATE(pInterface);
    4958 
    4959     if (!pcBits)
    4960         return VERR_INVALID_PARAMETER;
     4964    PVGASTATECC pThisCC = RT_FROM_MEMBER(pInterface, VGASTATECC, IPort);
     4965    PPDMDEVINS  pDevIns = pThisCC->pDevIns;
     4966    PVGASTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     4967
     4968    AssertReturn(pcBits, VERR_INVALID_PARAMETER);
     4969
    49614970    *pcBits = vgaR3GetBpp(pThis);
    49624971    if (pcx)
     
    49744983                                                 uint32_t *pcx, uint32_t *pcy)
    49754984{
    4976     PVGASTATE  pThis   = IDISPLAYPORT_2_VGASTATE(pInterface);
    4977     PPDMDEVINS pDevIns = pThis->CTX_SUFF(pDevIns);
    4978     PDMDEV_ASSERT_EMT(VGASTATE2DEVINS(pThis));
     4985    PVGASTATECC pThisCC = RT_FROM_MEMBER(pInterface, VGASTATECC, IPort);
     4986    PPDMDEVINS  pDevIns = pThisCC->pDevIns;
     4987    PVGASTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     4988    PDMDEV_ASSERT_EMT(pDevIns);
    49794989
    49804990    LogFlow(("vgaR3PortTakeScreenshot: ppbData=%p pcbData=%p pcx=%p pcy=%p\n", ppbData, pcbData, pcx, pcy));
     
    50355045             * If there is a pending resize, the function will fail.
    50365046             */
    5037             rc = vgaR3UpdateDisplay(pThis, false /*fUpdateAll*/, true /*fFailOnResize*/, false /*reset_dirty*/,
    5038                                     &Connector, &cur_graphic_mode);
     5047            rc = vgaR3UpdateDisplay(pDevIns, pThis, pThisCC, false /*fUpdateAll*/, true /*fFailOnResize*/,
     5048                                    false /*reset_dirty*/, &Connector, &cur_graphic_mode);
    50395049
    50405050            pThis->fRenderVRAM = fSavedRenderVRAM;
     
    50935103                                             uint32_t x, uint32_t y, uint32_t cx, uint32_t cy)
    50945104{
    5095     PVGASTATE       pThis   = IDISPLAYPORT_2_VGASTATE(pInterface);
    5096     PPDMDEVINS      pDevIns = pThis->CTX_SUFF(pDevIns);
    5097     int             rc;
    5098     PDMDEV_ASSERT_EMT(VGASTATE2DEVINS(pThis));
     5105    PVGASTATECC pThisCC = RT_FROM_MEMBER(pInterface, VGASTATECC, IPort);
     5106    PPDMDEVINS  pDevIns = pThisCC->pDevIns;
     5107    PVGASTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     5108    PDMDEV_ASSERT_EMT(pDevIns);
    50995109    LogFlow(("vgaR3PortDisplayBlt: pvData=%p x=%d y=%d cx=%d cy=%d\n", pvData, x, y, cx, cy));
    51005110
    5101     rc = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_SEM_BUSY);
     5111    int rc = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_SEM_BUSY);
    51025112    AssertRC(rc);
    51035113
     
    51065116     */
    51075117    if (    pvData
    5108         &&  x      <  pThis->pDrv->cx
    5109         &&  cx     <= pThis->pDrv->cx
    5110         &&  cx + x <= pThis->pDrv->cx
    5111         &&  y      <  pThis->pDrv->cy
    5112         &&  cy     <= pThis->pDrv->cy
    5113         &&  cy + y <= pThis->pDrv->cy)
     5118        &&  x      <  pThisCC->pDrv->cx
     5119        &&  cx     <= pThisCC->pDrv->cx
     5120        &&  cx + x <= pThisCC->pDrv->cx
     5121        &&  y      <  pThisCC->pDrv->cy
     5122        &&  cy     <= pThisCC->pDrv->cy
     5123        &&  cy + y <= pThisCC->pDrv->cy)
    51145124    {
    51155125        /*
     
    51175127         */
    51185128        size_t  cbPixelDst = 0;
    5119         switch (pThis->pDrv->cBits)
     5129        switch (pThisCC->pDrv->cBits)
    51205130        {
    51215131            case 8:
     
    51435153            size_t      cbLineSrc   = cx * 4; /* 32 bits per pixel. */
    51445154            uint8_t    *pbSrc       = (uint8_t *)pvData;
    5145             size_t      cbLineDst   = pThis->pDrv->cbScanline;
    5146             uint8_t    *pbDst       = pThis->pDrv->pbData + y * cbLineDst + x * cbPixelDst;
     5155            size_t      cbLineDst   = pThisCC->pDrv->cbScanline;
     5156            uint8_t    *pbDst       = pThisCC->pDrv->pbData + y * cbLineDst + x * cbPixelDst;
    51475157            uint32_t    cyLeft      = cy;
    5148             vga_draw_line_func *pfnVgaDrawLine = vga_draw_line_table[VGA_DRAW_LINE32 * 4 + vgaR3GetDepthIndex(pThis->pDrv->cBits)];
     5158            vga_draw_line_func *pfnVgaDrawLine = vga_draw_line_table[VGA_DRAW_LINE32 * 4 + vgaR3GetDepthIndex(pThisCC->pDrv->cBits)];
    51495159            Assert(pfnVgaDrawLine);
    51505160            while (cyLeft-- > 0)
    51515161            {
    5152                 pfnVgaDrawLine(pThis, pbDst, pbSrc, cx);
     5162                pfnVgaDrawLine(pThis, pThisCC, pbDst, pbSrc, cx);
    51535163                pbDst += cbLineDst;
    51545164                pbSrc += cbLineSrc;
     
    51585168             * Invalidate the area.
    51595169             */
    5160             pThis->pDrv->pfnUpdateRect(pThis->pDrv, x, y, cx, cy);
     5170            pThisCC->pDrv->pfnUpdateRect(pThisCC->pDrv, x, y, cx, cy);
    51615171        }
    51625172    }
     
    51765186static DECLCALLBACK(void) vgaR3PortUpdateDisplayRect(PPDMIDISPLAYPORT pInterface, int32_t x, int32_t y, uint32_t cx, uint32_t cy)
    51775187{
    5178     PVGASTATE  pThis   = IDISPLAYPORT_2_VGASTATE(pInterface);
    5179     PPDMDEVINS pDevIns = pThis->CTX_SUFF(pDevIns);
     5188    PVGASTATECC pThisCC = RT_FROM_MEMBER(pInterface, VGASTATECC, IPort);
     5189    PPDMDEVINS  pDevIns = pThisCC->pDevIns;
     5190    PVGASTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
    51805191    uint32_t v;
    5181     vga_draw_line_func *vga_draw_line;
    51825192
    51835193    uint32_t cbPixelDst;
     
    52105220    }
    52115221
    5212     Assert(pThis->pDrv);
    5213     Assert(pThis->pDrv->pbData);
     5222    Assert(pThisCC->pDrv);
     5223    Assert(pThisCC->pDrv->pbData);
    52145224
    52155225    /* Correct negative x and y coordinates. */
     
    52295239
    52305240    /* Also check if coords are greater than the display resolution. */
    5231     if (x + cx > pThis->pDrv->cx)
     5241    if (x + cx > pThisCC->pDrv->cx)
    52325242    {
    52335243        // x < 0 is not possible here
    5234         cx = pThis->pDrv->cx > (uint32_t)x? pThis->pDrv->cx - x: 0;
    5235     }
    5236 
    5237     if (y + cy > pThis->pDrv->cy)
     5244        cx = pThisCC->pDrv->cx > (uint32_t)x? pThisCC->pDrv->cx - x: 0;
     5245    }
     5246
     5247    if (y + cy > pThisCC->pDrv->cy)
    52385248    {
    52395249        // y < 0 is not possible here
    5240         cy = pThis->pDrv->cy > (uint32_t)y? pThis->pDrv->cy - y: 0;
     5250        cy = pThisCC->pDrv->cy > (uint32_t)y? pThisCC->pDrv->cy - y: 0;
    52415251    }
    52425252
     
    52625272
    52635273    /* Choose the rendering function. */
    5264     switch(pThis->get_bpp(pThis))
     5274    switch(pThisCC->get_bpp(pThis))
    52655275    {
    52665276        default:
     
    52895299    }
    52905300
    5291     vga_draw_line = vga_draw_line_table[v * 4 + vgaR3GetDepthIndex(pThis->pDrv->cBits)];
     5301    vga_draw_line_func *pfnVgaDrawLine = vga_draw_line_table[v * 4 + vgaR3GetDepthIndex(pThisCC->pDrv->cBits)];
    52925302
    52935303    /* Compute source and destination addresses and pitches. */
    5294     cbPixelDst = (pThis->pDrv->cBits + 7) / 8;
    5295     cbLineDst  = pThis->pDrv->cbScanline;
    5296     pbDst      = pThis->pDrv->pbData + y * cbLineDst + x * cbPixelDst;
    5297 
    5298     cbPixelSrc = (pThis->get_bpp(pThis) + 7) / 8;
     5304    cbPixelDst = (pThisCC->pDrv->cBits + 7) / 8;
     5305    cbLineDst  = pThisCC->pDrv->cbScanline;
     5306    pbDst      = pThisCC->pDrv->pbData + y * cbLineDst + x * cbPixelDst;
     5307
     5308    cbPixelSrc = (pThisCC->get_bpp(pThis) + 7) / 8;
    52995309    uint32_t offSrc, u32Dummy;
    5300     pThis->get_offsets(pThis, &cbLineSrc, &offSrc, &u32Dummy);
     5310    pThisCC->get_offsets(pThis, &cbLineSrc, &offSrc, &u32Dummy);
    53015311
    53025312    /* Assume that rendering is performed only on visible part of VRAM.
    53035313     * This is true because coordinates were verified.
    53045314     */
    5305     pbSrc = pThis->vram_ptrR3;
     5315    pbSrc = pThisCC->pbVRam;
    53065316    pbSrc += offSrc * 4 + y * cbLineSrc + x * cbPixelSrc;
    53075317
     
    53145324    while (cy-- > 0)
    53155325    {
    5316         vga_draw_line (pThis, pbDst, pbSrc, cx);
     5326        pfnVgaDrawLine(pThis, pThisCC, pbDst, pbSrc, cx);
    53175327        pbDst += cbLineDst;
    53185328        pbSrc += cbLineSrc;
     
    53375347                  uint32_t cbDstLine, uint32_t cDstBitsPerPixel)
    53385348{
    5339     PVGASTATE  pThis   = IDISPLAYPORT_2_VGASTATE(pInterface);
    5340     PPDMDEVINS pDevIns = pThis->CTX_SUFF(pDevIns);
     5349    PVGASTATECC pThisCC = RT_FROM_MEMBER(pInterface, VGASTATECC, IPort);
     5350    PPDMDEVINS  pDevIns = pThisCC->pDevIns;
     5351    PVGASTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
    53415352    uint32_t v;
    5342     vga_draw_line_func *vga_draw_line;
    53435353
    53445354# ifdef DEBUG_sunlover
     
    53475357
    53485358    Assert(pInterface);
    5349     Assert(pThis->pDrv);
     5359    Assert(pThisCC->pDrv);
    53505360
    53515361    int32_t  xSrcCorrected = xSrc;
     
    54225432     */
    54235433    if (   (pThis->vbe_regs[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_ENABLED) == 0
    5424         && VBVAIsPaused(pThis)
     5434        && VBVAIsPaused(pThisCC)
    54255435# ifdef VBOX_WITH_VMSVGA
    54265436        && !pThis->svga.fEnabled
     
    54575467    }
    54585468
    5459     vga_draw_line = vga_draw_line_table[v * 4 + vgaR3GetDepthIndex(cDstBitsPerPixel)];
     5469    vga_draw_line_func *pfnVgaDrawLine = vga_draw_line_table[v * 4 + vgaR3GetDepthIndex(cDstBitsPerPixel)];
    54605470
    54615471    /* Compute source and destination addresses and pitches. */
     
    54745484    while (cyCorrected-- > 0)
    54755485    {
    5476         vga_draw_line(pThis, pbDstCur, pbSrcCur, cxCorrected);
     5486        pfnVgaDrawLine(pThis, pThisCC, pbDstCur, pbSrcCur, cxCorrected);
    54775487        pbDstCur += cbLineDst;
    54785488        pbSrcCur += cbLineSrc;
     
    54925502static DECLCALLBACK(void) vgaR3PortSetRenderVRAM(PPDMIDISPLAYPORT pInterface, bool fRender)
    54935503{
    5494     PVGASTATE  pThis   = IDISPLAYPORT_2_VGASTATE(pInterface);
    5495     PPDMDEVINS pDevIns = pThis->CTX_SUFF(pDevIns);
     5504    PVGASTATECC pThisCC = RT_FROM_MEMBER(pInterface, VGASTATECC, IPort);
     5505    PPDMDEVINS  pDevIns = pThisCC->pDevIns;
     5506    PVGASTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
    54965507
    54975508    LogFlow(("vgaR3PortSetRenderVRAM: fRender = %d\n", fRender));
     
    55305541static DECLCALLBACK(void) vgaTimerRefresh(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
    55315542{
    5532     PVGASTATE pThis = (PVGASTATE)pvUser;
    5533     RT_NOREF(pTimer);
     5543    PVGASTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     5544    PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
     5545    RT_NOREF(pvUser, pTimer);
    55345546
    55355547    if (pThis->fScanLineCfg & VBVASCANLINECFG_ENABLE_VSYNC_IRQ)
    5536         VBVARaiseIrq(pThis, HGSMIHOSTFLAGS_VSYNC);
    5537 
    5538     if (pThis->pDrv)
    5539         pThis->pDrv->pfnRefresh(pThis->pDrv);
     5548        VBVARaiseIrq(pDevIns, pThis, pThisCC, HGSMIHOSTFLAGS_VSYNC);
     5549
     5550    if (pThisCC->pDrv)
     5551        pThisCC->pDrv->pfnRefresh(pThisCC->pDrv);
    55405552
    55415553    if (pThis->cMilliesRefreshInterval)
     
    55435555
    55445556# ifdef VBOX_WITH_VIDEOHWACCEL
    5545     vbvaTimerCb(pThis);
     5557    vbvaTimerCb(pDevIns, pThis, pThisCC);
    55465558# endif
    55475559
     
    55615573 * Helper for VMSVGA.
    55625574 */
    5563 int vgaR3RegisterVRAMHandler(PVGASTATE pVGAState, uint64_t cbFrameBuffer)
    5564 {
    5565     PPDMDEVINS pDevIns = pVGAState->pDevInsR3;
    5566     Assert(pVGAState->GCPhysVRAM);
    5567 
     5575int vgaR3RegisterVRAMHandler(PPDMDEVINS pDevIns, PVGASTATE pThis, uint64_t cbFrameBuffer)
     5576{
     5577    Assert(pThis->GCPhysVRAM);
    55685578    int rc = PGMHandlerPhysicalRegister(PDMDevHlpGetVM(pDevIns),
    5569                                         pVGAState->GCPhysVRAM, pVGAState->GCPhysVRAM + (cbFrameBuffer - 1),
    5570                                         pVGAState->hLfbAccessHandlerType, pVGAState, pDevIns->pvInstanceDataR0,
     5579                                        pThis->GCPhysVRAM, pThis->GCPhysVRAM + (cbFrameBuffer - 1),
     5580                                        pThis->hLfbAccessHandlerType, pThis, pDevIns->pvInstanceDataR0,
    55715581                                        pDevIns->pvInstanceDataRC, "VGA LFB");
    55725582
     
    55795589 * Helper for VMSVGA.
    55805590 */
    5581 int vgaR3UnregisterVRAMHandler(PVGASTATE pVGAState)
    5582 {
    5583     PPDMDEVINS pDevIns = pVGAState->pDevInsR3;
    5584 
    5585     Assert(pVGAState->GCPhysVRAM);
    5586     int rc = PGMHandlerPhysicalDeregister(PDMDevHlpGetVM(pDevIns), pVGAState->GCPhysVRAM);
     5591int vgaR3UnregisterVRAMHandler(PPDMDEVINS pDevIns, PVGASTATE pThis)
     5592{
     5593    Assert(pThis->GCPhysVRAM);
     5594    int rc = PGMHandlerPhysicalDeregister(PDMDevHlpGetVM(pDevIns), pThis->GCPhysVRAM);
    55875595    AssertRC(rc);
    55885596    return rc;
     
    56205628        {
    56215629            rc = PGMHandlerPhysicalRegister(PDMDevHlpGetVM(pDevIns), GCPhysAddress, GCPhysAddress + (pThis->vram_size - 1),
    5622                                             pThis->hLfbAccessHandlerType, pThis, pDevIns->pvInstanceDataR0,
    5623                                             pDevIns->pvInstanceDataRC, "VGA LFB");
     5630                                            pThis->hLfbAccessHandlerType, pDevIns, pDevIns->pDevInsR0RemoveMe,
     5631                                            pDevIns->pDevInsForRC, "VGA LFB");
    56245632            AssertLogRelRC(rc);
    56255633            if (RT_SUCCESS(rc))
     
    58195827static DECLCALLBACK(int) vgaR3SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
    58205828{
    5821     PVGASTATE       pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     5829    PVGASTATE       pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     5830    PVGASTATECC     pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
    58225831    PCPDMDEVHLPR3   pHlp  = pDevIns->pHlpR3;
    58235832
    58245833# ifdef VBOX_WITH_VDMA
    5825     vboxVDMASaveStateExecPrep(pThis->pVdma);
     5834    vboxVDMASaveStateExecPrep(pThisCC->pVdma);
    58265835# endif
    58275836
     
    58435852    rc = pHlp->pfnSSMPutU32(pSSM, 1);
    58445853    AssertRCReturn(rc, rc);
    5845     rc = vboxVDMASaveStateExecPerform(pHlp, pThis->pVdma, pSSM);
     5854    rc = vboxVDMASaveStateExecPerform(pHlp, pThisCC->pVdma, pSSM);
    58465855# else
    58475856    rc = pHlp->pfnSSMPutU32(pSSM, 0);
     
    58505859
    58515860# ifdef VBOX_WITH_VDMA
    5852     vboxVDMASaveStateExecDone(pThis->pVdma);
     5861    vboxVDMASaveStateExecDone(pThisCC->pVdma);
    58535862# endif
    58545863
     
    58725881static DECLCALLBACK(int) vgaR3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
    58735882{
    5874     PVGASTATE       pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
    5875     PCPDMDEVHLPR3   pHlp  = pDevIns->pHlpR3;
     5883    PVGASTATE       pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     5884    PVGASTATECC     pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
     5885    PCPDMDEVHLPR3   pHlp    = pDevIns->pHlpR3;
    58765886    int             rc;
    58775887
     
    59315941                if (u32 == 1)
    59325942                {
    5933                     rc = vboxVDMASaveLoadExecPerform(pHlp, pThis->pVdma, pSSM, uVersion);
     5943                    rc = vboxVDMASaveLoadExecPerform(pHlp, pThisCC->pVdma, pSSM, uVersion);
    59345944                    AssertRCReturn(rc, rc);
    59355945                }
     
    59625972static DECLCALLBACK(int) vgaR3LoadDone(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
    59635973{
    5964     RT_NOREF(pSSM);
    5965     int rc = VINF_SUCCESS;
     5974    PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
     5975    PVGASTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     5976    int         rc;
     5977    RT_NOREF(pThisCC, pThis, pSSM);
    59665978
    59675979# ifdef VBOX_WITH_HGSMI
    5968     PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
    59695980    rc = vboxVBVALoadStateDone(pDevIns);
    59705981    AssertRCReturn(rc, rc);
    59715982# ifdef VBOX_WITH_VDMA
    5972     rc = vboxVDMASaveLoadDone(pThis->pVdma);
     5983    rc = vboxVDMASaveLoadDone(pThisCC->pVdma);
    59735984    AssertRCReturn(rc, rc);
    59745985# endif
    59755986    /* Now update the current VBVA state which depends on VBE registers. vboxVBVALoadStateDone cleared the state. */
    5976     VBVAOnVBEChanged(pThis);
     5987    VBVAOnVBEChanged(pThis, pThisCC);
    59775988# endif
    59785989# ifdef VBOX_WITH_VMSVGA
     
    59835994    }
    59845995# endif
    5985     return rc;
     5996    return VINF_SUCCESS;
    59865997}
    59875998
     
    59946005static DECLCALLBACK(void) vgaR3Resume(PPDMDEVINS pDevIns)
    59956006{
    5996     PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
    5997     VBVAOnResume(pThis);
     6007    PVGASTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     6008    PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
     6009    VBVAOnResume(pDevIns, pThis, pThisCC);
    59986010}
    59996011
     
    60046016static DECLCALLBACK(void)  vgaR3Reset(PPDMDEVINS pDevIns)
    60056017{
    6006     PVGASTATE       pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     6018    PVGASTATE       pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     6019    PVGASTATECC     pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
    60076020    char           *pchStart;
    60086021    char           *pchEnd;
    60096022    LogFlow(("vgaReset\n"));
    60106023
    6011     if (pThis->pVdma)
    6012         vboxVDMAReset(pThis->pVdma);
     6024    if (pThisCC->pVdma)
     6025        vboxVDMAReset(pThisCC->pVdma);
    60136026
    60146027# ifdef VBOX_WITH_VMSVGA
     
    60186031
    60196032# ifdef VBOX_WITH_HGSMI
    6020     VBVAReset(pThis);
     6033    VBVAReset(pDevIns, pThis, pThisCC);
    60216034# endif
    60226035
    60236036
    60246037    /* Clear the VRAM ourselves. */
    6025     if (pThis->vram_ptrR3 && pThis->vram_size)
    6026         memset(pThis->vram_ptrR3, 0, pThis->vram_size);
     6038    if (pThisCC->pbVRam && pThis->vram_size)
     6039        memset(pThisCC->pbVRam, 0, pThis->vram_size);
    60276040
    60286041    /*
     
    60466059     * Restore and re-init some bits.
    60476060     */
    6048     pThis->get_bpp        = vgaR3GetBpp;
    6049     pThis->get_offsets    = vgaR3GetOffsets;
    6050     pThis->get_resolution = vgaR3GetResolution;
     6061    pThisCC->get_bpp        = vgaR3GetBpp;
     6062    pThisCC->get_offsets    = vgaR3GetOffsets;
     6063    pThisCC->get_resolution = vgaR3GetResolution;
    60516064    pThis->graphic_mode   = -1;         /* Force full update. */
    60526065# ifdef CONFIG_BOCHS_VBE
     
    60786091     * Reset the logo data.
    60796092     */
    6080     pThis->LogoCommand = LOGO_CMD_NOP;
    6081     pThis->offLogoData = 0;
     6093    pThisCC->LogoCommand = LOGO_CMD_NOP;
     6094    pThisCC->offLogoData = 0;
    60826095
    60836096    /* notify port handler */
    6084     if (pThis->pDrv)
     6097    if (pThisCC->pDrv)
    60856098    {
    60866099        PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect); /* hack around lock order issue. */
    6087         pThis->pDrv->pfnReset(pThis->pDrv);
    6088         pThis->pDrv->pfnVBVAMousePointerShape(pThis->pDrv, false, false, 0, 0, 0, 0, NULL);
     6100        pThisCC->pDrv->pfnReset(pThisCC->pDrv);
     6101        pThisCC->pDrv->pfnVBVAMousePointerShape(pThisCC->pDrv, false, false, 0, 0, 0, 0, NULL);
    60896102        PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED);
    60906103    }
     
    61066119static DECLCALLBACK(void) vgaR3PowerOn(PPDMDEVINS pDevIns)
    61076120{
    6108     PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     6121    PVGASTATE   pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     6122    PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
    61096123# ifdef VBOX_WITH_VMSVGA
    61106124    vmsvgaR3PowerOn(pDevIns);
    61116125# endif
    6112     VBVAOnResume(pThis);
     6126    VBVAOnResume(pDevIns, pThis, pThisCC);
    61136127}
    61146128
     
    61256139        LogFlow(("vgaRelocate: offDelta = %08X\n", offDelta));
    61266140
    6127         pThis->vram_ptrRC += offDelta;
     6141        pThisRC->pbVRam += offDelta;
    61286142        pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
    61296143    }
     
    61416155static DECLCALLBACK(int)  vgaAttach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
    61426156{
    6143     PVGASTATE   pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     6157    PVGASTATE       pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     6158    PVGASTATECC     pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
    61446159
    61456160    AssertMsgReturn(fFlags & PDM_TACH_FLAGS_NOT_HOT_PLUG,
     
    61526167        case 0:
    61536168        {
    6154             int rc = PDMDevHlpDriverAttach(pDevIns, iLUN, &pThis->IBase, &pThis->pDrvBase, "Display Port");
     6169            int rc = PDMDevHlpDriverAttach(pDevIns, iLUN, &pThisCC->IBase, &pThisCC->pDrvBase, "Display Port");
    61556170            if (RT_SUCCESS(rc))
    61566171            {
    6157                 pThis->pDrv = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIDISPLAYCONNECTOR);
    6158                 if (pThis->pDrv)
     6172                pThisCC->pDrv = PDMIBASE_QUERY_INTERFACE(pThisCC->pDrvBase, PDMIDISPLAYCONNECTOR);
     6173                if (pThisCC->pDrv)
    61596174                {
    6160                     /* pThis->pDrv->pbData can be NULL when there is no framebuffer. */
    6161                     if (    pThis->pDrv->pfnRefresh
    6162                         &&  pThis->pDrv->pfnResize
    6163                         &&  pThis->pDrv->pfnUpdateRect)
     6175                    /* pThisCC->pDrv->pbData can be NULL when there is no framebuffer. */
     6176                    if (    pThisCC->pDrv->pfnRefresh
     6177                        &&  pThisCC->pDrv->pfnResize
     6178                        &&  pThisCC->pDrv->pfnUpdateRect)
    61646179                        rc = VINF_SUCCESS;
    61656180                    else
    61666181                    {
    6167                         Assert(pThis->pDrv->pfnRefresh);
    6168                         Assert(pThis->pDrv->pfnResize);
    6169                         Assert(pThis->pDrv->pfnUpdateRect);
    6170                         pThis->pDrv = NULL;
    6171                         pThis->pDrvBase = NULL;
     6182                        Assert(pThisCC->pDrv->pfnRefresh);
     6183                        Assert(pThisCC->pDrv->pfnResize);
     6184                        Assert(pThisCC->pDrv->pfnUpdateRect);
     6185                        pThisCC->pDrv = NULL;
     6186                        pThisCC->pDrvBase = NULL;
    61726187                        rc = VERR_INTERNAL_ERROR;
    61736188                    }
     
    61756190                    if(rc == VINF_SUCCESS)
    61766191                    {
    6177                         rc = vbvaVHWAConstruct(pThis);
     6192                        rc = vbvaVHWAConstruct(pDevIns, pThis, pThisCC);
    61786193                        if (rc != VERR_NOT_IMPLEMENTED)
    61796194                            AssertRC(rc);
     
    61846199                {
    61856200                    AssertMsgFailed(("LUN #0 doesn't have a display connector interface! rc=%Rrc\n", rc));
    6186                     pThis->pDrvBase = NULL;
     6201                    pThisCC->pDrvBase = NULL;
    61876202                    rc = VERR_PDM_MISSING_INTERFACE;
    61886203                }
     
    62126227static DECLCALLBACK(void)  vgaDetach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
    62136228{
    6214     RT_NOREF1(fFlags);
    6215     PVGASTATE   pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     6229    PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
    62166230    AssertMsg(fFlags & PDM_TACH_FLAGS_NOT_HOT_PLUG, ("VGA device does not support hotplugging\n"));
     6231    RT_NOREF(fFlags);
    62176232
    62186233    /*
     
    62236238        /* LUN #0: Display port. */
    62246239        case 0:
    6225             pThis->pDrv = NULL;
    6226             pThis->pDrvBase = NULL;
     6240            pThisCC->pDrv = NULL;
     6241            pThisCC->pDrvBase = NULL;
    62276242            break;
    62286243
     
    62406255{
    62416256    PDMDEV_CHECK_VERSIONS_RETURN_QUIET(pDevIns);
    6242 
    6243     PVGASTATE   pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     6257    PVGASTATE       pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     6258    PVGASTATECC     pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
    62446259    LogFlow(("vgaR3Destruct:\n"));
    62456260
    62466261# ifdef VBOX_WITH_VDMA
    6247     if (pThis->pVdma)
    6248         vboxVDMADestruct(pThis->pVdma);
     6262    if (pThisCC->pVdma)
     6263        vboxVDMADestruct(pThisCC->pVdma);
    62496264# endif
    62506265
     
    62556270
    62566271# ifdef VBOX_WITH_HGSMI
    6257     VBVADestroy(pThis);
     6272    VBVADestroy(pThisCC);
    62586273# endif
    62596274
     
    62616276     * Free MM heap pointers.
    62626277     */
    6263     if (pThis->pbVBEExtraData)
    6264     {
    6265         PDMDevHlpMMHeapFree(pDevIns, pThis->pbVBEExtraData);
    6266         pThis->pbVBEExtraData = NULL;
    6267     }
    6268     if (pThis->pbVgaBios)
    6269     {
    6270         PDMDevHlpMMHeapFree(pDevIns, pThis->pbVgaBios);
    6271         pThis->pbVgaBios = NULL;
    6272     }
    6273 
    6274     if (pThis->pszVgaBiosFile)
    6275     {
    6276         PDMDevHlpMMHeapFree(pDevIns, pThis->pszVgaBiosFile);
    6277         pThis->pszVgaBiosFile = NULL;
    6278     }
    6279 
    6280     if (pThis->pszLogoFile)
    6281     {
    6282         PDMDevHlpMMHeapFree(pDevIns, pThis->pszLogoFile);
    6283         pThis->pszLogoFile = NULL;
    6284     }
    6285 
    6286     if (pThis->pbLogo)
    6287     {
    6288         PDMDevHlpMMHeapFree(pDevIns, pThis->pbLogo);
    6289         pThis->pbLogo = NULL;
     6278    if (pThisCC->pbVBEExtraData)
     6279    {
     6280        PDMDevHlpMMHeapFree(pDevIns, pThisCC->pbVBEExtraData);
     6281        pThisCC->pbVBEExtraData = NULL;
     6282    }
     6283    if (pThisCC->pbVgaBios)
     6284    {
     6285        PDMDevHlpMMHeapFree(pDevIns, pThisCC->pbVgaBios);
     6286        pThisCC->pbVgaBios = NULL;
     6287    }
     6288
     6289    if (pThisCC->pszVgaBiosFile)
     6290    {
     6291        PDMDevHlpMMHeapFree(pDevIns, pThisCC->pszVgaBiosFile);
     6292        pThisCC->pszVgaBiosFile = NULL;
     6293    }
     6294
     6295    if (pThisCC->pszLogoFile)
     6296    {
     6297        PDMDevHlpMMHeapFree(pDevIns, pThisCC->pszLogoFile);
     6298        pThisCC->pszLogoFile = NULL;
     6299    }
     6300
     6301    if (pThisCC->pbLogo)
     6302    {
     6303        PDMDevHlpMMHeapFree(pDevIns, pThisCC->pbLogo);
     6304        pThisCC->pbLogo = NULL;
    62906305    }
    62916306
     
    63266341{
    63276342    PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
    6328     PVGASTATE       pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
    6329     PVM             pVM   = PDMDevHlpGetVM(pDevIns);
    6330     PCPDMDEVHLPR3   pHlp  = pDevIns->pHlpR3;
     6343    PVGASTATE       pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     6344    PVGASTATECC     pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
     6345    PVM             pVM     = PDMDevHlpGetVM(pDevIns);
     6346    PCPDMDEVHLPR3   pHlp    = pDevIns->pHlpR3;
    63316347    int             rc;
    63326348    unsigned        i;
     
    64646480# endif
    64656481
    6466     pThis->pDevInsR3 = pDevIns;
    6467     pThis->pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns);
    6468 # ifdef VBOX_WITH_RAW_MODE_KEEP
    6469     pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
    6470 # endif
     6482    pThisCC->pDevIns = pDevIns;
    64716483
    64726484    vgaR3Reset(pDevIns);
     
    65076519
    65086520    /* the interfaces. */
    6509     pThis->IBase.pfnQueryInterface    = vgaR3PortQueryInterface;
    6510 
    6511     pThis->IPort.pfnUpdateDisplay     = vgaR3PortUpdateDisplay;
    6512     pThis->IPort.pfnUpdateDisplayAll  = vgaR3PortUpdateDisplayAll;
    6513     pThis->IPort.pfnQueryVideoMode    = vgaR3PortQueryVideoMode;
    6514     pThis->IPort.pfnSetRefreshRate    = vgaR3PortSetRefreshRate;
    6515     pThis->IPort.pfnTakeScreenshot    = vgaR3PortTakeScreenshot;
    6516     pThis->IPort.pfnFreeScreenshot    = vgaR3PortFreeScreenshot;
    6517     pThis->IPort.pfnDisplayBlt        = vgaR3PortDisplayBlt;
    6518     pThis->IPort.pfnUpdateDisplayRect = vgaR3PortUpdateDisplayRect;
    6519     pThis->IPort.pfnCopyRect          = vgaR3PortCopyRect;
    6520     pThis->IPort.pfnSetRenderVRAM     = vgaR3PortSetRenderVRAM;
     6521    pThisCC->IBase.pfnQueryInterface    = vgaR3PortQueryInterface;
     6522
     6523    pThisCC->IPort.pfnUpdateDisplay     = vgaR3PortUpdateDisplay;
     6524    pThisCC->IPort.pfnUpdateDisplayAll  = vgaR3PortUpdateDisplayAll;
     6525    pThisCC->IPort.pfnQueryVideoMode    = vgaR3PortQueryVideoMode;
     6526    pThisCC->IPort.pfnSetRefreshRate    = vgaR3PortSetRefreshRate;
     6527    pThisCC->IPort.pfnTakeScreenshot    = vgaR3PortTakeScreenshot;
     6528    pThisCC->IPort.pfnFreeScreenshot    = vgaR3PortFreeScreenshot;
     6529    pThisCC->IPort.pfnDisplayBlt        = vgaR3PortDisplayBlt;
     6530    pThisCC->IPort.pfnUpdateDisplayRect = vgaR3PortUpdateDisplayRect;
     6531    pThisCC->IPort.pfnCopyRect          = vgaR3PortCopyRect;
     6532    pThisCC->IPort.pfnSetRenderVRAM     = vgaR3PortSetRenderVRAM;
    65216533# ifdef VBOX_WITH_VMSVGA
    6522     pThis->IPort.pfnSetViewport       = vmsvgaR3PortSetViewport;
     6534    pThisCC->IPort.pfnSetViewport       = vmsvgaR3PortSetViewport;
    65236535# else
    6524     pThis->IPort.pfnSetViewport       = NULL;
     6536    pThisCC->IPort.pfnSetViewport       = NULL;
    65256537# endif
    6526     pThis->IPort.pfnSendModeHint      = vbvaR3PortSendModeHint;
    6527     pThis->IPort.pfnReportHostCursorCapabilities = vgaR3PortReportHostCursorCapabilities;
    6528     pThis->IPort.pfnReportHostCursorPosition = vgaR3PortReportHostCursorPosition;
     6538    pThisCC->IPort.pfnSendModeHint      = vbvaR3PortSendModeHint;
     6539    pThisCC->IPort.pfnReportHostCursorCapabilities = vgaR3PortReportHostCursorCapabilities;
     6540    pThisCC->IPort.pfnReportHostCursorPosition = vgaR3PortReportHostCursorPosition;
    65296541
    65306542# if defined(VBOX_WITH_HGSMI) && defined(VBOX_WITH_VIDEOHWACCEL)
    6531     pThis->IVBVACallbacks.pfnVHWACommandCompleteAsync = vbvaR3VHWACommandCompleteAsync;
     6543    pThisCC->IVBVACallbacks.pfnVHWACommandCompleteAsync = vbvaR3VHWACommandCompleteAsync;
    65326544# endif
    65336545
    6534     pThis->ILeds.pfnQueryStatusLed    = vgaR3PortQueryStatusLed;
     6546    pThisCC->ILeds.pfnQueryStatusLed    = vgaR3PortQueryStatusLed;
    65356547    pThis->Led3D.u32Magic               = PDMLED_MAGIC;
    65366548
     
    65886600    rc = PDMDevHlpPCIIORegionCreateMmio2Ex(pDevIns, pThis->pciRegions.iVRAM, pThis->vram_size,
    65896601                                           PCI_ADDRESS_SPACE_MEM_PREFETCH, 0 /*fFlags*/, vgaR3PciIORegionVRamMapUnmap,
    6590                                            "VRam", (void **)&pThis->vram_ptrR3, &pThis->hMmio2VRam);
     6602                                           "VRam", (void **)&pThisCC->pbVRam, &pThis->hMmio2VRam);
    65916603    AssertLogRelRCReturn(rc, PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
    65926604                                                 N_("Failed to allocate %u bytes of VRAM"), pThis->vram_size));
    65936605# ifndef VGA_WITH_PARTIAL_RING0_MAPPING
    6594     pThis->vram_ptrR0 = (RTR0PTR)pThis->vram_ptrR3;
     6606    pThis->vram_ptrR0 = (RTR0PTR)pThisCC->pbVRam;
    65956607# endif
    65966608
     
    66586670     * Get the VGA BIOS ROM file name.
    66596671     */
    6660     rc = pHlp->pfnCFGMQueryStringAlloc(pCfg, "BiosRom", &pThis->pszVgaBiosFile);
     6672    rc = pHlp->pfnCFGMQueryStringAlloc(pCfg, "BiosRom", &pThisCC->pszVgaBiosFile);
    66616673    if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    66626674    {
    6663         pThis->pszVgaBiosFile = NULL;
     6675        pThisCC->pszVgaBiosFile = NULL;
    66646676        rc = VINF_SUCCESS;
    66656677    }
    66666678    else if (RT_FAILURE(rc))
    66676679        return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Querying \"BiosRom\" as a string failed"));
    6668     else if (!*pThis->pszVgaBiosFile)
    6669     {
    6670         PDMDevHlpMMHeapFree(pDevIns, pThis->pszVgaBiosFile);
    6671         pThis->pszVgaBiosFile = NULL;
     6680    else if (!*pThisCC->pszVgaBiosFile)
     6681    {
     6682        PDMDevHlpMMHeapFree(pDevIns, pThisCC->pszVgaBiosFile);
     6683        pThisCC->pszVgaBiosFile = NULL;
    66726684    }
    66736685
     
    66766688     */
    66776689    RTFILE FileVgaBios = NIL_RTFILE;
    6678     if (pThis->pszVgaBiosFile)
    6679     {
    6680         rc = RTFileOpen(&FileVgaBios, pThis->pszVgaBiosFile,
    6681                         RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
     6690    if (pThisCC->pszVgaBiosFile)
     6691    {
     6692        rc = RTFileOpen(&FileVgaBios, pThisCC->pszVgaBiosFile, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
    66826693        if (RT_SUCCESS(rc))
    66836694        {
    6684             rc = RTFileQuerySize(FileVgaBios, &pThis->cbVgaBios);
     6695            rc = RTFileQuerySize(FileVgaBios, &pThisCC->cbVgaBios);
    66856696            if (RT_SUCCESS(rc))
    66866697            {
    6687                 if (    RT_ALIGN(pThis->cbVgaBios, _4K) != pThis->cbVgaBios
    6688                     ||  pThis->cbVgaBios > _64K
    6689                     ||  pThis->cbVgaBios < 16 * _1K)
     6698                if (    RT_ALIGN(pThisCC->cbVgaBios, _4K) != pThisCC->cbVgaBios
     6699                    ||  pThisCC->cbVgaBios > _64K
     6700                    ||  pThisCC->cbVgaBios < 16 * _1K)
    66906701                    rc = VERR_TOO_MUCH_DATA;
    66916702            }
     
    66966707             * In case of failure simply fall back to the built-in VGA BIOS ROM.
    66976708             */
    6698             Log(("vgaConstruct: Failed to open VGA BIOS ROM file '%s', rc=%Rrc!\n", pThis->pszVgaBiosFile, rc));
     6709            Log(("vgaConstruct: Failed to open VGA BIOS ROM file '%s', rc=%Rrc!\n", pThisCC->pszVgaBiosFile, rc));
    66996710            RTFileClose(FileVgaBios);
    67006711            FileVgaBios = NIL_RTFILE;
    6701             PDMDevHlpMMHeapFree(pDevIns, pThis->pszVgaBiosFile);
    6702             pThis->pszVgaBiosFile = NULL;
     6712            PDMDevHlpMMHeapFree(pDevIns, pThisCC->pszVgaBiosFile);
     6713            pThisCC->pszVgaBiosFile = NULL;
    67036714        }
    67046715    }
     
    67076718     * Attempt to get the VGA BIOS ROM data from file.
    67086719     */
    6709     if (pThis->pszVgaBiosFile)
     6720    if (pThisCC->pszVgaBiosFile)
    67106721    {
    67116722        /*
    67126723         * Allocate buffer for the VGA BIOS ROM data.
    67136724         */
    6714         pThis->pbVgaBios = (uint8_t *)PDMDevHlpMMHeapAlloc(pDevIns, pThis->cbVgaBios);
    6715         if (pThis->pbVgaBios)
     6725        pThisCC->pbVgaBios = (uint8_t *)PDMDevHlpMMHeapAlloc(pDevIns, pThisCC->cbVgaBios);
     6726        if (pThisCC->pbVgaBios)
    67166727        {
    6717             rc = RTFileRead(FileVgaBios, pThis->pbVgaBios, pThis->cbVgaBios, NULL);
     6728            rc = RTFileRead(FileVgaBios, pThisCC->pbVgaBios, pThisCC->cbVgaBios, NULL);
    67186729            if (RT_FAILURE(rc))
    67196730            {
    6720                 AssertMsgFailed(("RTFileRead(,,%d,NULL) -> %Rrc\n", pThis->cbVgaBios, rc));
    6721                 PDMDevHlpMMHeapFree(pDevIns, pThis->pbVgaBios);
    6722                 pThis->pbVgaBios = NULL;
     6731                AssertMsgFailed(("RTFileRead(,,%d,NULL) -> %Rrc\n", pThisCC->cbVgaBios, rc));
     6732                PDMDevHlpMMHeapFree(pDevIns, pThisCC->pbVgaBios);
     6733                pThisCC->pbVgaBios = NULL;
    67236734            }
    67246735            rc = VINF_SUCCESS;
     
    67286739    }
    67296740    else
    6730         pThis->pbVgaBios = NULL;
     6741        pThisCC->pbVgaBios = NULL;
    67316742
    67326743    /* cleanup */
     
    67396750    uint64_t        cbVgaBiosBinary;
    67406751    uint32_t        fFlags = 0;
    6741     if (pThis->pbVgaBios == NULL)
     6752    if (pThisCC->pbVgaBios == NULL)
    67426753    {
    67436754        CPUMMICROARCH enmMicroarch = pVM ? CPUMGetGuestMicroarch(pVM) : kCpumMicroarch_Intel_P6;
     
    67676778    else
    67686779    {
    6769         pbVgaBiosBinary = pThis->pbVgaBios;
    6770         cbVgaBiosBinary = pThis->cbVgaBios;
     6780        pbVgaBiosBinary = pThisCC->pbVgaBios;
     6781        cbVgaBiosBinary = pThisCC->cbVgaBios;
    67716782    }
    67726783
     
    67906801     * Create the refresh timer.
    67916802     */
    6792     rc = PDMDevHlpTimerCreate(pDevIns, TMCLOCK_REAL, vgaTimerRefresh, pThis, TMTIMER_FLAGS_NO_CRIT_SECT,
     6803    rc = PDMDevHlpTimerCreate(pDevIns, TMCLOCK_REAL, vgaTimerRefresh, NULL, TMTIMER_FLAGS_NO_CRIT_SECT,
    67936804                              "VGA Refresh Timer", &pThis->hRefreshTimer);
    67946805    AssertRCReturn(rc, rc);
     
    68346845     */
    68356846    AssertRelease(sizeof(VBEHEADER) + cb < 65536);
    6836     pThis->cbVBEExtraData = (uint16_t)(sizeof(VBEHEADER) + cb);
    6837     pThis->pbVBEExtraData = (uint8_t *)PDMDevHlpMMHeapAllocZ(pDevIns, pThis->cbVBEExtraData);
    6838     if (!pThis->pbVBEExtraData)
     6847    pThisCC->cbVBEExtraData = (uint16_t)(sizeof(VBEHEADER) + cb);
     6848    pThisCC->pbVBEExtraData = (uint8_t *)PDMDevHlpMMHeapAllocZ(pDevIns, pThisCC->cbVBEExtraData);
     6849    if (!pThisCC->pbVBEExtraData)
    68396850        return VERR_NO_MEMORY;
    68406851
    6841     pVBEDataHdr = (PVBEHEADER)pThis->pbVBEExtraData;
     6852    pVBEDataHdr = (PVBEHEADER)pThisCC->pbVBEExtraData;
    68426853    pVBEDataHdr->u16Signature = VBEHEADER_MAGIC;
    68436854    pVBEDataHdr->cbData = cb;
     
    70597070     * Get the Logo file name.
    70607071     */
    7061     rc = pHlp->pfnCFGMQueryStringAlloc(pCfg, "LogoFile", &pThis->pszLogoFile);
     7072    rc = pHlp->pfnCFGMQueryStringAlloc(pCfg, "LogoFile", &pThisCC->pszLogoFile);
    70627073    if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    7063         pThis->pszLogoFile = NULL;
     7074        pThisCC->pszLogoFile = NULL;
    70647075    else if (RT_FAILURE(rc))
    70657076        return PDMDEV_SET_ERROR(pDevIns, rc,
    70667077                                N_("Configuration error: Querying \"LogoFile\" as a string failed"));
    7067     else if (!*pThis->pszLogoFile)
    7068     {
    7069         PDMDevHlpMMHeapFree(pDevIns, pThis->pszLogoFile);
    7070         pThis->pszLogoFile = NULL;
     7078    else if (!*pThisCC->pszLogoFile)
     7079    {
     7080        PDMDevHlpMMHeapFree(pDevIns, pThisCC->pszLogoFile);
     7081        pThisCC->pszLogoFile = NULL;
    70717082    }
    70727083
     
    70767087    LogoHdr.cbLogo = g_cbVgaDefBiosLogo;
    70777088    RTFILE FileLogo = NIL_RTFILE;
    7078     if (pThis->pszLogoFile)
    7079     {
    7080         rc = RTFileOpen(&FileLogo, pThis->pszLogoFile,
     7089    if (pThisCC->pszLogoFile)
     7090    {
     7091        rc = RTFileOpen(&FileLogo, pThisCC->pszLogoFile,
    70817092                        RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
    70827093        if (RT_SUCCESS(rc))
     
    70977108             * Ignore failure and fall back to the default logo.
    70987109             */
    7099             LogRel(("vgaR3Construct: Failed to open logo file '%s', rc=%Rrc!\n", pThis->pszLogoFile, rc));
     7110            LogRel(("vgaR3Construct: Failed to open logo file '%s', rc=%Rrc!\n", pThisCC->pszLogoFile, rc));
    71007111            if (FileLogo != NIL_RTFILE)
    71017112                RTFileClose(FileLogo);
    71027113            FileLogo = NIL_RTFILE;
    7103             PDMDevHlpMMHeapFree(pDevIns, pThis->pszLogoFile);
    7104             pThis->pszLogoFile = NULL;
     7114            PDMDevHlpMMHeapFree(pDevIns, pThisCC->pszLogoFile);
     7115            pThisCC->pszLogoFile = NULL;
    71057116        }
    71067117    }
     
    71167127     * Let us fall back to default logo on read failure.
    71177128     */
    7118     pThis->cbLogo = LogoHdr.cbLogo;
     7129    pThisCC->cbLogo = LogoHdr.cbLogo;
    71197130    if (g_cbVgaDefBiosLogo)
    7120         pThis->cbLogo = g_cbVgaDefBiosLogo;
     7131        pThisCC->cbLogo = g_cbVgaDefBiosLogo;
    71217132# ifndef VBOX_OSE
    71227133    if (g_cbVgaDefBiosLogoNY)
    7123         pThis->cbLogo = g_cbVgaDefBiosLogoNY;
     7134        pThisCC->cbLogo = g_cbVgaDefBiosLogoNY;
    71247135# endif
    7125     pThis->cbLogo += sizeof(LogoHdr);
    7126 
    7127     pThis->pbLogo = (uint8_t *)PDMDevHlpMMHeapAlloc(pDevIns, pThis->cbLogo);
    7128     if (pThis->pbLogo)
     7136    pThisCC->cbLogo += sizeof(LogoHdr);
     7137
     7138    pThisCC->pbLogo = (uint8_t *)PDMDevHlpMMHeapAlloc(pDevIns, pThisCC->cbLogo);
     7139    if (pThisCC->pbLogo)
    71297140    {
    71307141        /*
    71317142         * Write the logo header.
    71327143         */
    7133         PLOGOHDR pLogoHdr = (PLOGOHDR)pThis->pbLogo;
     7144        PLOGOHDR pLogoHdr = (PLOGOHDR)pThisCC->pbLogo;
    71347145        *pLogoHdr = LogoHdr;
    71357146
     
    71377148         * Write the logo bitmap.
    71387149         */
    7139         if (pThis->pszLogoFile)
     7150        if (pThisCC->pszLogoFile)
    71407151        {
    71417152            rc = RTFileRead(FileLogo, pLogoHdr + 1, LogoHdr.cbLogo, NULL);
    71427153            if (RT_SUCCESS(rc))
    7143                 rc = vbeR3ParseBitmap(pThis);
     7154                rc = vbeR3ParseBitmap(pThisCC);
    71447155            if (RT_FAILURE(rc))
    71457156            {
    71467157                LogRel(("Error %Rrc reading logo file '%s', using internal logo\n",
    7147                        rc, pThis->pszLogoFile));
     7158                       rc, pThisCC->pszLogoFile));
    71487159                pLogoHdr->cbLogo = LogoHdr.cbLogo = g_cbVgaDefBiosLogo;
    71497160            }
    71507161        }
    7151         if (   !pThis->pszLogoFile
     7162        if (   !pThisCC->pszLogoFile
    71527163            || RT_FAILURE(rc))
    71537164        {
     
    71647175                pLogoHdr->cbLogo = LogoHdr.cbLogo = g_cbVgaDefBiosLogoNY;
    71657176                memcpy(pLogoHdr + 1, g_abVgaDefBiosLogoNY, LogoHdr.cbLogo);
    7166                 pThis->fBootMenuInverse = true;
     7177                pThisCC->fBootMenuInverse = true;
    71677178            }
    71687179            else
    71697180# endif
    71707181                memcpy(pLogoHdr + 1, g_abVgaDefBiosLogo, LogoHdr.cbLogo);
    7171             rc = vbeR3ParseBitmap(pThis);
    7172             if (RT_FAILURE(rc))
    7173                 AssertReleaseMsgFailed(("Parsing of internal bitmap failed! vbeR3ParseBitmap() -> %Rrc\n", rc));
     7182            rc = vbeR3ParseBitmap(pThisCC);
     7183            AssertLogRelMsgReturn(RT_SUCCESS(rc), ("Parsing of internal bitmap failed! vbeR3ParseBitmap() -> %Rrc\n", rc), rc);
    71747184        }
    71757185
     
    71867196
    71877197# ifdef VBOX_WITH_HGSMI
    7188     VBVAInit (pThis);
     7198    VBVAInit(pDevIns, pThis, pThisCC);
    71897199# endif
    71907200
     
    71927202    if (rc == VINF_SUCCESS)
    71937203    {
    7194         rc = vboxVDMAConstruct(pThis, 1024);
     7204        rc = vboxVDMAConstruct(pThis, pThisCC, 1024);
    71957205        AssertRC(rc);
    71967206    }
     
    72277237         * Attach status driver (optional).
    72287238         */
    7229         rc = PDMDevHlpDriverAttach(pDevIns, PDM_STATUS_LUN, &pThis->IBase, &pBase, "Status Port");
     7239        rc = PDMDevHlpDriverAttach(pDevIns, PDM_STATUS_LUN, &pThisCC->IBase, &pBase, "Status Port");
    72307240        if (RT_SUCCESS(rc))
    7231             pThis->pLedsConnector = PDMIBASE_QUERY_INTERFACE(pBase, PDMILEDCONNECTORS);
     7241            pThisCC->pLedsConnector = PDMIBASE_QUERY_INTERFACE(pBase, PDMILEDCONNECTORS);
    72327242        else if (rc == VERR_PDM_NO_ATTACHED_DRIVER)
    72337243        {
     
    72527262{
    72537263    PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
    7254     PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     7264    PVGASTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     7265    PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
    72557266
    72567267    int rc = PDMDevHlpSetDeviceCritSect(pDevIns, &pThis->CritSect);
     
    73117322     */
    73127323# if defined(VBOX_WITH_2X_4GB_ADDR_SPACE) || (defined(IN_RING0) && defined(VGA_WITH_PARTIAL_RING0_MAPPING))
    7313     rc = PDMDevHlpMmio2SetUpContext(pDevIns, pThis->hMmio2VRam, 0 /* off */, VGA_MAPPING_SIZE, (void **)&pThis->CTX_SUFF(vram_ptr));
     7324    rc = PDMDevHlpMmio2SetUpContext(pDevIns, pThis->hMmio2VRam, 0 /* off */, VGA_MAPPING_SIZE, (void **)&pThisCC->pbVRam);
    73147325    AssertLogRelMsgRCReturn(rc, ("PDMDevHlpMmio2SetUpContext(,VRAM,0,%#x,) -> %Rrc\n", VGA_MAPPING_SIZE, rc), rc);
    73157326# endif
     
    73497360    /* .uSharedVersion = */         42,
    73507361    /* .cbInstanceShared = */       sizeof(VGASTATE),
    7351     /* .cbInstanceCC = */           0,
    7352     /* .cbInstanceRC = */           0,
     7362    /* .cbInstanceCC = */           sizeof(VGASTATECC),
     7363    /* .cbInstanceRC = */           sizeof(VGASTATERC),
    73537364    /* .cMaxPciDevices = */         1,
    73547365    /* .cMaxMsixVectors = */        0,
  • trunk/src/VBox/Devices/Graphics/DevVGA.h

    r82094 r82109  
    282282
    283283
     284/**
     285 * The shared VGA state data.
     286 */
    284287typedef struct VGAState
    285288{
    286 #ifndef VBOX
    287     VGA_STATE_COMMON
    288 #else /* VBOX */
    289     R3PTRTYPE(uint8_t *) vram_ptrR3;
    290     R3PTRTYPE(FNGETBPP *) get_bpp;
    291     R3PTRTYPE(FNGETOFFSETS *) get_offsets;
    292     R3PTRTYPE(FNGETRESOLUTION *) get_resolution;
    293     R3PTRTYPE(FNRGBTOPIXEL *) rgb_to_pixel;
    294     R3PTRTYPE(FNCURSORINVALIDATE *) cursor_invalidate;
    295     R3PTRTYPE(FNCURSORDRAWLINE *) cursor_draw_line;
    296     RTR3PTR R3PtrCmnAlignment;
    297289    uint32_t vram_size;
    298290    uint32_t latch;
     
    337329    bool last_cur_blink, last_chr_blink;
    338330    uint32_t cursor_offset;
    339     /* hardware mouse cursor support */
     331    /** hardware mouse cursor support */
    340332    uint32_t invalidated_y_table[VGA_MAX_HEIGHT / 32];
    341     /* tell for each page if it has been updated since the last time */
     333    /** tell for each page if it has been updated since the last time */
    342334    uint32_t last_palette[256];
    343335    uint32_t last_ch_attr[CH_ATTR_SIZE]; /* XXX: make it dynamic */
     
    346338    uint32_t                    u32Marker;
    347339
    348 # ifdef VBOX_WITH_RAW_MODE_KEEP
    349     /** Pointer to the device instance - RC Ptr. */
    350     PPDMDEVINSRC                pDevInsRC;
    351     /** Pointer to the GC vram mapping. */
    352     RCPTRTYPE(uint8_t *)        vram_ptrRC;
    353     uint32_t                    Padding1;
    354 # endif
    355 
    356     /** Pointer to the device instance - R3 Ptr. */
    357     PPDMDEVINSR3                pDevInsR3;
    358 # ifdef VBOX_WITH_HGSMI
    359     R3PTRTYPE(PHGSMIINSTANCE)   pHGSMI;
    360 # endif
    361 # ifdef VBOX_WITH_VDMA
    362     R3PTRTYPE(PVBOXVDMAHOST)    pVdma;
    363 # endif
    364     /** LUN\#0: The display port base interface. */
    365     PDMIBASE                    IBase;
    366     /** LUN\#0: The display port interface. */
    367     PDMIDISPLAYPORT             IPort;
    368 # if defined(VBOX_WITH_HGSMI)
    369     /** LUN\#0: VBVA callbacks interface */
    370     PDMIDISPLAYVBVACALLBACKS    IVBVACallbacks;
    371 # else
    372     RTR3PTR                     Padding2;
    373 # endif
    374     /** Status LUN: Leds interface. */
    375     PDMILEDPORTS                ILeds;
    376 
    377     /** Pointer to base interface of the driver. */
    378     R3PTRTYPE(PPDMIBASE)        pDrvBase;
    379     /** Pointer to display connector interface of the driver. */
    380     R3PTRTYPE(PPDMIDISPLAYCONNECTOR) pDrv;
    381 
    382     /** Status LUN: Partner of ILeds. */
    383     R3PTRTYPE(PPDMILEDCONNECTORS)   pLedsConnector;
    384 
    385340    /** Refresh timer handle - HC. */
    386341    TMTIMERHANDLE               hRefreshTimer;
    387342
    388     /** Pointer to the device instance - R0 Ptr. */
    389     PPDMDEVINSR0                pDevInsR0;
    390     /** The R0 vram pointer... */
    391     R0PTRTYPE(uint8_t *)        vram_ptrR0;
    392 
    393 # ifdef VBOX_WITH_VMSVGA
     343#ifdef VBOX_WITH_VMSVGA
    394344    VMSVGAState                 svga;
    395 # endif
     345#endif
    396346
    397347    /** The number of monitors. */
     
    412362    /** Whether 3D is enabled for the VM. */
    413363    bool                        f3DEnabled;
    414 # ifdef VBOX_WITH_VMSVGA
     364#ifdef VBOX_WITH_VMSVGA
    415365    /* Whether the SVGA emulation is enabled or not. */
    416366    bool                        fVMSVGAEnabled;
     
    418368    bool                        fVMSVGAPciBarLayout;
    419369    bool                        Padding4[4];
    420 # else
     370#else
    421371    bool                        Padding4[3+4];
    422 # endif
     372#endif
    423373
    424374    struct {
    425375        uint32_t                    u32Padding1;
    426376        uint32_t                    iVRAM;
    427 # ifdef VBOX_WITH_VMSVGA
     377#ifdef VBOX_WITH_VMSVGA
    428378        uint32_t                    iIO;
    429379        uint32_t                    iFIFO;
    430 # endif
     380#endif
    431381    } pciRegions;
    432382
     
    438388    /** The critical section protect the instance data. */
    439389    PDMCRITSECT                 CritSect;
    440 
    441     STAMPROFILE                 StatRZMemoryRead;
    442     STAMPROFILE                 StatR3MemoryRead;
    443     STAMPROFILE                 StatRZMemoryWrite;
    444     STAMPROFILE                 StatR3MemoryWrite;
    445     STAMCOUNTER                 StatMapPage;            /**< Counts IOMMMIOMapMMIO2Page calls.  */
    446     STAMCOUNTER                 StatUpdateDisp;         /**< Counts vgaPortUpdateDisplay calls.  */
    447 # ifdef VBOX_WITH_HGSMI
    448     STAMCOUNTER                 StatHgsmiMdaCgaAccesses;
    449 # endif
    450390
    451391    /* Keep track of ring 0 latched accesses to the VGA MMIO memory. */
     
    455395    uint16_t                    iMask;
    456396
    457 # ifdef VBE_BYTEWISE_IO
     397#ifdef VBE_BYTEWISE_IO
    458398    /** VBE read/write data/index flags */
    459399    uint8_t                     fReadVBEData;
     
    467407    uint8_t                     cbWriteVBEExtraAddress;
    468408    uint8_t                     Padding5;
    469 # endif
     409#endif
    470410
    471411    /** Retrace emulation state */
     
    474414    vga_retrace_s               retrace_state;
    475415
    476     /** The VBE BIOS extra data. */
    477     R3PTRTYPE(uint8_t *)        pbVBEExtraData;
    478     /** The size of the VBE BIOS extra data. */
    479     uint16_t                    cbVBEExtraData;
    480     /** The VBE BIOS current memory address. */
    481     uint16_t                    u16VBEExtraAddress;
    482     uint16_t                    Padding7[2];
    483 
    484     /** The BIOS logo data. */
    485     R3PTRTYPE(uint8_t *)        pbLogo;
    486     /** The name of the logo file. */
    487     R3PTRTYPE(char *)           pszLogoFile;
    488     /** Bitmap image data. */
    489     R3PTRTYPE(uint8_t *)        pbLogoBitmap;
     416#ifdef VBOX_WITH_HGSMI
     417    /** Base port in the assigned PCI I/O space. */
     418    RTIOPORT                    IOPortBase;
     419# ifdef VBOX_WITH_WDDM
     420    uint8_t                     Padding10[2];
     421    /** Specifies guest driver caps, i.e. whether it can handle IRQs from the
     422     * adapter, the way it can handle async HGSMI command completion, etc. */
     423    uint32_t                    fGuestCaps;
     424    uint32_t                    fScanLineCfg;
     425    uint32_t                    Padding11;
     426# else
     427    uint8_t                     Padding11[14];
     428# endif
     429
     430    /** The critical section serializes the HGSMI IRQ setting/clearing. */
     431    PDMCRITSECT                 CritSectIRQ;
     432    /** VBVARaiseIRQ flags which were set when the guest was still processing previous IRQ. */
     433    uint32_t                    fu32PendingGuestFlags;
     434    uint32_t                    Padding12;
     435#endif /* VBOX_WITH_HGSMI */
     436
     437    PDMLED Led3D;
     438
     439    struct {
     440        volatile uint32_t cPending;
     441        uint32_t Padding1;
     442        union
     443        {
     444            RTLISTNODE PendingList;
     445            /* make sure the structure sized cross different contexts correctly */
     446            struct
     447            {
     448                R3PTRTYPE(void *) dummy1;
     449                R3PTRTYPE(void *) dummy2;
     450            } dummy;
     451        };
     452    } pendingVhwaCommands;
     453
     454    /** The MMIO handle of the legacy graphics buffer/regs at 0xa0000-0xbffff. */
     455    PGMMMIO2HANDLE              hMmioLegacy;
     456
     457    /** @name I/O ports for range 0x3c0-3cf.
     458     * @{ */
     459    IOMIOPORTHANDLE             hIoPortAr;
     460    IOMIOPORTHANDLE             hIoPortMsrSt00;
     461    IOMIOPORTHANDLE             hIoPort3c3;
     462    IOMIOPORTHANDLE             hIoPortSr;
     463    IOMIOPORTHANDLE             hIoPortDac;
     464    IOMIOPORTHANDLE             hIoPortPos;
     465    IOMIOPORTHANDLE             hIoPortGr;
     466    /** @} */
     467
     468    /** @name I/O ports for MDA 0x3b0-0x3bf (sparse)
     469     * @{ */
     470    IOMIOPORTHANDLE             hIoPortMdaCrt;
     471    IOMIOPORTHANDLE             hIoPortMdaFcrSt;
     472    /** @} */
     473
     474    /** @name I/O ports for CGA 0x3d0-0x3df (sparse)
     475     * @{ */
     476    IOMIOPORTHANDLE             hIoPortCgaCrt;
     477    IOMIOPORTHANDLE             hIoPortCgaFcrSt;
     478    /** @} */
     479
     480#ifdef VBOX_WITH_HGSMI
     481    /** @name I/O ports for HGSMI 0x3b0-03b3 and 0x3d0-03d3 (ring-3 only)
     482     * @{ */
     483    IOMIOPORTHANDLE             hIoPortHgsmiHost;
     484    IOMIOPORTHANDLE             hIoPortHgsmiGuest;
     485    /** @} */
     486#endif
     487
     488    /** @name I/O ports for Boch VBE 0x1ce-0x1cf
     489     *  @{ */
     490    IOMIOPORTHANDLE             hIoPortVbeIndex;
     491    IOMIOPORTHANDLE             hIoPortVbeData;
     492    /** @} */
     493
     494    /** The BIOS printf I/O port. */
     495    IOMIOPORTHANDLE             hIoPortBios;
     496    /** The VBE extra data I/O port. */
     497    IOMIOPORTHANDLE             hIoPortVbeExtra;
     498    /** The logo command I/O port. */
     499    IOMIOPORTHANDLE             hIoPortCmdLogo;
     500
     501#ifdef VBOX_WITH_VMSVGA
     502    /** VMSVGA: I/O port PCI region. */
     503    IOMIOPORTHANDLE             hIoPortVmSvga;
     504    /** VMSVGA: The MMIO2 handle of the FIFO PCI region. */
     505    PGMMMIO2HANDLE              hMmio2VmSvgaFifo;
     506#endif
     507    /** The MMIO2 handle of the VRAM. */
     508    PGMMMIO2HANDLE              hMmio2VRam;
     509
     510    STAMPROFILE                 StatRZMemoryRead;
     511    STAMPROFILE                 StatR3MemoryRead;
     512    STAMPROFILE                 StatRZMemoryWrite;
     513    STAMPROFILE                 StatR3MemoryWrite;
     514    STAMCOUNTER                 StatMapPage;            /**< Counts IOMMMIOMapMMIO2Page calls.  */
     515    STAMCOUNTER                 StatUpdateDisp;         /**< Counts vgaPortUpdateDisplay calls.  */
     516#ifdef VBOX_WITH_HGSMI
     517    STAMCOUNTER                 StatHgsmiMdaCgaAccesses;
     518#endif
     519} VGAState;
     520#ifdef VBOX
     521/** VGA state. */
     522typedef VGAState VGASTATE;
     523/** Pointer to the VGA state. */
     524typedef VGASTATE *PVGASTATE;
     525AssertCompileMemberAlignment(VGASTATE, bank_offset, 8);
     526AssertCompileMemberAlignment(VGASTATE, font_offsets, 8);
     527AssertCompileMemberAlignment(VGASTATE, last_ch_attr, 8);
     528AssertCompileMemberAlignment(VGASTATE, u32Marker, 8);
     529#endif
     530
     531
     532/**
     533 * The VGA state data for ring-3 context.
     534 */
     535typedef struct VGASTATER3
     536{
     537    R3PTRTYPE(uint8_t *)        pbVRam;
     538    R3PTRTYPE(FNGETBPP *)       get_bpp;
     539    R3PTRTYPE(FNGETOFFSETS *)   get_offsets;
     540    R3PTRTYPE(FNGETRESOLUTION *) get_resolution;
     541    R3PTRTYPE(FNRGBTOPIXEL *)   rgb_to_pixel;
     542    R3PTRTYPE(FNCURSORINVALIDATE *) cursor_invalidate;
     543    R3PTRTYPE(FNCURSORDRAWLINE *) cursor_draw_line;
     544
     545    /** Pointer to the device instance.
     546     * @note Only for getting our bearings in interface methods.  */
     547    PPDMDEVINSR3                pDevIns;
     548#ifdef VBOX_WITH_HGSMI
     549    R3PTRTYPE(PHGSMIINSTANCE)   pHGSMI;
     550#endif
     551#ifdef VBOX_WITH_VDMA
     552    R3PTRTYPE(PVBOXVDMAHOST)    pVdma;
     553#endif
     554
     555    /** LUN\#0: The display port base interface. */
     556    PDMIBASE                    IBase;
     557    /** LUN\#0: The display port interface. */
     558    PDMIDISPLAYPORT             IPort;
     559#ifdef VBOX_WITH_HGSMI
     560    /** LUN\#0: VBVA callbacks interface */
     561    PDMIDISPLAYVBVACALLBACKS    IVBVACallbacks;
     562#endif
     563    /** Status LUN: Leds interface. */
     564    PDMILEDPORTS                ILeds;
     565
     566    /** Pointer to base interface of the driver. */
     567    R3PTRTYPE(PPDMIBASE)        pDrvBase;
     568    /** Pointer to display connector interface of the driver. */
     569    R3PTRTYPE(PPDMIDISPLAYCONNECTOR) pDrv;
     570
     571    /** Status LUN: Partner of ILeds. */
     572    R3PTRTYPE(PPDMILEDCONNECTORS) pLedsConnector;
     573
     574    /** The VGA BIOS ROM data. */
     575    R3PTRTYPE(uint8_t *)        pbVgaBios;
     576    /** The size of the VGA BIOS ROM. */
     577    uint64_t                    cbVgaBios;
     578    /** The name of the VGA BIOS ROM file. */
     579    R3PTRTYPE(char *)           pszVgaBiosFile;
     580
     581    /** @name Logo data
     582     * @{ */
    490583    /** Current logo data offset. */
    491584    uint32_t                    offLogoData;
     
    514607    /** Palette data. */
    515608    uint32_t                    au32LogoPalette[256];
    516 
    517     /** The VGA BIOS ROM data. */
    518     R3PTRTYPE(uint8_t *)        pbVgaBios;
    519     /** The size of the VGA BIOS ROM. */
    520     uint64_t                    cbVgaBios;
    521     /** The name of the VGA BIOS ROM file. */
    522     R3PTRTYPE(char *)           pszVgaBiosFile;
    523 # if HC_ARCH_BITS == 32
    524     uint32_t                    Padding9;
    525 # endif
    526 
    527 # ifdef VBOX_WITH_HGSMI
    528     /** Base port in the assigned PCI I/O space. */
    529     RTIOPORT                    IOPortBase;
    530 #  ifdef VBOX_WITH_WDDM
    531     uint8_t                     Padding10[2];
    532     /** Specifies guest driver caps, i.e. whether it can handle IRQs from the
    533      * adapter, the way it can handle async HGSMI command completion, etc. */
    534     uint32_t                    fGuestCaps;
    535     uint32_t                    fScanLineCfg;
    536     uint32_t                    Padding11;
    537 #  else
    538     uint8_t                     Padding11[14];
    539 #  endif
    540 
    541     /** The critical section serializes the HGSMI IRQ setting/clearing. */
    542     PDMCRITSECT                 CritSectIRQ;
    543     /** VBVARaiseIRQ flags which were set when the guest was still processing previous IRQ. */
    544     uint32_t                    fu32PendingGuestFlags;
    545     uint32_t                    Padding12;
    546 # endif /* VBOX_WITH_HGSMI */
    547 
    548     PDMLED Led3D;
    549 
    550     struct {
    551         volatile uint32_t cPending;
    552         uint32_t Padding1;
    553         union
    554         {
    555             RTLISTNODE PendingList;
    556             /* make sure the structure sized cross different contexts correctly */
    557             struct
    558             {
    559                 R3PTRTYPE(void *) dummy1;
    560                 R3PTRTYPE(void *) dummy2;
    561             } dummy;
    562         };
    563     } pendingVhwaCommands;
    564 
    565     /** The MMIO handle of the legacy graphics buffer/regs at 0xa0000-0xbffff. */
    566     PGMMMIO2HANDLE              hMmioLegacy;
    567 
    568     /** @name I/O ports for range 0x3c0-3cf.
     609    /** The BIOS logo data. */
     610    R3PTRTYPE(uint8_t *)        pbLogo;
     611    /** The name of the logo file. */
     612    R3PTRTYPE(char *)           pszLogoFile;
     613    /** Bitmap image data. */
     614    R3PTRTYPE(uint8_t *)        pbLogoBitmap;
     615    /** @} */
     616
     617    /** @name VBE extra data (modes)
    569618     * @{ */
    570     IOMIOPORTHANDLE             hIoPortAr;
    571     IOMIOPORTHANDLE             hIoPortMsrSt00;
    572     IOMIOPORTHANDLE             hIoPort3c3;
    573     IOMIOPORTHANDLE             hIoPortSr;
    574     IOMIOPORTHANDLE             hIoPortDac;
    575     IOMIOPORTHANDLE             hIoPortPos;
    576     IOMIOPORTHANDLE             hIoPortGr;
     619    /** The VBE BIOS extra data. */
     620    R3PTRTYPE(uint8_t *)        pbVBEExtraData;
     621    /** The size of the VBE BIOS extra data. */
     622    uint16_t                    cbVBEExtraData;
     623    /** The VBE BIOS current memory address. */
     624    uint16_t                    u16VBEExtraAddress;
     625    uint16_t                    Padding7[2];
    577626    /** @} */
    578627
    579     /** @name I/O ports for MDA 0x3b0-0x3bf (sparse)
    580      * @{ */
    581     IOMIOPORTHANDLE             hIoPortMdaCrt;
    582     IOMIOPORTHANDLE             hIoPortMdaFcrSt;
    583     /** @} */
    584 
    585     /** @name I/O ports for CGA 0x3d0-0x3df (sparse)
    586      * @{ */
    587     IOMIOPORTHANDLE             hIoPortCgaCrt;
    588     IOMIOPORTHANDLE             hIoPortCgaFcrSt;
    589     /** @} */
    590 
    591 # ifdef VBOX_WITH_HGSMI
    592     /** @name I/O ports for HGSMI 0x3b0-03b3 and 0x3d0-03d3 (ring-3 only)
    593      * @{ */
    594     IOMIOPORTHANDLE             hIoPortHgsmiHost;
    595     IOMIOPORTHANDLE             hIoPortHgsmiGuest;
    596     /** @} */
    597 # endif
    598 
    599     /** @name I/O ports for Boch VBE 0x1ce-0x1cf
    600      *  @{ */
    601     IOMIOPORTHANDLE             hIoPortVbeIndex;
    602     IOMIOPORTHANDLE             hIoPortVbeData;
    603     /** @} */
    604 
    605     /** The BIOS printf I/O port. */
    606     IOMIOPORTHANDLE             hIoPortBios;
    607     /** The VBE extra data I/O port. */
    608     IOMIOPORTHANDLE             hIoPortVbeExtra;
    609     /** The logo command I/O port. */
    610     IOMIOPORTHANDLE             hIoPortCmdLogo;
    611 
    612 # ifdef VBOX_WITH_VMSVGA
    613     /** VMSVGA: I/O port PCI region. */
    614     IOMIOPORTHANDLE             hIoPortVmSvga;
    615     /** VMSVGA: The MMIO2 handle of the FIFO PCI region. */
    616     PGMMMIO2HANDLE              hMmio2VmSvgaFifo;
    617 # endif
    618     /** The MMIO2 handle of the VRAM. */
    619     PGMMMIO2HANDLE              hMmio2VRam;
    620 #endif /* VBOX */
    621 } VGAState;
    622 #ifdef VBOX
    623 /** VGA state. */
    624 typedef VGAState VGASTATE;
    625 /** Pointer to the VGA state. */
    626 typedef VGASTATE *PVGASTATE;
    627 AssertCompileMemberAlignment(VGASTATE, bank_offset, 8);
    628 AssertCompileMemberAlignment(VGASTATE, font_offsets, 8);
    629 AssertCompileMemberAlignment(VGASTATE, last_ch_attr, 8);
    630 AssertCompileMemberAlignment(VGASTATE, u32Marker, 8);
    631 #endif
     628} VGASTATER3;
     629/** Pointer to the ring-3 VGA state. */
     630typedef VGASTATER3 *PVGASTATER3;
     631
     632
     633/**
     634 * The VGA state data for ring-0 context.
     635 */
     636typedef struct VGASTATER0
     637{
     638    /** The R0 vram pointer... */
     639    R0PTRTYPE(uint8_t *)        pbVRam;
     640} VGASTATER0;
     641/** Pointer to the ring-0 VGA state. */
     642typedef VGASTATER0 *PVGASTATER0;
     643
     644
     645/**
     646 * The VGA state data for raw-mode context.
     647 */
     648typedef struct VGASTATERC
     649{
     650    /** Pointer to the GC vram mapping. */
     651    RCPTRTYPE(uint8_t *)        pbVRam;
     652} VGASTATERC;
     653/** Pointer to the raw-mode VGA state. */
     654typedef VGASTATERC *PVGASTATERC;
     655
     656
     657/** The VGA state for the current context. */
     658typedef CTX_SUFF(VGASTATE) VGASTATECC;
     659/** Pointer to the VGA state for the current context. */
     660typedef CTX_SUFF(PVGASTATE) PVGASTATECC;
     661
     662
    632663
    633664/** VBE Extra Data. */
     
    648679
    649680#ifdef VBOX_WITH_HGSMI
    650 int      VBVAInit       (PVGASTATE pVGAState);
    651 void     VBVADestroy    (PVGASTATE pVGAState);
    652 int      VBVAUpdateDisplay (PVGASTATE pVGAState);
    653 void     VBVAReset (PVGASTATE pVGAState);
    654 void     VBVAPause (PVGASTATE pVGAState, bool fPause);
    655 void     VBVAOnVBEChanged(PVGASTATE pVGAState);
    656 void     VBVAOnResume(PVGASTATE pThis);
    657 
    658 bool VBVAIsPaused(PVGASTATE pVGAState);
    659 bool VBVAIsEnabled(PVGASTATE pVGAState);
    660 
    661 void VBVARaiseIrq(PVGASTATE pVGAState, uint32_t fFlags);
    662 
    663 int VBVAInfoView(PVGASTATE pVGAState, const VBVAINFOVIEW RT_UNTRUSTED_VOLATILE_HOST *pView);
    664 int VBVAInfoScreen(PVGASTATE pVGAState, const VBVAINFOSCREEN RT_UNTRUSTED_VOLATILE_HOST *pScreen);
    665 int VBVAGetInfoViewAndScreen(PVGASTATE pVGAState, uint32_t u32ViewIndex, VBVAINFOVIEW *pView, VBVAINFOSCREEN *pScreen);
     681int     VBVAInit(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC);
     682void    VBVADestroy(PVGASTATECC pThisCC);
     683int     VBVAUpdateDisplay(PVGASTATE pThis, PVGASTATECC pThisCC);
     684void    VBVAReset(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC);
     685void    VBVAOnVBEChanged(PVGASTATE pThis, PVGASTATECC pThisCC);
     686void    VBVAOnResume(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC);
     687
     688bool    VBVAIsPaused(PVGASTATECC pThisCC);
     689#ifdef UNUSED_FUNCTION
     690bool    VBVAIsEnabled(PVGASTATECC pThisCC);
     691#endif
     692
     693void    VBVARaiseIrq(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC, uint32_t fFlags);
     694
     695int     VBVAInfoScreen(PVGASTATE pThis, const VBVAINFOSCREEN RT_UNTRUSTED_VOLATILE_HOST *pScreen);
     696#ifdef UNUSED_FUNCTION
     697int     VBVAGetInfoViewAndScreen(PVGASTATE pThis, PVGASTATECC pThisCC, uint32_t u32ViewIndex,
     698                                 VBVAINFOVIEW *pView, VBVAINFOSCREEN *pScreen);
     699#endif
    666700
    667701/* @return host-guest flags that were set on reset
     
    673707DECLCALLBACK(int) vbvaR3VHWACommandCompleteAsync(PPDMIDISPLAYVBVACALLBACKS pInterface,
    674708                                                 VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *pCmd);
    675 int vbvaVHWAConstruct(PVGASTATE pVGAState);
    676 int vbvaVHWAReset(PVGASTATE pVGAState);
    677 
    678 void vbvaTimerCb(PVGASTATE pVGAState);
     709int vbvaVHWAConstruct(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC);
     710
     711void vbvaTimerCb(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC);
    679712
    680713int vboxVBVASaveStatePrep(PPDMDEVINS pDevIns);
     
    682715# endif
    683716
    684 #define PPDMIDISPLAYVBVACALLBACKS_2_PVGASTATE(_pcb) ( (PVGASTATE)((uint8_t *)(_pcb) - RT_OFFSETOF(VGASTATE, IVBVACallbacks)) )
    685 
    686717int vboxVBVASaveStateExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM);
    687718int vboxVBVALoadStateExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t u32Version);
     
    693724# ifdef VBOX_WITH_VDMA
    694725typedef struct VBOXVDMAHOST *PVBOXVDMAHOST;
    695 int vboxVDMAConstruct(PVGASTATE pVGAState, uint32_t cPipeElements);
     726int vboxVDMAConstruct(PVGASTATE pThis, PVGASTATECC pThisCC, uint32_t cPipeElements);
    696727void vboxVDMADestruct(PVBOXVDMAHOST pVdma);
    697728void vboxVDMAReset(PVBOXVDMAHOST pVdma);
     
    708739
    709740# ifdef VBOX_WITH_VMSVGA
    710 int vgaR3RegisterVRAMHandler(PVGASTATE pVGAState, uint64_t cbFrameBuffer);
    711 int vgaR3UnregisterVRAMHandler(PVGASTATE pVGAState);
    712 int vgaR3UpdateDisplay(PVGASTATE pVGAState, unsigned xStart, unsigned yStart, unsigned width, unsigned height);
     741int vgaR3UnregisterVRAMHandler(PPDMDEVINS pDevIns, PVGASTATE pThis);
     742int vgaR3RegisterVRAMHandler(PPDMDEVINS pDevIns, PVGASTATE pThis, uint64_t cbFrameBuffer);
     743int vgaR3UpdateDisplay(PVGASTATE pThis, unsigned xStart, unsigned yStart, unsigned width, unsigned height);
    713744# endif
    714745
  • trunk/src/VBox/Devices/Graphics/DevVGATmpl.h

    r76553 r82109  
    181181 * 4 color mode
    182182 */
    183 static void RT_CONCAT(vga_draw_line2_, DEPTH)(VGAState *s1, uint8_t *d,
     183static void RT_CONCAT(vga_draw_line2_, DEPTH)(VGAState *s1, PVGASTATER3 pThisCC, uint8_t *d,
    184184                                              const uint8_t *s, int width)
    185185{
    186186    uint32_t plane_mask, *palette, data, v, src_inc, dwb_mode;
    187187    int x;
     188    RT_NOREF(pThisCC);
    188189
    189190    palette = s1->last_palette;
     
    225226 * 4 color mode, dup2 horizontal
    226227 */
    227 static void RT_CONCAT(vga_draw_line2d2_, DEPTH)(VGAState *s1, uint8_t *d,
     228static void RT_CONCAT(vga_draw_line2d2_, DEPTH)(VGAState *s1, PVGASTATER3 pThisCC, uint8_t *d,
    228229                                                const uint8_t *s, int width)
    229230{
    230231    uint32_t plane_mask, *palette, data, v, src_inc, dwb_mode;
    231232    int x;
     233    RT_NOREF(pThisCC);
    232234
    233235    palette = s1->last_palette;
     
    260262 * 16 color mode
    261263 */
    262 static void RT_CONCAT(vga_draw_line4_, DEPTH)(VGAState *s1, uint8_t *d,
     264static void RT_CONCAT(vga_draw_line4_, DEPTH)(VGAState *s1, PVGASTATER3 pThisCC, uint8_t *d,
    263265                                              const uint8_t *s, int width)
    264266{
    265267    uint32_t plane_mask, data, v, *palette, vram_ofs;
    266268    int x;
    267 
    268     vram_ofs = s - s1->vram_ptrR3;
     269    RT_NOREF(pThisCC);
     270
     271    vram_ofs = s - pThisCC->pbVRam;
    269272    palette = s1->last_palette;
    270273    plane_mask = mask16[s1->ar[0x12] & 0xf];
    271274    width >>= 3;
    272275    for(x = 0; x < width; x++) {
    273         s = s1->vram_ptrR3 + (vram_ofs & s1->vga_addr_mask);
     276        s = pThisCC->pbVRam + (vram_ofs & s1->vga_addr_mask);
    274277        data = ((uint32_t *)s)[0];
    275278        data &= plane_mask;
     
    294297 * 16 color mode, dup2 horizontal
    295298 */
    296 static void RT_CONCAT(vga_draw_line4d2_, DEPTH)(VGAState *s1, uint8_t *d,
     299static void RT_CONCAT(vga_draw_line4d2_, DEPTH)(VGAState *s1, PVGASTATER3 pThisCC, uint8_t *d,
    297300                                                const uint8_t *s, int width)
    298301{
    299302    uint32_t plane_mask, data, v, *palette;
    300303    int x;
     304    RT_NOREF(pThisCC);
    301305
    302306    palette = s1->last_palette;
     
    328332 * XXX: add plane_mask support (never used in standard VGA modes)
    329333 */
    330 static void RT_CONCAT(vga_draw_line8d2_, DEPTH)(VGAState *s1, uint8_t *d,
     334static void RT_CONCAT(vga_draw_line8d2_, DEPTH)(VGAState *s1, PVGASTATER3 pThisCC, uint8_t *d,
    331335                                                const uint8_t *s, int width)
    332336{
    333337    uint32_t *palette;
    334338    int x;
     339    RT_NOREF(pThisCC);
    335340
    336341    palette = s1->last_palette;
     
    351356 * XXX: add plane_mask support (never used in standard VGA modes)
    352357 */
    353 static void RT_CONCAT(vga_draw_line8_, DEPTH)(VGAState *s1, uint8_t *d,
     358static void RT_CONCAT(vga_draw_line8_, DEPTH)(VGAState *s1, PVGASTATER3 pThisCC, uint8_t *d,
    354359                                              const uint8_t *s, int width)
    355360{
    356361    uint32_t *palette;
    357362    int x;
     363    RT_NOREF(pThisCC);
    358364
    359365    palette = s1->last_palette;
     
    381387 * 15 bit color
    382388 */
    383 static void RT_CONCAT(vga_draw_line15_, DEPTH)(VGAState *s1, uint8_t *d,
     389static void RT_CONCAT(vga_draw_line15_, DEPTH)(VGAState *s1, PVGASTATER3 pThisCC, uint8_t *d,
    384390                                               const uint8_t *s, int width)
    385391{
     392    RT_NOREF(s1, pThisCC);
    386393#if DEPTH == 15 && defined(WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN)
    387394    memcpy(d, s, width * 2);
     
    401408    } while (--w != 0);
    402409#endif
    403     NOREF(s1);
    404410}
    405411
     
    407413 * 16 bit color
    408414 */
    409 static void RT_CONCAT(vga_draw_line16_, DEPTH)(VGAState *s1, uint8_t *d,
     415static void RT_CONCAT(vga_draw_line16_, DEPTH)(VGAState *s1, PVGASTATER3 pThisCC, uint8_t *d,
    410416                                               const uint8_t *s, int width)
    411417{
     418    RT_NOREF(s1, pThisCC);
    412419#if DEPTH == 16 && defined(WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN)
    413420    memcpy(d, s, width * 2);
     
    427434    } while (--w != 0);
    428435#endif
    429     NOREF(s1);
    430436}
    431437
     
    433439 * 24 bit color
    434440 */
    435 static void RT_CONCAT(vga_draw_line24_, DEPTH)(VGAState *s1, uint8_t *d,
     441static void RT_CONCAT(vga_draw_line24_, DEPTH)(VGAState *s1, PVGASTATER3 pThisCC, uint8_t *d,
    436442                                               const uint8_t *s, int width)
    437443{
    438444    int w;
    439445    uint32_t r, g, b;
    440     NOREF(s1);
     446    RT_NOREF(s1, pThisCC);
    441447
    442448    w = width;
     
    460466 * 32 bit color
    461467 */
    462 static void RT_CONCAT(vga_draw_line32_, DEPTH)(VGAState *s1, uint8_t *d,
     468static void RT_CONCAT(vga_draw_line32_, DEPTH)(VGAState *s1, PVGASTATER3 pThisCC, uint8_t *d,
    463469                                               const uint8_t *s, int width)
    464470{
     471    RT_NOREF(s1, pThisCC);
    465472#if DEPTH == 32 && defined(WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN)
    466473    memcpy(d, s, width * 4);
     
    485492    } while (--w != 0);
    486493#endif
    487     NOREF(s1);
    488494}
    489495
  • trunk/src/VBox/Devices/Graphics/DevVGA_VBVA.cpp

    r82088 r82109  
    383383}
    384384
    385 static int vbvaFlushProcess(unsigned uScreenId, PVGASTATE pVGAState, VBVADATA *pVBVAData)
     385static int vbvaFlushProcess(PVGASTATECC pThisCC, VBVADATA *pVBVAData, unsigned uScreenId)
    386386{
    387387    LOGVBVABUFFER(("uScreenId %d, indexRecordFirst = %d, indexRecordFree = %d, off32Data = %d, off32Free = %d\n",
    388388                   uScreenId, pVBVAData->indexRecordFirst, pVBVAData->guest.pVBVA->indexRecordFree,
    389389                   pVBVAData->off32Data, pVBVAData->guest.pVBVA->off32Free));
    390     struct {
     390    struct
     391    {
    391392        /* The rectangle that includes all dirty rectangles. */
    392393        int32_t xLeft;
     
    430431            if (!fUpdate)
    431432            {
    432                 pVGAState->pDrv->pfnVBVAUpdateBegin(pVGAState->pDrv, uScreenId);
     433                pThisCC->pDrv->pfnVBVAUpdateBegin(pThisCC->pDrv, uScreenId);
    433434                fUpdate = true;
    434435            }
    435436
    436437            /* Updates the rectangle and sends the command to the VRDP server. */
    437             pVGAState->pDrv->pfnVBVAUpdateProcess(pVGAState->pDrv, uScreenId, pHdr, cbCmd);
     438            pThisCC->pDrv->pfnVBVAUpdateProcess(pThisCC->pDrv, uScreenId, pHdr, cbCmd);
    438439
    439440            int32_t xRight  = pHdr->x + pHdr->w;
     
    492493                     dirtyRect.yTop, dirtyRect.xRight - dirtyRect.xLeft,
    493494                     dirtyRect.yBottom - dirtyRect.yTop));
    494             pVGAState->pDrv->pfnVBVAUpdateEnd(pVGAState->pDrv, uScreenId, dirtyRect.xLeft, dirtyRect.yTop,
     495            pThisCC->pDrv->pfnVBVAUpdateEnd(pThisCC->pDrv, uScreenId, dirtyRect.xLeft, dirtyRect.yTop,
    495496                                              dirtyRect.xRight - dirtyRect.xLeft, dirtyRect.yBottom - dirtyRect.yTop);
    496497        }
    497498        else
    498499        {
    499             pVGAState->pDrv->pfnVBVAUpdateEnd(pVGAState->pDrv, uScreenId, 0, 0, 0, 0);
     500            pThisCC->pDrv->pfnVBVAUpdateEnd(pThisCC->pDrv, uScreenId, 0, 0, 0, 0);
    500501        }
    501502    }
     
    504505}
    505506
    506 static int vbvaFlush(PVGASTATE pVGAState, VBVACONTEXT *pCtx)
     507static int vbvaFlush(PVGASTATE pThis, PVGASTATECC pThisCC, VBVACONTEXT *pCtx)
    507508{
    508509    int rc = VINF_SUCCESS;
     
    514515        if (pVBVAData->guest.pVBVA)
    515516        {
    516             rc = vbvaFlushProcess(uScreenId, pVGAState, pVBVAData);
     517            rc = vbvaFlushProcess(pThisCC, pVBVAData, uScreenId);
    517518            if (RT_FAILURE(rc))
    518519                break;
     
    524525        /* Turn off VBVA processing. */
    525526        LogRel(("VBVA: Disabling (%Rrc)\n", rc));
    526         pVGAState->fGuestCaps = 0;
    527         pVGAState->pDrv->pfnVBVAGuestCapabilityUpdate(pVGAState->pDrv, pVGAState->fGuestCaps);
     527        pThis->fGuestCaps = 0;
     528        pThisCC->pDrv->pfnVBVAGuestCapabilityUpdate(pThisCC->pDrv, pThis->fGuestCaps);
    528529        for (uScreenId = 0; uScreenId < pCtx->cViews; uScreenId++)
    529530        {
     
    532533            {
    533534                vbvaDataCleanup(pVBVAData);
    534                 pVGAState->pDrv->pfnVBVADisable(pVGAState->pDrv, uScreenId);
     535                pThisCC->pDrv->pfnVBVADisable(pThisCC->pDrv, uScreenId);
    535536            }
    536537        }
     
    540541}
    541542
    542 static int vbvaResize(PVGASTATE pVGAState, VBVAVIEW *pView, const VBVAINFOSCREEN *pNewScreen, bool fResetInputMapping)
     543static int vbvaResize(PVGASTATECC pThisCC, VBVAVIEW *pView, const VBVAINFOSCREEN *pNewScreen, bool fResetInputMapping)
    543544{
    544545    /* Callers ensure that pNewScreen contains valid data. */
     
    547548    pView->screen = *pNewScreen;
    548549
    549     uint8_t *pu8VRAM = pVGAState->vram_ptrR3 + pView->view.u32ViewOffset;
    550     return pVGAState->pDrv->pfnVBVAResize (pVGAState->pDrv, &pView->view, &pView->screen, pu8VRAM, fResetInputMapping);
    551 }
    552 
    553 static int vbvaEnable(unsigned uScreenId, PVGASTATE pVGAState, VBVACONTEXT *pCtx,
     550    uint8_t *pbVRam = pThisCC->pbVRam + pView->view.u32ViewOffset;
     551    return pThisCC->pDrv->pfnVBVAResize(pThisCC->pDrv, &pView->view, &pView->screen, pbVRam, fResetInputMapping);
     552}
     553
     554static int vbvaEnable(PVGASTATE pThis, PVGASTATECC pThisCC, VBVACONTEXT *pCtx, unsigned uScreenId,
    554555                      VBVABUFFER RT_UNTRUSTED_VOLATILE_GUEST *pVBVA, uint32_t u32Offset, bool fRestored)
    555556{
     
    563564    uint32_t const cbVBVABuffer = RT_UOFFSETOF(VBVABUFFER, au8Data) + VbgaSafe.cbData;
    564565    ASSERT_GUEST_RETURN(   VbgaSafe.cbData <= UINT32_MAX - RT_UOFFSETOF(VBVABUFFER, au8Data)
    565                         && cbVBVABuffer <= pVGAState->vram_size
    566                         && u32Offset <= pVGAState->vram_size - cbVBVABuffer,
     566                        && cbVBVABuffer <= pThis->vram_size
     567                        && u32Offset <= pThis->vram_size - cbVBVABuffer,
    567568                        VERR_INVALID_PARAMETER);
    568569    if (!fRestored)
     
    582583     */
    583584    int rc;
    584     if (pVGAState->pDrv->pfnVBVAEnable)
     585    if (pThisCC->pDrv->pfnVBVAEnable)
    585586    {
    586587        pVBVA->hostFlags.u32HostEvents      = 0;
    587588        pVBVA->hostFlags.u32SupportedOrders = 0;
    588         rc = pVGAState->pDrv->pfnVBVAEnable(pVGAState->pDrv, uScreenId, &pVBVA->hostFlags);
     589        rc = pThisCC->pDrv->pfnVBVAEnable(pThisCC->pDrv, uScreenId, &pVBVA->hostFlags);
    589590        if (RT_SUCCESS(rc))
    590591        {
     
    623624}
    624625
    625 static int vbvaDisable (unsigned uScreenId, PVGASTATE pVGAState, VBVACONTEXT *pCtx)
     626static int vbvaDisable(PVGASTATE pThis, PVGASTATECC pThisCC, VBVACONTEXT *pCtx, unsigned idScreen)
    626627{
    627628    /* Process any pending orders and empty the VBVA ring buffer. */
    628     vbvaFlush (pVGAState, pCtx);
    629 
    630     VBVADATA *pVBVAData = &pCtx->aViews[uScreenId].vbva;
     629    vbvaFlush(pThis, pThisCC, pCtx);
     630
     631    AssertReturn(idScreen < RT_ELEMENTS(pCtx->aViews), VERR_OUT_OF_RANGE);
     632    VBVADATA *pVBVAData = &pCtx->aViews[idScreen].vbva;
    631633    vbvaDataCleanup(pVBVAData);
    632634
    633     if (uScreenId == 0)
    634     {
    635         pVGAState->fGuestCaps = 0;
    636         pVGAState->pDrv->pfnVBVAGuestCapabilityUpdate(pVGAState->pDrv, pVGAState->fGuestCaps);
    637     }
    638     pVGAState->pDrv->pfnVBVADisable(pVGAState->pDrv, uScreenId);
     635    if (idScreen == 0)
     636    {
     637        pThis->fGuestCaps = 0;
     638        pThisCC->pDrv->pfnVBVAGuestCapabilityUpdate(pThisCC->pDrv, pThis->fGuestCaps);
     639    }
     640    pThisCC->pDrv->pfnVBVADisable(pThisCC->pDrv, idScreen);
    639641    return VINF_SUCCESS;
    640642}
    641643
    642 bool VBVAIsEnabled(PVGASTATE pVGAState)
    643 {
    644     PHGSMIINSTANCE pHGSMI = pVGAState->pHGSMI;
     644#ifdef UNUSED_FUNCTION
     645bool VBVAIsEnabled(PVGASTATECC pThisCC)
     646{
     647    PHGSMIINSTANCE pHGSMI = pThisCC->pHGSMI;
    645648    if (pHGSMI)
    646649    {
     
    658661    return false;
    659662}
     663#endif
    660664
    661665#ifdef DEBUG_sunlover
     
    677681#endif
    678682
    679 static int vbvaUpdateMousePointerShape(PVGASTATE pVGAState, VBVAMOUSESHAPEINFO *pMouseShapeInfo, bool fShape)
    680 {
    681     LogFlowFunc(("pVGAState %p, pMouseShapeInfo %p, fShape %d\n",
    682                   pVGAState, pMouseShapeInfo, fShape));
     683static int vbvaUpdateMousePointerShape(PVGASTATECC pThisCC, VBVAMOUSESHAPEINFO *pMouseShapeInfo, bool fShape)
     684{
     685    LogFlowFunc(("pThisCC %p, pMouseShapeInfo %p, fShape %d\n", pThisCC, pMouseShapeInfo, fShape));
    683686#ifdef DEBUG_sunlover
    684687    dumpMouseShapeInfo(pMouseShapeInfo);
    685688#endif
    686689
    687     if (pVGAState->pDrv->pfnVBVAMousePointerShape == NULL)
    688     {
     690    if (pThisCC->pDrv->pfnVBVAMousePointerShape == NULL)
    689691        return VERR_NOT_SUPPORTED;
    690     }
    691692
    692693    int rc;
    693694    if (fShape && pMouseShapeInfo->pu8Shape != NULL)
    694     {
    695         rc = pVGAState->pDrv->pfnVBVAMousePointerShape (pVGAState->pDrv,
    696                                                         pMouseShapeInfo->fVisible,
    697                                                         pMouseShapeInfo->fAlpha,
    698                                                         pMouseShapeInfo->u32HotX,
    699                                                         pMouseShapeInfo->u32HotY,
    700                                                         pMouseShapeInfo->u32Width,
    701                                                         pMouseShapeInfo->u32Height,
    702                                                         pMouseShapeInfo->pu8Shape);
    703     }
     695        rc = pThisCC->pDrv->pfnVBVAMousePointerShape(pThisCC->pDrv,
     696                                                     pMouseShapeInfo->fVisible,
     697                                                     pMouseShapeInfo->fAlpha,
     698                                                     pMouseShapeInfo->u32HotX,
     699                                                     pMouseShapeInfo->u32HotY,
     700                                                     pMouseShapeInfo->u32Width,
     701                                                     pMouseShapeInfo->u32Height,
     702                                                     pMouseShapeInfo->pu8Shape);
    704703    else
    705     {
    706         rc = pVGAState->pDrv->pfnVBVAMousePointerShape (pVGAState->pDrv,
    707                                                         pMouseShapeInfo->fVisible,
    708                                                         false,
    709                                                         0, 0,
    710                                                         0, 0,
    711                                                         NULL);
    712     }
    713 
     704        rc = pThisCC->pDrv->pfnVBVAMousePointerShape(pThisCC->pDrv,
     705                                                     pMouseShapeInfo->fVisible,
     706                                                     false,
     707                                                     0, 0,
     708                                                     0, 0,
     709                                                     NULL);
    714710    return rc;
    715711}
    716712
    717 static int vbvaMousePointerShape(PVGASTATE pVGAState, VBVACONTEXT *pCtx,
     713static int vbvaMousePointerShape(PVGASTATECC pThisCC, VBVACONTEXT *pCtx,
    718714                                 const VBVAMOUSEPOINTERSHAPE RT_UNTRUSTED_VOLATILE_GUEST *pShape, HGSMISIZE cbShape)
    719715{
     
    790786    }
    791787
    792     return vbvaUpdateMousePointerShape(pVGAState, &pCtx->mouseShapeInfo, fShape);
     788    return vbvaUpdateMousePointerShape(pThisCC, &pCtx->mouseShapeInfo, fShape);
    793789}
    794790
     
    855851
    856852#ifdef VBOX_WITH_VIDEOHWACCEL
     853
    857854static void vbvaVHWAHHCommandReinit(VBOXVHWACMD* pHdr, VBOXVHWACMD_TYPE enmCmd, int32_t iDisplay)
    858855{
     
    887884}
    888885
    889 static void vbvaVHWACommandComplete(PVGASTATE pVGAState, VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *pCommand, bool fAsyncCommand)
     886static void vbvaVHWACommandComplete(PVGASTATECC pThisCC, VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *pCommand, bool fAsyncCommand)
    890887{
    891888    if (fAsyncCommand)
    892889    {
    893890        Assert(pCommand->Flags & VBOXVHWACMD_FLAG_HG_ASYNCH);
    894         vbvaR3VHWACommandCompleteAsync(&pVGAState->IVBVACallbacks, pCommand);
     891        vbvaR3VHWACommandCompleteAsync(&pThisCC->IVBVACallbacks, pCommand);
    895892    }
    896893    else
     
    902899}
    903900
    904 static void vbvaVHWACommandCompleteAllPending(PVGASTATE pVGAState, int rc)
    905 {
    906     if (!ASMAtomicUoReadU32(&pVGAState->pendingVhwaCommands.cPending))
     901static void vbvaVHWACommandCompleteAllPending(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC, int rc)
     902{
     903    if (!ASMAtomicUoReadU32(&pThis->pendingVhwaCommands.cPending))
    907904        return;
    908905
    909     PDMDevHlpCritSectEnter(pVGAState->CTX_SUFF(pDevIns), &pVGAState->CritSect, VERR_SEM_BUSY);
     906    PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_SEM_BUSY);
    910907
    911908    VBOX_VHWA_PENDINGCMD *pIter, *pNext;
    912     RTListForEachSafe(&pVGAState->pendingVhwaCommands.PendingList, pIter, pNext, VBOX_VHWA_PENDINGCMD, Node)
     909    RTListForEachSafe(&pThis->pendingVhwaCommands.PendingList, pIter, pNext, VBOX_VHWA_PENDINGCMD, Node)
    913910    {
    914911        pIter->pCommand->rc = rc;
    915         vbvaVHWACommandComplete(pVGAState, pIter->pCommand, true);
     912        vbvaVHWACommandComplete(pThisCC, pIter->pCommand, true);
    916913
    917914        /* the command is submitted/processed, remove from the pend list */
    918915        RTListNodeRemove(&pIter->Node);
    919         ASMAtomicDecU32(&pVGAState->pendingVhwaCommands.cPending);
     916        ASMAtomicDecU32(&pThis->pendingVhwaCommands.cPending);
    920917        RTMemFree(pIter);
    921918    }
    922919
    923     PDMDevHlpCritSectLeave(pVGAState->CTX_SUFF(pDevIns), &pVGAState->CritSect);
    924 }
    925 
    926 static void vbvaVHWACommandClearAllPending(PVGASTATE pVGAState)
    927 {
    928     if (!ASMAtomicUoReadU32(&pVGAState->pendingVhwaCommands.cPending))
     920    PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
     921}
     922
     923static void vbvaVHWACommandClearAllPending(PPDMDEVINS pDevIns, PVGASTATE pThis)
     924{
     925    if (!ASMAtomicUoReadU32(&pThis->pendingVhwaCommands.cPending))
    929926        return;
    930927
    931     PDMDevHlpCritSectEnter(pVGAState->CTX_SUFF(pDevIns), &pVGAState->CritSect, VERR_SEM_BUSY);
     928    PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_SEM_BUSY);
    932929
    933930    VBOX_VHWA_PENDINGCMD *pIter, *pNext;
    934     RTListForEachSafe(&pVGAState->pendingVhwaCommands.PendingList, pIter, pNext, VBOX_VHWA_PENDINGCMD, Node)
     931    RTListForEachSafe(&pThis->pendingVhwaCommands.PendingList, pIter, pNext, VBOX_VHWA_PENDINGCMD, Node)
    935932    {
    936933        RTListNodeRemove(&pIter->Node);
    937         ASMAtomicDecU32(&pVGAState->pendingVhwaCommands.cPending);
     934        ASMAtomicDecU32(&pThis->pendingVhwaCommands.cPending);
    938935        RTMemFree(pIter);
    939936    }
    940937
    941     PDMDevHlpCritSectLeave(pVGAState->CTX_SUFF(pDevIns), &pVGAState->CritSect);
    942 }
    943 
    944 static void vbvaVHWACommandPend(PVGASTATE pVGAState, VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *pCommand)
     938    PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
     939}
     940
     941static void vbvaVHWACommandPend(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC,
     942                                VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *pCommand)
    945943{
    946944    int rc = VERR_BUFFER_OVERFLOW;
    947945
    948     if (ASMAtomicUoReadU32(&pVGAState->pendingVhwaCommands.cPending) < VBOX_VHWA_MAX_PENDING_COMMANDS)
     946    if (ASMAtomicUoReadU32(&pThis->pendingVhwaCommands.cPending) < VBOX_VHWA_MAX_PENDING_COMMANDS)
    949947    {
    950948        VBOX_VHWA_PENDINGCMD *pPend = (VBOX_VHWA_PENDINGCMD *)RTMemAlloc(sizeof(*pPend));
     
    953951            pCommand->Flags |= VBOXVHWACMD_FLAG_HG_ASYNCH;
    954952            pPend->pCommand = pCommand;
    955             PDMDevHlpCritSectEnter(pVGAState->CTX_SUFF(pDevIns), &pVGAState->CritSect, VERR_SEM_BUSY);
    956             if (ASMAtomicUoReadU32(&pVGAState->pendingVhwaCommands.cPending) < VBOX_VHWA_MAX_PENDING_COMMANDS)
    957             {
    958                 RTListAppend(&pVGAState->pendingVhwaCommands.PendingList, &pPend->Node);
    959                 ASMAtomicIncU32(&pVGAState->pendingVhwaCommands.cPending);
    960                 PDMDevHlpCritSectLeave(pVGAState->CTX_SUFF(pDevIns), &pVGAState->CritSect);
     953            PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_SEM_BUSY);
     954            if (ASMAtomicUoReadU32(&pThis->pendingVhwaCommands.cPending) < VBOX_VHWA_MAX_PENDING_COMMANDS)
     955            {
     956                RTListAppend(&pThis->pendingVhwaCommands.PendingList, &pPend->Node);
     957                ASMAtomicIncU32(&pThis->pendingVhwaCommands.cPending);
     958                PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
    961959                return;
    962960            }
    963             PDMDevHlpCritSectLeave(pVGAState->CTX_SUFF(pDevIns), &pVGAState->CritSect);
     961            PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
    964962            LogRel(("VBVA: Pending command count has reached its threshold.. completing them all.."));
    965963            RTMemFree(pPend);
     
    971969        LogRel(("VBVA: Pending command count has reached its threshold, completing them all.."));
    972970
    973     vbvaVHWACommandCompleteAllPending(pVGAState, rc);
     971    vbvaVHWACommandCompleteAllPending(pDevIns, pThis, pThisCC, rc);
    974972
    975973    pCommand->rc = rc;
    976974
    977     vbvaVHWACommandComplete(pVGAState, pCommand, false);
     975    vbvaVHWACommandComplete(pThisCC, pCommand, false);
    978976}
    979977
     
    993991}
    994992
    995 static int vbvaVHWACommandSavePending(PCPDMDEVHLPR3 pHlp, PVGASTATE pVGAState, PSSMHANDLE pSSM)
    996 {
    997     int rc = pHlp->pfnSSMPutU32(pSSM, pVGAState->pendingVhwaCommands.cPending);
     993static int vbvaVHWACommandSavePending(PCPDMDEVHLPR3 pHlp, PVGASTATE pThis, PVGASTATECC pThisCC, PSSMHANDLE pSSM)
     994{
     995    int rc = pHlp->pfnSSMPutU32(pSSM, pThis->pendingVhwaCommands.cPending);
    998996    AssertRCReturn(rc, rc);
    999997
    1000998    VBOX_VHWA_PENDINGCMD *pIter;
    1001     RTListForEach(&pVGAState->pendingVhwaCommands.PendingList, pIter, VBOX_VHWA_PENDINGCMD, Node)
    1002     {
    1003         AssertContinue((uintptr_t)pIter->pCommand - (uintptr_t)pVGAState->vram_ptrR3 < pVGAState->vram_size);
    1004         rc = pHlp->pfnSSMPutU32(pSSM, (uint32_t)(((uint8_t *)pIter->pCommand) - ((uint8_t *)pVGAState->vram_ptrR3)));
     999    RTListForEach(&pThis->pendingVhwaCommands.PendingList, pIter, VBOX_VHWA_PENDINGCMD, Node)
     1000    {
     1001        AssertContinue((uintptr_t)pIter->pCommand - (uintptr_t)pThisCC->pbVRam < pThis->vram_size);
     1002        rc = pHlp->pfnSSMPutU32(pSSM, (uint32_t)(((uint8_t *)pIter->pCommand) - ((uint8_t *)pThisCC->pbVRam)));
    10051003        AssertRCReturn(rc, rc);
    10061004    }
     
    10081006}
    10091007
    1010 static int vbvaVHWACommandLoadPending(PCPDMDEVHLPR3 pHlp, PVGASTATE pVGAState, PSSMHANDLE pSSM, uint32_t u32Version)
     1008static int vbvaVHWACommandLoadPending(PPDMDEVINS pDevIns, PCPDMDEVHLPR3 pHlp, PVGASTATE pThis, PVGASTATECC pThisCC,
     1009                                      PSSMHANDLE pSSM, uint32_t u32Version)
    10111010{
    10121011    if (u32Version < VGA_SAVEDSTATE_VERSION_WITH_PENDVHWA)
     
    10221021        AssertRCReturn(rc, rc);
    10231022        VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *pCommand
    1024             = (VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *)((uint8_t volatile *)pVGAState->vram_ptrR3 + off32);
    1025         vbvaVHWACommandPend(pVGAState, pCommand);
     1023            = (VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *)((uint8_t volatile *)pThisCC->pbVRam + off32);
     1024        vbvaVHWACommandPend(pDevIns, pThis, pThisCC, pCommand);
    10261025    }
    10271026    return rc;
     
    10301029
    10311030/** Worker for vbvaVHWACommandSubmit. */
    1032 static bool vbvaVHWACommandSubmitInner(PVGASTATE pVGAState, VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *pCommand, bool *pfPending)
     1031static bool vbvaVHWACommandSubmitInner(PVGASTATE pThis, PVGASTATECC pThisCC,
     1032                                       VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *pCommand, bool *pfPending)
    10331033{
    10341034    *pfPending = false;
     
    10401040    RT_UNTRUSTED_NONVOLATILE_COPY_FENCE();
    10411041
    1042     bool fGuestCmd = (uintptr_t)pCommand - (uintptr_t)pVGAState->vram_ptrR3 < pVGAState->vram_size;
     1042    bool fGuestCmd = (uintptr_t)pCommand - (uintptr_t)pThisCC->pbVRam < pThis->vram_size;
    10431043    ASSERT_GUEST_LOGREL_MSG_STMT_RETURN(   !fGuestCmd
    10441044                                        || (   enmCmd != VBOXVHWACMD_TYPE_HH_CONSTRUCT
     
    10531053                                        pCommand->rc = VERR_INVALID_PARAMETER,
    10541054                                        true);
    1055     ASSERT_GUEST_STMT_RETURN(pVGAState->pDrv->pfnVHWACommandProcess, pCommand->rc = VERR_INVALID_STATE, true);
     1055    ASSERT_GUEST_STMT_RETURN(pThisCC->pDrv->pfnVHWACommandProcess, pCommand->rc = VERR_INVALID_STATE, true);
    10561056    RT_UNTRUSTED_VALIDATED_FENCE();
    10571057
     
    10601060     */
    10611061    Log(("VGA Command >>> %#p, %d\n", pCommand, enmCmd));
    1062     int rc = pVGAState->pDrv->pfnVHWACommandProcess(pVGAState->pDrv, enmCmd, fGuestCmd, pCommand);
     1062    int rc = pThisCC->pDrv->pfnVHWACommandProcess(pThisCC->pDrv, enmCmd, fGuestCmd, pCommand);
    10631063    if (rc == VINF_CALLBACK_RETURN)
    10641064    {
     
    10891089
    10901090
    1091 static bool vbvaVHWACommandSubmit(PVGASTATE pVGAState, VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *pCommand, bool fAsyncCommand)
     1091static bool vbvaVHWACommandSubmit(PVGASTATE pThis, PVGASTATECC pThisCC,
     1092                                  VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *pCommand, bool fAsyncCommand)
    10921093{
    10931094    bool fPending = false;
    1094     bool fRet = vbvaVHWACommandSubmitInner(pVGAState, pCommand, &fPending);
     1095    bool fRet = vbvaVHWACommandSubmitInner(pThis, pThisCC, pCommand, &fPending);
    10951096    if (!fPending)
    1096         vbvaVHWACommandComplete(pVGAState, pCommand, fAsyncCommand);
     1097        vbvaVHWACommandComplete(pThisCC, pCommand, fAsyncCommand);
    10971098    return fRet;
    10981099}
     
    11021103 * @returns false if commands are pending, otherwise true.
    11031104 */
    1104 static bool vbvaVHWACheckPendingCommands(PVGASTATE pVGAState)
    1105 {
    1106     if (!ASMAtomicUoReadU32(&pVGAState->pendingVhwaCommands.cPending))
     1105static bool vbvaVHWACheckPendingCommands(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC)
     1106{
     1107    if (!ASMAtomicUoReadU32(&pThis->pendingVhwaCommands.cPending))
    11071108        return true;
    11081109
    1109     PDMDevHlpCritSectEnter(pVGAState->CTX_SUFF(pDevIns), &pVGAState->CritSect, VERR_SEM_BUSY);
     1110    PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_SEM_BUSY);
    11101111
    11111112    VBOX_VHWA_PENDINGCMD *pIter, *pNext;
    1112     RTListForEachSafe(&pVGAState->pendingVhwaCommands.PendingList, pIter, pNext, VBOX_VHWA_PENDINGCMD, Node)
    1113     {
    1114         if (!vbvaVHWACommandSubmit(pVGAState, pIter->pCommand, true))
    1115         {
    1116             PDMDevHlpCritSectLeave(pVGAState->CTX_SUFF(pDevIns), &pVGAState->CritSect);
     1113    RTListForEachSafe(&pThis->pendingVhwaCommands.PendingList, pIter, pNext, VBOX_VHWA_PENDINGCMD, Node)
     1114    {
     1115        if (!vbvaVHWACommandSubmit(pThis, pThisCC, pIter->pCommand, true))
     1116        {
     1117            PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
    11171118            return false; /* the command should be still pending */
    11181119        }
     
    11201121        /* the command is submitted/processed, remove from the pend list */
    11211122        RTListNodeRemove(&pIter->Node);
    1122         ASMAtomicDecU32(&pVGAState->pendingVhwaCommands.cPending);
     1123        ASMAtomicDecU32(&pThis->pendingVhwaCommands.cPending);
    11231124        RTMemFree(pIter);
    11241125    }
    11251126
    1126     PDMDevHlpCritSectLeave(pVGAState->CTX_SUFF(pDevIns), &pVGAState->CritSect);
     1127    PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
    11271128
    11281129    return true;
    11291130}
    11301131
    1131 void vbvaTimerCb(PVGASTATE pVGAState)
    1132 {
    1133     vbvaVHWACheckPendingCommands(pVGAState);
    1134 }
    1135 
    1136 static void vbvaVHWAHandleCommand(PVGASTATE pVGAState, VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *pCmd)
    1137 {
    1138     if (vbvaVHWACheckPendingCommands(pVGAState))
    1139     {
    1140         if (vbvaVHWACommandSubmit(pVGAState, pCmd, false))
     1132void vbvaTimerCb(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC)
     1133{
     1134    vbvaVHWACheckPendingCommands(pDevIns, pThis, pThisCC);
     1135}
     1136
     1137static void vbvaVHWAHandleCommand(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC,
     1138                                  VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *pCmd)
     1139{
     1140    if (vbvaVHWACheckPendingCommands(pDevIns, pThis, pThisCC))
     1141    {
     1142        if (vbvaVHWACommandSubmit(pThis, pThisCC, pCmd, false))
    11411143            return;
    11421144    }
    11431145
    1144     vbvaVHWACommandPend(pVGAState, pCmd);
     1146    vbvaVHWACommandPend(pDevIns, pThis, pThisCC, pCmd);
    11451147}
    11461148
     
    11501152}
    11511153
    1152 static int vbvaVHWAHHCommandPost(PVGASTATE pVGAState, VBOXVHWACMD *pCmd)
     1154static int vbvaVHWAHHCommandPost(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC, VBOXVHWACMD *pCmd)
    11531155{
    11541156    RTSEMEVENT hComplEvent;
     
    11611163
    11621164        VBOXVHWA_HH_CALLBACK_SET(pCmd, vbvaVHWAHHCommandSetEventCallback, (void *)hComplEvent);
    1163         vbvaVHWAHandleCommand(pVGAState, pCmd);
     1165        vbvaVHWAHandleCommand(pDevIns, pThis, pThisCC, pCmd);
    11641166
    11651167        if ((ASMAtomicReadU32((volatile uint32_t *)&pCmd->Flags) & VBOXVHWACMD_FLAG_HG_ASYNCH) != 0)
     
    11761178}
    11771179
    1178 int vbvaVHWAConstruct(PVGASTATE pVGAState)
    1179 {
    1180     pVGAState->pendingVhwaCommands.cPending = 0;
    1181     RTListInit(&pVGAState->pendingVhwaCommands.PendingList);
     1180int vbvaVHWAConstruct(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC)
     1181{
     1182    pThis->pendingVhwaCommands.cPending = 0;
     1183    RTListInit(&pThis->pendingVhwaCommands.PendingList);
    11821184
    11831185    VBOXVHWACMD *pCmd = vbvaVHWAHHCommandCreate(VBOXVHWACMD_TYPE_HH_CONSTRUCT, 0, sizeof(VBOXVHWACMD_HH_CONSTRUCT));
     
    11891191        VBOXVHWACMD_HH_CONSTRUCT *pBody = VBOXVHWACMD_BODY_HOST_HEAP(pCmd, VBOXVHWACMD_HH_CONSTRUCT);
    11901192
    1191         do
     1193        for (;;)
    11921194        {
    11931195            memset(pBody, 0, sizeof(VBOXVHWACMD_HH_CONSTRUCT));
    11941196
    1195             PPDMDEVINS pDevIns = pVGAState->pDevInsR3;
    11961197            PVM pVM = PDMDevHlpGetVM(pDevIns);
    11971198
    11981199            pBody->pVM = pVM;
    1199             pBody->pvVRAM = pVGAState->vram_ptrR3;
    1200             pBody->cbVRAM = pVGAState->vram_size;
    1201 
    1202             rc = vbvaVHWAHHCommandPost(pVGAState, pCmd);
     1200            pBody->pvVRAM = pThisCC->pbVRam;
     1201            pBody->cbVRAM = pThis->vram_size;
     1202
     1203            rc = vbvaVHWAHHCommandPost(pDevIns, pThis, pThisCC, pCmd);
    12031204            ASMCompilerBarrier();
    12041205
     
    12101211                if(rc == VERR_NOT_IMPLEMENTED)
    12111212                {
    1212                     /** @todo set some flag in pVGAState indicating VHWA is not supported */
     1213                    /** @todo set some flag in pThis indicating VHWA is not supported */
    12131214                    /* VERR_NOT_IMPLEMENTED is not a failure, we just do not support it */
    12141215                    rc = VINF_SUCCESS;
     
    12221223
    12231224            ++iDisplay;
    1224             if (iDisplay >= pVGAState->cMonitors)
     1225            if (iDisplay >= pThis->cMonitors)
    12251226                break;
    12261227            vbvaVHWAHHCommandReinit(pCmd, VBOXVHWACMD_TYPE_HH_CONSTRUCT, (int32_t)iDisplay);
    1227         } while (true);
     1228        }
    12281229
    12291230        vbvaVHWAHHCommandRelease(pCmd);
     
    12341235}
    12351236
    1236 int vbvaVHWAReset(PVGASTATE pVGAState)
    1237 {
    1238     vbvaVHWACommandClearAllPending(pVGAState);
     1237static int vbvaVHWAReset(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC)
     1238{
     1239    vbvaVHWACommandClearAllPending(pDevIns, pThis);
    12391240
    12401241    /* ensure we have all pending cmds processed and h->g cmds disabled */
     
    12481249        do
    12491250        {
    1250             rc = vbvaVHWAHHCommandPost(pVGAState, pCmd);
     1251            rc = vbvaVHWAHHCommandPost(pDevIns, pThis, pThisCC, pCmd);
    12511252            AssertRC(rc);
    12521253            if(RT_SUCCESS(rc))
     
    12621263
    12631264            ++iDisplay;
    1264             if (iDisplay >= pVGAState->cMonitors)
     1265            if (iDisplay >= pThis->cMonitors)
    12651266                break;
    12661267            vbvaVHWAHHCommandReinit(pCmd, VBOXVHWACMD_TYPE_HH_RESET, (int32_t)iDisplay);
     
    12751276}
    12761277
    1277 typedef DECLCALLBACK(bool) FNVBOXVHWAHHCMDPRECB(PVGASTATE pVGAState, VBOXVHWACMD *pCmd, uint32_t iDisplay, void *pvContext);
     1278typedef DECLCALLBACK(bool) FNVBOXVHWAHHCMDPRECB(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC, VBOXVHWACMD *pCmd,
     1279                                                uint32_t iDisplay, void *pvContext);
    12781280typedef FNVBOXVHWAHHCMDPRECB *PFNVBOXVHWAHHCMDPRECB;
    12791281
    1280 typedef DECLCALLBACK(bool) FNVBOXVHWAHHCMDPOSTCB(PVGASTATE pVGAState, VBOXVHWACMD *pCmd, uint32_t iDisplay, int rc, void *pvContext);
     1282typedef DECLCALLBACK(bool) FNVBOXVHWAHHCMDPOSTCB(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC, VBOXVHWACMD *pCmd,
     1283                                                 uint32_t iDisplay, int rc, void *pvContext);
    12811284typedef FNVBOXVHWAHHCMDPOSTCB *PFNVBOXVHWAHHCMDPOSTCB;
    12821285
    1283 int vbvaVHWAHHPost(PVGASTATE pVGAState, VBOXVHWACMD *pCmd, PFNVBOXVHWAHHCMDPRECB pfnPre, PFNVBOXVHWAHHCMDPOSTCB pfnPost, void *pvContext)
     1286static int vbvaVHWAHHPost(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC, VBOXVHWACMD *pCmd,
     1287                          PFNVBOXVHWAHHCMDPRECB pfnPre, PFNVBOXVHWAHHCMDPOSTCB pfnPost, void *pvContext)
    12841288{
    12851289    const VBOXVHWACMD_TYPE enmType = pCmd->enmCmd;
     
    12891293    do
    12901294    {
    1291         if (!pfnPre || pfnPre(pVGAState, pCmd, iDisplay, pvContext))
    1292         {
    1293             rc = vbvaVHWAHHCommandPost(pVGAState, pCmd);
     1295        if (!pfnPre || pfnPre(pDevIns, pThis, pThisCC, pCmd, iDisplay, pvContext))
     1296        {
     1297            rc = vbvaVHWAHHCommandPost(pDevIns, pThis, pThisCC, pCmd);
    12941298            AssertRC(rc);
    12951299            if (pfnPost)
    12961300            {
    1297                 if (!pfnPost(pVGAState, pCmd, iDisplay, rc, pvContext))
     1301                if (!pfnPost(pDevIns, pThis, pThisCC, pCmd, iDisplay, rc, pvContext))
    12981302                {
    12991303                    rc = VINF_SUCCESS;
     
    13171321
    13181322        ++iDisplay;
    1319         if (iDisplay >= pVGAState->cMonitors)
     1323        if (iDisplay >= pThis->cMonitors)
    13201324            break;
    13211325        vbvaVHWAHHCommandReinit(pCmd, enmType, (int32_t)iDisplay);
     
    13261330
    13271331/** @todo call this also on reset? */
    1328 int vbvaVHWAEnable (PVGASTATE pVGAState, bool bEnable)
     1332static int vbvaVHWAEnable(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC, bool bEnable)
    13291333{
    13301334    const VBOXVHWACMD_TYPE enmType = bEnable ? VBOXVHWACMD_TYPE_HH_ENABLE : VBOXVHWACMD_TYPE_HH_DISABLE;
     
    13331337    if(pCmd)
    13341338    {
    1335         int rc = vbvaVHWAHHPost (pVGAState, pCmd, NULL, NULL, NULL);
     1339        int rc = vbvaVHWAHHPost(pDevIns, pThis, pThisCC, pCmd, NULL, NULL, NULL);
    13361340        vbvaVHWAHHCommandRelease(pCmd);
    13371341        return rc;
     
    13431347{
    13441348    /* ensure we have no pending commands */
    1345     return vbvaVHWAEnable(PDMINS_2_DATA(pDevIns, PVGASTATE), false);
     1349    return vbvaVHWAEnable(pDevIns, PDMDEVINS_2_DATA(pDevIns, PVGASTATE), PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC), false);
    13461350}
    13471351
     
    13491353{
    13501354    /* ensure we have no pending commands */
    1351     return vbvaVHWAEnable(PDMINS_2_DATA(pDevIns, PVGASTATE), true);
    1352 }
     1355    return vbvaVHWAEnable(pDevIns, PDMDEVINS_2_DATA(pDevIns, PVGASTATE), PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC), true);
     1356}
     1357
    13531358
    13541359/**
     
    13581363                                                 VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *pCmd)
    13591364{
    1360     PVGASTATE pVGAState = PPDMIDISPLAYVBVACALLBACKS_2_PVGASTATE(pInterface);
     1365    PVGASTATECC pThisCC = RT_FROM_MEMBER(pInterface, VGASTATECC, IVBVACallbacks);
     1366    PPDMDEVINS  pDevIns = pThisCC->pDevIns;
     1367    PVGASTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
    13611368    int rc;
     1369
    13621370    Log(("VGA Command <<< Async rc %d %#p, %d\n", pCmd->rc, pCmd, pCmd->enmCmd));
    13631371
    1364     if ((uintptr_t)pCmd - (uintptr_t)pVGAState->vram_ptrR3 < pVGAState->vram_size)
    1365     {
    1366         PHGSMIINSTANCE pIns = pVGAState->pHGSMI;
     1372    if ((uintptr_t)pCmd - (uintptr_t)pThisCC->pbVRam < pThis->vram_size)
     1373    {
     1374        PHGSMIINSTANCE pIns = pThisCC->pHGSMI;
    13671375        Assert(!(pCmd->Flags & VBOXVHWACMD_FLAG_HH_CMD));
    13681376        Assert(pCmd->Flags & VBOXVHWACMD_FLAG_HG_ASYNCH);
    13691377#ifdef VBOX_WITH_WDDM
    1370         if (pVGAState->fGuestCaps & VBVACAPS_COMPLETEGCMD_BY_IOREAD)
     1378        if (pThis->fGuestCaps & VBVACAPS_COMPLETEGCMD_BY_IOREAD)
    13711379        {
    13721380            rc = HGSMICompleteGuestCommand(pIns, pCmd, !!(pCmd->Flags & VBOXVHWACMD_FLAG_GH_ASYNCH_IRQ));
     
    14491457} VBOXVBVASAVEDSTATECBDATA, *PVBOXVBVASAVEDSTATECBDATA;
    14501458
    1451 static DECLCALLBACK(bool) vboxVBVASaveStateBeginPostCb(PVGASTATE pVGAState, VBOXVHWACMD *pCmd, uint32_t iDisplay,
    1452                                                        int rc, void *pvContext)
    1453 {
    1454     RT_NOREF(pVGAState, pCmd);
     1459/**
     1460 * @callback_method_impl{FNVBOXVHWAHHCMDPOSTCB}
     1461 */
     1462static DECLCALLBACK(bool) vboxVBVASaveStateBeginPostCb(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC,
     1463                                                       VBOXVHWACMD *pCmd, uint32_t iDisplay, int rc, void *pvContext)
     1464{
     1465    RT_NOREF(pDevIns, pThis, pThisCC, pCmd);
    14551466    PVBOXVBVASAVEDSTATECBDATA pData = (PVBOXVBVASAVEDSTATECBDATA)pvContext;
    14561467    if (RT_FAILURE(pData->rc))
     
    14831494}
    14841495
    1485 static DECLCALLBACK(bool)
    1486 vboxVBVASaveStatePerformPreCb(PVGASTATE pVGAState, VBOXVHWACMD *pCmd, uint32_t iDisplay, void *pvContext)
    1487 {
    1488     RT_NOREF(pVGAState, pCmd);
     1496/**
     1497 * @callback_method_impl{FNVBOXVHWAHHCMDPRECB}
     1498 */
     1499static DECLCALLBACK(bool) vboxVBVASaveStatePerformPreCb(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC,
     1500                                                        VBOXVHWACMD *pCmd, uint32_t iDisplay, void *pvContext)
     1501{
     1502    RT_NOREF(pThis, pThisCC, pCmd);
    14891503    PVBOXVBVASAVEDSTATECBDATA pData = (PVBOXVBVASAVEDSTATECBDATA)pvContext;
    14901504    if (RT_FAILURE(pData->rc))
     
    14991513
    15001514    int rc;
    1501     PCPDMDEVHLPR3 pHlp = pVGAState->pDevInsR3->pHlpR3;
     1515    PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3;
    15021516
    15031517    if (pData->ab2DOn[iDisplay])
     
    15221536}
    15231537
    1524 static DECLCALLBACK(bool) vboxVBVASaveStateEndPreCb(PVGASTATE pVGAState, VBOXVHWACMD *pCmd, uint32_t iDisplay, void *pvContext)
    1525 {
    1526     RT_NOREF(pVGAState, pCmd);
     1538/**
     1539 * @callback_method_impl{FNVBOXVHWAHHCMDPOSTCB}
     1540 */
     1541static DECLCALLBACK(bool) vboxVBVASaveStateEndPreCb(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC,
     1542                                                    VBOXVHWACMD *pCmd, uint32_t iDisplay, void *pvContext)
     1543{
     1544    RT_NOREF(pDevIns, pThis, pThisCC, pCmd);
    15271545    PVBOXVBVASAVEDSTATECBDATA pData = (PVBOXVBVASAVEDSTATECBDATA)pvContext;
    15281546    Assert(iDisplay < RT_ELEMENTS(pData->ab2DOn));
    15291547    if (pData->ab2DOn[iDisplay])
    1530     {
    15311548        return true;
    1532     }
    1533 
    15341549    return false;
    15351550}
    15361551
    1537 static DECLCALLBACK(bool)
    1538 vboxVBVALoadStatePerformPostCb(PVGASTATE pVGAState, VBOXVHWACMD *pCmd, uint32_t iDisplay, int rc, void *pvContext)
    1539 {
    1540     RT_NOREF(pVGAState, pCmd);
     1552/**
     1553 * @callback_method_impl{FNVBOXVHWAHHCMDPOSTCB}
     1554 */
     1555static DECLCALLBACK(bool) vboxVBVALoadStatePerformPostCb(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC,
     1556                                                         VBOXVHWACMD *pCmd, uint32_t iDisplay, int rc, void *pvContext)
     1557{
     1558    RT_NOREF(pThis, pThisCC, pCmd);
    15411559    PVBOXVBVASAVEDSTATECBDATA pData = (PVBOXVBVASAVEDSTATECBDATA)pvContext;
    15421560    if (RT_FAILURE(pData->rc))
     
    15551573    }
    15561574
    1557     PCPDMDEVHLPR3 pHlp = pVGAState->pDevInsR3->pHlpR3;
     1575    PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3;
    15581576    Assert(RT_SUCCESS(pCmd->rc) || pCmd->rc == VERR_NOT_IMPLEMENTED);
    15591577    if (pCmd->rc == VERR_NOT_IMPLEMENTED)
     
    15721590}
    15731591
    1574 static DECLCALLBACK(bool)
    1575 vboxVBVALoadStatePerformPreCb(PVGASTATE pVGAState, VBOXVHWACMD *pCmd, uint32_t iDisplay, void *pvContext)
    1576 {
    1577     RT_NOREF(pVGAState, pCmd);
     1592/**
     1593 * @callback_method_impl{FNVBOXVHWAHHCMDPOSTCB}
     1594 */
     1595static DECLCALLBACK(bool) vboxVBVALoadStatePerformPreCb(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC,
     1596                                                        VBOXVHWACMD *pCmd, uint32_t iDisplay, void *pvContext)
     1597{
     1598    RT_NOREF(pThis, pThisCC, pCmd);
    15781599    PVBOXVBVASAVEDSTATECBDATA pData = (PVBOXVBVASAVEDSTATECBDATA)pvContext;
    15791600    if (RT_FAILURE(pData->rc))
     
    15871608    }
    15881609
    1589     PCPDMDEVHLPR3 pHlp = pVGAState->pDevInsR3->pHlpR3;
     1610    PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3;
    15901611    int rc;
    15911612    uint32_t u32;
     
    16101631    }
    16111632}
    1612 #endif /* #ifdef VBOX_WITH_VIDEOHWACCEL */
    1613 
    1614 int vboxVBVASaveDevStateExec(PCPDMDEVHLPR3 pHlp, PVGASTATE pVGAState, PSSMHANDLE pSSM)
    1615 {
    1616     PHGSMIINSTANCE pIns = pVGAState->pHGSMI;
     1633
     1634#endif /* VBOX_WITH_VIDEOHWACCEL */
     1635
     1636static int vboxVBVASaveDevStateExec(PCPDMDEVHLPR3 pHlp, PVGASTATE pThis, PVGASTATECC pThisCC, PSSMHANDLE pSSM)
     1637{
     1638    PHGSMIINSTANCE pIns = pThisCC->pHGSMI;
    16171639    int rc = HGSMIHostSaveStateExec(pHlp, pIns, pSSM);
    16181640    if (RT_SUCCESS(rc))
     
    17131735            rc = pHlp->pfnSSMPutU32(pSSM, 4);
    17141736            AssertRCReturn(rc, rc);
    1715             rc = pHlp->pfnSSMPutU32(pSSM, pVGAState->fGuestCaps);
     1737            rc = pHlp->pfnSSMPutU32(pSSM, pThis->fGuestCaps);
    17161738            AssertRCReturn(rc, rc);
    17171739#else
     
    17371759int vboxVBVASaveStateExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
    17381760{
    1739     PVGASTATE       pVGAState = PDMINS_2_DATA(pDevIns, PVGASTATE);
    1740     PCPDMDEVHLPR3   pHlp      = pDevIns->pHlpR3;
     1761    PVGASTATE       pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     1762    PVGASTATECC     pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
     1763    PCPDMDEVHLPR3   pHlp    = pDevIns->pHlpR3;
    17411764    int rc;
    17421765#ifdef VBOX_WITH_VIDEOHWACCEL
     
    17461769    VBOXVHWACMD *pCmd = vbvaVHWAHHCommandCreate(VBOXVHWACMD_TYPE_HH_SAVESTATE_SAVEBEGIN, 0, cbCmd);
    17471770    Assert(pCmd);
    1748     if(pCmd)
    1749     {
    1750         vbvaVHWAHHPost(pVGAState, pCmd, NULL, vboxVBVASaveStateBeginPostCb, &VhwaData);
     1771    if (pCmd)
     1772    {
     1773        vbvaVHWAHHPost(pDevIns, pThis, pThisCC, pCmd, NULL, vboxVBVASaveStateBeginPostCb, &VhwaData);
    17511774        rc = VhwaData.rc;
    17521775        AssertRC(rc);
     
    17541777        {
    17551778#endif
    1756             rc = vboxVBVASaveDevStateExec(pHlp, pVGAState, pSSM);
     1779            rc = vboxVBVASaveDevStateExec(pHlp, pThis, pThisCC, pSSM);
    17571780            AssertRC(rc);
    17581781#ifdef VBOX_WITH_VIDEOHWACCEL
     
    17621785                VBOXVHWACMD_HH_SAVESTATE_SAVEPERFORM *pSave = VBOXVHWACMD_BODY_HOST_HEAP(pCmd, VBOXVHWACMD_HH_SAVESTATE_SAVEPERFORM);
    17631786                pSave->pSSM = pSSM;
    1764                 vbvaVHWAHHPost(pVGAState, pCmd, vboxVBVASaveStatePerformPreCb, NULL, &VhwaData);
     1787                vbvaVHWAHHPost(pDevIns, pThis, pThisCC, pCmd, vboxVBVASaveStatePerformPreCb, NULL, &VhwaData);
    17651788                rc = VhwaData.rc;
    17661789                AssertRC(rc);
    17671790                if (RT_SUCCESS(rc))
    17681791                {
    1769                     rc = vbvaVHWACommandSavePending(pHlp, pVGAState, pSSM);
     1792                    rc = vbvaVHWACommandSavePending(pHlp, pThis, pThisCC, pSSM);
    17701793                    AssertRCReturn(rc, rc);
    17711794
    17721795                    vbvaVHWAHHCommandReinit(pCmd, VBOXVHWACMD_TYPE_HH_SAVESTATE_SAVEEND, 0);
    1773                     vbvaVHWAHHPost(pVGAState, pCmd, vboxVBVASaveStateEndPreCb, NULL, &VhwaData);
     1796                    vbvaVHWAHHPost(pDevIns, pThis, pThisCC, pCmd, vboxVBVASaveStateEndPreCb, NULL, &VhwaData);
    17741797                    rc = VhwaData.rc;
    17751798                    AssertRC(rc);
     
    17851808    if (RT_SUCCESS(rc))
    17861809    {
    1787         for (uint32_t i = 0; i < pVGAState->cMonitors; ++i)
     1810        for (uint32_t i = 0; i < pThis->cMonitors; ++i)
    17881811        {
    17891812            rc = pHlp->pfnSSMPutU32(pSSM, VBOXVBVASAVEDSTATE_VHWAUNAVAILABLE_MAGIC);
     
    18061829    }
    18071830
    1808     PVGASTATE       pVGAState = PDMINS_2_DATA(pDevIns, PVGASTATE);
    1809     PHGSMIINSTANCE  pIns      = pVGAState->pHGSMI;
    1810     PCPDMDEVHLPR3   pHlp      = pDevIns->pHlpR3;
     1831    PVGASTATE       pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     1832    PVGASTATECC     pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
     1833    PHGSMIINSTANCE  pIns    = pThisCC->pHGSMI;
     1834    PCPDMDEVHLPR3   pHlp    = pDevIns->pHlpR3;
    18111835    int rc = HGSMIHostLoadStateExec(pHlp, pIns, pSSM, uVersion);
    18121836    if (RT_SUCCESS(rc))
     
    19411965                if (cbExtra >= 4)
    19421966                {
    1943                     rc = pHlp->pfnSSMGetU32 (pSSM, &pVGAState->fGuestCaps);
     1967                    rc = pHlp->pfnSSMGetU32 (pSSM, &pThis->fGuestCaps);
    19441968                    AssertRCReturn(rc, rc);
    1945                     pVGAState->pDrv->pfnVBVAGuestCapabilityUpdate(pVGAState->pDrv, pVGAState->fGuestCaps);
     1969                    pThisCC->pDrv->pfnVBVAGuestCapabilityUpdate(pThisCC->pDrv, pThis->fGuestCaps);
    19461970                    cbExtra -= 4;
    19471971                }
     
    20012025                    VBOXVHWACMD_HH_SAVESTATE_LOADPERFORM *pLoad = VBOXVHWACMD_BODY_HOST_HEAP(pCmd, VBOXVHWACMD_HH_SAVESTATE_LOADPERFORM);
    20022026                    pLoad->pSSM = pSSM;
    2003                     vbvaVHWAHHPost (pVGAState, pCmd, vboxVBVALoadStatePerformPreCb, vboxVBVALoadStatePerformPostCb, &VhwaData);
     2027                    vbvaVHWAHHPost(pDevIns, pThis, pThisCC, pCmd, vboxVBVALoadStatePerformPreCb,
     2028                                   vboxVBVALoadStatePerformPostCb, &VhwaData);
    20042029                    rc = VhwaData.rc;
    20052030                    vbvaVHWAHHCommandRelease(pCmd);
     
    20082033                    if (fLoadCommands)
    20092034                    {
    2010                         rc = vbvaVHWACommandLoadPending(pHlp, pVGAState, pSSM, uVersion);
     2035                        rc = vbvaVHWACommandLoadPending(pDevIns, pHlp, pThis, pThisCC, pSSM, uVersion);
    20112036                        AssertRCReturn(rc, rc);
    20122037                    }
     
    20192044                uint32_t u32;
    20202045
    2021                 for (uint32_t i = 0; i < pVGAState->cMonitors; ++i)
     2046                for (uint32_t i = 0; i < pThis->cMonitors; ++i)
    20222047                {
    20232048                    rc = pHlp->pfnSSMGetU32(pSSM, &u32);
     
    20562081int vboxVBVALoadStateDone(PPDMDEVINS pDevIns)
    20572082{
    2058     PVGASTATE pVGAState = PDMINS_2_DATA(pDevIns, PVGASTATE);
    2059     VBVACONTEXT *pCtx = (VBVACONTEXT *)HGSMIContext(pVGAState->pHGSMI);
     2083    PVGASTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     2084    PVGASTATECC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
     2085    VBVACONTEXT *pCtx = (VBVACONTEXT *)HGSMIContext(pThisCC->pHGSMI);
    20602086    if (pCtx)
    20612087    {
     
    20662092            if (pView->vbva.guest.pVBVA)
    20672093            {
    2068                 int rc = vbvaEnable(iView, pVGAState, pCtx, pView->vbva.guest.pVBVA, pView->vbva.u32VBVAOffset, true /* fRestored */);
     2094                int rc = vbvaEnable(pThis, pThisCC, pCtx, iView, pView->vbva.guest.pVBVA,
     2095                                    pView->vbva.u32VBVAOffset, true /* fRestored */);
    20692096                if (RT_SUCCESS(rc))
    2070                     vbvaResize(pVGAState, pView, &pView->screen, false);
     2097                    vbvaResize(pThisCC, pView, &pView->screen, false);
    20712098                else
    20722099                    LogRel(("VBVA: can not restore: %Rrc\n", rc));
     
    20752102
    20762103        if (pCtx->mouseShapeInfo.fSet)
    2077             vbvaUpdateMousePointerShape(pVGAState, &pCtx->mouseShapeInfo, true);
     2104            vbvaUpdateMousePointerShape(pThisCC, &pCtx->mouseShapeInfo, true);
    20782105    }
    20792106
     
    20812108}
    20822109
    2083 void VBVARaiseIrq(PVGASTATE pVGAState, uint32_t fFlags)
    2084 {
    2085     PPDMDEVINS pDevIns = pVGAState->pDevInsR3;
    2086 
    2087     PDMDevHlpCritSectEnter(pVGAState->CTX_SUFF(pDevIns), &pVGAState->CritSectIRQ, VERR_SEM_BUSY);
    2088 
    2089     const uint32_t fu32CurrentGuestFlags = HGSMIGetHostGuestFlags(pVGAState->pHGSMI);
     2110void VBVARaiseIrq(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC, uint32_t fFlags)
     2111{
     2112    PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSectIRQ, VERR_SEM_BUSY);
     2113
     2114    const uint32_t fu32CurrentGuestFlags = HGSMIGetHostGuestFlags(pThisCC->pHGSMI);
    20902115    if ((fu32CurrentGuestFlags & HGSMIHOSTFLAGS_IRQ) == 0)
    20912116    {
    20922117        /* No IRQ set yet. */
    2093         Assert(pVGAState->fu32PendingGuestFlags == 0);
    2094 
    2095         HGSMISetHostGuestFlags(pVGAState->pHGSMI, HGSMIHOSTFLAGS_IRQ | fFlags);
     2118        Assert(pThis->fu32PendingGuestFlags == 0);
     2119
     2120        HGSMISetHostGuestFlags(pThisCC->pHGSMI, HGSMIHOSTFLAGS_IRQ | fFlags);
    20962121
    20972122        /* If VM is not running, the IRQ will be set in VBVAOnResume. */
     
    21042129    {
    21052130        /* IRQ already set, remember the new flags. */
    2106         pVGAState->fu32PendingGuestFlags |= HGSMIHOSTFLAGS_IRQ | fFlags;
    2107     }
    2108 
    2109     PDMDevHlpCritSectLeave(pVGAState->CTX_SUFF(pDevIns), &pVGAState->CritSectIRQ);
    2110 }
    2111 
    2112 void VBVAOnResume(PVGASTATE pThis)
    2113 {
    2114     PPDMDEVINS pDevIns = pThis->pDevInsR3;
    2115 
     2131        pThis->fu32PendingGuestFlags |= HGSMIHOSTFLAGS_IRQ | fFlags;
     2132    }
     2133
     2134    PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSectIRQ);
     2135}
     2136
     2137void VBVAOnResume(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC)
     2138{
    21162139    PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSectIRQ, VERR_SEM_BUSY);
    21172140
    2118     if (HGSMIGetHostGuestFlags(pThis->pHGSMI) & HGSMIHOSTFLAGS_IRQ)
     2141    if (HGSMIGetHostGuestFlags(pThisCC->pHGSMI) & HGSMIHOSTFLAGS_IRQ)
    21192142        PDMDevHlpPCISetIrqNoWait(pDevIns, 0, PDM_IRQ_LEVEL_HIGH);
    21202143
     
    21222145}
    21232146
    2124 static int vbvaHandleQueryConf32(PVGASTATE pVGAState, VBVACONF32 RT_UNTRUSTED_VOLATILE_GUEST *pConf32)
     2147static int vbvaHandleQueryConf32(PVGASTATECC pThisCC, VBVACONF32 RT_UNTRUSTED_VOLATILE_GUEST *pConf32)
    21252148{
    21262149    uint32_t const idxQuery = pConf32->u32Index;
     
    21282151    LogFlowFunc(("VBVA_QUERY_CONF32: u32Index %d, u32Value 0x%x\n", idxQuery, pConf32->u32Value));
    21292152
    2130     VBVACONTEXT *pCtx = (VBVACONTEXT *)HGSMIContext(pVGAState->pHGSMI);
     2153    VBVACONTEXT *pCtx = (VBVACONTEXT *)HGSMIContext(pThisCC->pHGSMI);
    21312154    uint32_t     uValue;
    21322155    if (idxQuery == VBOX_VBVA_CONF32_MONITOR_COUNT)
     
    21732196}
    21742197
    2175 static int vbvaHandleInfoHeap(PVGASTATE pVGAState, const VBVAINFOHEAP RT_UNTRUSTED_VOLATILE_GUEST *pInfoHeap)
     2198static int vbvaHandleInfoHeap(PVGASTATECC pThisCC, const VBVAINFOHEAP RT_UNTRUSTED_VOLATILE_GUEST *pInfoHeap)
    21762199{
    21772200    uint32_t const offHeap = pInfoHeap->u32HeapOffset;
     
    21802203    LogFlowFunc(("VBVA_INFO_HEAP: offset 0x%x, size 0x%x\n", offHeap, cbHeap));
    21812204
    2182     return HGSMIHostHeapSetup(pVGAState->pHGSMI, offHeap, cbHeap);
    2183 }
    2184 
    2185 int VBVAInfoView(PVGASTATE pVGAState, const VBVAINFOVIEW RT_UNTRUSTED_VOLATILE_GUEST *pView)
     2205    return HGSMIHostHeapSetup(pThisCC->pHGSMI, offHeap, cbHeap);
     2206}
     2207
     2208static int vbvaInfoView(PVGASTATE pThis, PVGASTATER3 pThisCC, const VBVAINFOVIEW RT_UNTRUSTED_VOLATILE_GUEST *pView)
    21862209{
    21872210    VBVAINFOVIEW view;
     
    21922215                 view.u32ViewIndex, view.u32ViewOffset, view.u32ViewSize, view.u32MaxScreenSize));
    21932216
    2194     VBVACONTEXT *pCtx = (VBVACONTEXT *)HGSMIContext(pVGAState->pHGSMI);
     2217    VBVACONTEXT *pCtx = (VBVACONTEXT *)HGSMIContext(pThisCC->pHGSMI);
    21952218    ASSERT_GUEST_LOGREL_MSG_RETURN(   view.u32ViewIndex     < pCtx->cViews
    2196                                    && view.u32ViewOffset    <= pVGAState->vram_size
    2197                                    && view.u32ViewSize      <= pVGAState->vram_size
    2198                                    && view.u32ViewOffset    <= pVGAState->vram_size - view.u32ViewSize
     2219                                   && view.u32ViewOffset    <= pThis->vram_size
     2220                                   && view.u32ViewSize      <= pThis->vram_size
     2221                                   && view.u32ViewOffset    <= pThis->vram_size - view.u32ViewSize
    21992222                                   && view.u32MaxScreenSize <= view.u32ViewSize,
    22002223                                   ("index %d(%d), offset 0x%x, size 0x%x, max 0x%x, vram size 0x%x\n",
    22012224                                    view.u32ViewIndex, pCtx->cViews, view.u32ViewOffset, view.u32ViewSize,
    2202                                     view.u32MaxScreenSize, pVGAState->vram_size),
     2225                                    view.u32MaxScreenSize, pThis->vram_size),
    22032226                                   VERR_INVALID_PARAMETER);
    22042227    RT_UNTRUSTED_VALIDATED_FENCE();
     
    22082231}
    22092232
    2210 int VBVAInfoScreen(PVGASTATE pVGAState, const VBVAINFOSCREEN RT_UNTRUSTED_VOLATILE_GUEST *pScreen)
     2233static int vbvaInfoScreen(PVGASTATECC pThisCC, const VBVAINFOSCREEN RT_UNTRUSTED_VOLATILE_GUEST *pScreen)
    22112234{
    22122235    /*
     
    22252248     */
    22262249    /* Allow screen.u16BitsPerPixel == 0 because legacy guest code used it for screen blanking. */
    2227     VBVACONTEXT *pCtx = (VBVACONTEXT *)HGSMIContext(pVGAState->pHGSMI);
     2250    VBVACONTEXT *pCtx = (VBVACONTEXT *)HGSMIContext(pThisCC->pHGSMI);
    22282251    ASSERT_GUEST_LOGREL_MSG_RETURN(screen.u32ViewIndex <  pCtx->cViews,
    22292252                                   ("Screen index %#x is out of bound (cViews=%#x)\n", screen.u32ViewIndex, pCtx->cViews),
     
    22582281     * Do the job.
    22592282     */
    2260     vbvaResize(pVGAState, &pCtx->aViews[screen.u32ViewIndex], &screen, true);
     2283    vbvaResize(pThisCC, &pCtx->aViews[screen.u32ViewIndex], &screen, true);
    22612284    return VINF_SUCCESS;
    22622285}
    22632286
    2264 int VBVAGetInfoViewAndScreen(PVGASTATE pVGAState, uint32_t u32ViewIndex, VBVAINFOVIEW *pView, VBVAINFOSCREEN *pScreen)
    2265 {
    2266     if (u32ViewIndex >= pVGAState->cMonitors)
     2287#ifdef UNUSED_FUNCTION
     2288int VBVAGetInfoViewAndScreen(PVGASTATE pThis, PVGASTATECC pThisCC, uint32_t u32ViewIndex, VBVAINFOVIEW *pView, VBVAINFOSCREEN *pScreen)
     2289{
     2290    if (u32ViewIndex >= pThis->cMonitors)
    22672291        return VERR_INVALID_PARAMETER;
    22682292
    2269     PHGSMIINSTANCE pIns = pVGAState->pHGSMI;
     2293    PHGSMIINSTANCE pIns = pThisCC->pHGSMI;
    22702294    VBVACONTEXT *pCtx = (VBVACONTEXT *)HGSMIContext (pIns);
    22712295
     
    22782302    return VINF_SUCCESS;
    22792303}
    2280 
    2281 static int vbvaHandleEnable(PVGASTATE pVGAState, uint32_t fEnableFlags, uint32_t offEnable, uint32_t idScreen)
     2304#endif
     2305
     2306static int vbvaHandleEnable(PVGASTATE pThis, PVGASTATER3 pThisCC, uint32_t fEnableFlags, uint32_t offEnable, uint32_t idScreen)
    22822307{
    22832308    LogFlowFunc(("VBVA_ENABLE[%u]: fEnableFlags=0x%x offEnable=%#x\n", idScreen, fEnableFlags, offEnable));
    2284     PHGSMIINSTANCE pIns = pVGAState->pHGSMI;
     2309    PHGSMIINSTANCE pIns = pThisCC->pHGSMI;
    22852310    VBVACONTEXT   *pCtx = (VBVACONTEXT *)HGSMIContext(pIns);
    22862311
     
    22952320    if (fEnableFlags & VBVA_F_ENABLE)
    22962321    {
    2297         ASSERT_GUEST_LOGREL_MSG_RETURN(offEnable < pVGAState->vram_size,
    2298                                        ("offEnable=%#x vram_size=%#x\n", offEnable, pVGAState->vram_size),
     2322        ASSERT_GUEST_LOGREL_MSG_RETURN(offEnable < pThis->vram_size,
     2323                                       ("offEnable=%#x vram_size=%#x\n", offEnable, pThis->vram_size),
    22992324                                       VERR_INVALID_PARAMETER);
    23002325        if (fEnableFlags & VBVA_F_ABSOFFSET)
    23012326            /* Offset from VRAM start. */
    2302             ASSERT_GUEST_LOGREL_MSG_RETURN(   pVGAState->vram_size >= RT_UOFFSETOF(VBVABUFFER, au8Data)
    2303                                            && offEnable <= pVGAState->vram_size - RT_UOFFSETOF(VBVABUFFER, au8Data),
    2304                                            ("offEnable=%#x vram_size=%#x\n", offEnable, pVGAState->vram_size),
     2327            ASSERT_GUEST_LOGREL_MSG_RETURN(   pThis->vram_size >= RT_UOFFSETOF(VBVABUFFER, au8Data)
     2328                                           && offEnable <= pThis->vram_size - RT_UOFFSETOF(VBVABUFFER, au8Data),
     2329                                           ("offEnable=%#x vram_size=%#x\n", offEnable, pThis->vram_size),
    23052330                                           VERR_INVALID_PARAMETER);
    23062331        else
     
    23092334            RT_UNTRUSTED_VALIDATED_FENCE();
    23102335            const VBVAINFOVIEW *pView = &pCtx->aViews[idScreen].view;
    2311             ASSERT_GUEST_LOGREL_MSG_RETURN(   pVGAState->vram_size - offEnable >= pView->u32ViewOffset
     2336            ASSERT_GUEST_LOGREL_MSG_RETURN(   pThis->vram_size - offEnable >= pView->u32ViewOffset
    23122337                                           && pView->u32ViewSize >= RT_UOFFSETOF(VBVABUFFER, au8Data)
    23132338                                           && offEnable <= pView->u32ViewSize - RT_UOFFSETOF(VBVABUFFER, au8Data),
    23142339                                           ("offEnable=%#x vram_size=%#x view: %#x LB %#x\n",
    2315                                             offEnable, pVGAState->vram_size, pView->u32ViewOffset, pView->u32ViewSize),
     2340                                            offEnable, pThis->vram_size, pView->u32ViewOffset, pView->u32ViewSize),
    23162341                                           VERR_INVALID_PARAMETER);
    23172342            offEnable += pView->u32ViewOffset;
     
    23352360
    23362361        /* Process any pending orders and empty the VBVA ring buffer. */
    2337         vbvaFlush(pVGAState, pCtx);
    2338 
    2339         rc = vbvaEnable(idScreen, pVGAState, pCtx, pVBVA, offEnable, false /* fRestored */);
     2362        vbvaFlush(pThis, pThisCC, pCtx);
     2363
     2364        rc = vbvaEnable(pThis, pThisCC, pCtx, idScreen, pVBVA, offEnable, false /* fRestored */);
    23402365        if (RT_FAILURE(rc))
    23412366            LogRelMax(8, ("VBVA: can not enable: %Rrc\n", rc));
    23422367    }
    23432368    else
    2344         rc = vbvaDisable(idScreen, pVGAState, pCtx);
     2369        rc = vbvaDisable(pThis, pThisCC, pCtx, idScreen);
    23452370    return rc;
    23462371}
    23472372
    2348 static int vbvaHandleQueryModeHints(PVGASTATE pVGAState, VBVAQUERYMODEHINTS volatile *pQueryModeHints, HGSMISIZE cbBuffer)
    2349 {
    2350     PHGSMIINSTANCE pIns = pVGAState->pHGSMI;
     2373static int vbvaHandleQueryModeHints(PVGASTATECC pThisCC, VBVAQUERYMODEHINTS volatile *pQueryModeHints, HGSMISIZE cbBuffer)
     2374{
     2375    PHGSMIINSTANCE pIns = pThisCC->pHGSMI;
    23512376    VBVACONTEXT   *pCtx = (VBVACONTEXT *)HGSMIContext(pIns);
    23522377
     
    23912416 */
    23922417
    2393 static DECLCALLBACK(void) vbvaNotifyGuest (void *pvCallback)
     2418static DECLCALLBACK(void) vbvaNotifyGuest(void *pvCallback)
    23942419{
    23952420#if defined(VBOX_WITH_HGSMI) && (defined(VBOX_WITH_VIDEOHWACCEL) || defined(VBOX_WITH_VDMA) || defined(VBOX_WITH_WDDM))
    2396     PVGASTATE pVGAState = (PVGASTATE)pvCallback;
    2397     VBVARaiseIrq (pVGAState, 0);
     2421    PPDMDEVINS pDevIns = (PPDMDEVINS)pvCallback;
     2422    PVGASTATE       pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     2423    PVGASTATECC     pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
     2424    VBVARaiseIrq(pDevIns, pThis, pThisCC, 0);
    23982425#else
    23992426    NOREF(pvCallback);
     
    24222449    LogFlowFunc(("pvHandler %p, u16ChannelInfo %d, pvBuffer %p, cbBuffer %u\n", pvHandler, u16ChannelInfo, pvBuffer, cbBuffer));
    24232450
    2424     PVGASTATE       pVGAState = (PVGASTATE)pvHandler;
    2425     PHGSMIINSTANCE  pIns      = pVGAState->pHGSMI;
    2426     VBVACONTEXT    *pCtx      = (VBVACONTEXT *)HGSMIContext(pIns);
     2451    PPDMDEVINS      pDevIns = (PPDMDEVINS)pvHandler;
     2452    PVGASTATE       pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     2453    PVGASTATECC     pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVGASTATECC);
     2454    PHGSMIINSTANCE  pIns    = pThisCC->pHGSMI;
     2455    VBVACONTEXT    *pCtx    = (VBVACONTEXT *)HGSMIContext(pIns);
    24272456
    24282457    switch (u16ChannelInfo)
     
    24342463                VBOXVDMACBUF_DR RT_UNTRUSTED_VOLATILE_GUEST *pCmd
    24352464                    = (VBOXVDMACBUF_DR RT_UNTRUSTED_VOLATILE_GUEST *)VBoxSHGSMIBufferData((VBOXSHGSMIHEADER RT_UNTRUSTED_VOLATILE_GUEST *)pvBuffer);
    2436                 vboxVDMACommand(pVGAState->pVdma, pCmd, cbBuffer - VBoxSHGSMIBufferHeaderSize());
     2465                vboxVDMACommand(pThisCC->pVdma, pCmd, cbBuffer - VBoxSHGSMIBufferHeaderSize());
    24372466                rc = VINF_SUCCESS;
    24382467            }
     
    24462475                VBOXVDMA_CTL RT_UNTRUSTED_VOLATILE_GUEST *pCmd
    24472476                    = (VBOXVDMA_CTL RT_UNTRUSTED_VOLATILE_GUEST *)VBoxSHGSMIBufferData((VBOXSHGSMIHEADER RT_UNTRUSTED_VOLATILE_GUEST *)pvBuffer);
    2448                 vboxVDMAControl(pVGAState->pVdma, pCmd, cbBuffer - VBoxSHGSMIBufferHeaderSize());
     2477                vboxVDMAControl(pThisCC->pVdma, pCmd, cbBuffer - VBoxSHGSMIBufferHeaderSize());
    24492478            }
    24502479            else
     
    24552484        case VBVA_QUERY_CONF32:
    24562485            if (cbBuffer >= sizeof(VBVACONF32))
    2457                 rc = vbvaHandleQueryConf32(pVGAState, (VBVACONF32 RT_UNTRUSTED_VOLATILE_GUEST *)pvBuffer);
     2486                rc = vbvaHandleQueryConf32(pThisCC, (VBVACONF32 RT_UNTRUSTED_VOLATILE_GUEST *)pvBuffer);
    24582487            else
    24592488                rc = VERR_INVALID_PARAMETER;
     
    24782507                     ++pView, cbBuffer -= sizeof(VBVAINFOVIEW))
    24792508                {
    2480                     rc = VBVAInfoView(pVGAState, pView);
     2509                    rc = vbvaInfoView(pThis, pThisCC, pView);
    24812510                    if (RT_FAILURE(rc))
    24822511                        break;
     
    24872516        case VBVA_INFO_HEAP:
    24882517            if (cbBuffer >= sizeof(VBVAINFOHEAP))
    2489                 rc = vbvaHandleInfoHeap(pVGAState, (VBVAINFOHEAP RT_UNTRUSTED_VOLATILE_GUEST *)pvBuffer);
     2518                rc = vbvaHandleInfoHeap(pThisCC, (VBVAINFOHEAP RT_UNTRUSTED_VOLATILE_GUEST *)pvBuffer);
    24902519            else
    24912520                rc = VERR_INVALID_PARAMETER;
     
    24942523        case VBVA_FLUSH:
    24952524            if (cbBuffer >= sizeof(VBVAFLUSH))
    2496                 rc = vbvaFlush(pVGAState, pCtx);
     2525                rc = vbvaFlush(pThis, pThisCC, pCtx);
    24972526            else
    24982527                rc = VERR_INVALID_PARAMETER;
     
    25022531            rc = VERR_INVALID_PARAMETER;
    25032532            if (cbBuffer >= sizeof(VBVAINFOSCREEN))
    2504                 rc = VBVAInfoScreen(pVGAState, (VBVAINFOSCREEN RT_UNTRUSTED_VOLATILE_GUEST *)pvBuffer);
     2533                rc = vbvaInfoScreen(pThisCC, (VBVAINFOSCREEN RT_UNTRUSTED_VOLATILE_GUEST *)pvBuffer);
    25052534            break;
    25062535
     
    25242553                    idScreen = vbvaViewFromBufferPtr(pIns, pCtx, pvBuffer);
    25252554
    2526                 rc = vbvaHandleEnable(pVGAState, fEnableFlags, offEnable, idScreen);
     2555                rc = vbvaHandleEnable(pThis, pThisCC, fEnableFlags, offEnable, idScreen);
    25272556                pVbvaEnable->i32Result = rc;
    25282557            }
     
    25342563                VBVAMOUSEPOINTERSHAPE RT_UNTRUSTED_VOLATILE_GUEST *pShape
    25352564                    = (VBVAMOUSEPOINTERSHAPE RT_UNTRUSTED_VOLATILE_GUEST *)pvBuffer;
    2536                 rc = vbvaMousePointerShape(pVGAState, pCtx, pShape, cbBuffer);
     2565                rc = vbvaMousePointerShape(pThisCC, pCtx, pShape, cbBuffer);
    25372566                pShape->i32Result = rc;
    25382567            }
     
    25462575            if (cbBuffer >= VBOXVHWACMD_HEADSIZE())
    25472576            {
    2548                 vbvaVHWAHandleCommand(pVGAState, (VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *)pvBuffer);
     2577                vbvaVHWAHandleCommand(pDevIns, pThis, pThisCC, (VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *)pvBuffer);
    25492578                rc = VINF_SUCCESS;
    25502579            }
     
    25592588            {
    25602589                VBVACAPS RT_UNTRUSTED_VOLATILE_GUEST *pCaps = (VBVACAPS RT_UNTRUSTED_VOLATILE_GUEST *)pvBuffer;
    2561                 pVGAState->fGuestCaps = pCaps->fCaps;
     2590                pThis->fGuestCaps = pCaps->fCaps;
    25622591                RT_UNTRUSTED_NONVOLATILE_COPY_FENCE();
    25632592
    2564                 pVGAState->pDrv->pfnVBVAGuestCapabilityUpdate(pVGAState->pDrv, pVGAState->fGuestCaps);
     2593                pThisCC->pDrv->pfnVBVAGuestCapabilityUpdate(pThisCC->pDrv, pThis->fGuestCaps);
    25652594                pCaps->rc = rc = VINF_SUCCESS;
    25662595            }
     
    25742603            {
    25752604                VBVASCANLINECFG RT_UNTRUSTED_VOLATILE_GUEST *pCfg = (VBVASCANLINECFG RT_UNTRUSTED_VOLATILE_GUEST *)pvBuffer;
    2576                 pVGAState->fScanLineCfg = pCfg->fFlags;
     2605                pThis->fScanLineCfg = pCfg->fFlags;
    25772606                RT_UNTRUSTED_NONVOLATILE_COPY_FENCE();
    25782607
     
    25882617                VBVAQUERYMODEHINTS RT_UNTRUSTED_VOLATILE_GUEST *pQueryModeHints
    25892618                    = (VBVAQUERYMODEHINTS RT_UNTRUSTED_VOLATILE_GUEST *)pvBuffer;
    2590                 rc = vbvaHandleQueryModeHints(pVGAState, pQueryModeHints, cbBuffer);
     2619                rc = vbvaHandleQueryModeHints(pThisCC, pQueryModeHints, cbBuffer);
    25912620                pQueryModeHints->rc = rc;
    25922621            }
     
    26112640                LogRelFlowFunc(("VBVA: ChannelHandler: VBVA_REPORT_INPUT_MAPPING: x=%RI32, y=%RI32, cx=%RU32, cy=%RU32\n",
    26122641                                inputMapping.x, inputMapping.y, inputMapping.cx, inputMapping.cy));
    2613                 pVGAState->pDrv->pfnVBVAInputMappingUpdate(pVGAState->pDrv,
     2642                pThisCC->pDrv->pfnVBVAInputMappingUpdate(pThisCC->pDrv,
    26142643                                                           inputMapping.x, inputMapping.y,
    26152644                                                           inputMapping.cx, inputMapping.cy);
     
    26332662                                RT_BOOL(Report.fReportPosition), vbvaViewFromBufferPtr(pIns, pCtx, pvBuffer), Report.x, Report.y));
    26342663
    2635                 pVGAState->pDrv->pfnVBVAReportCursorPosition(pVGAState->pDrv, RT_BOOL(Report.fReportPosition), vbvaViewFromBufferPtr(pIns, pCtx, pvBuffer), Report.x, Report.y);
     2664                pThisCC->pDrv->pfnVBVAReportCursorPosition(pThisCC->pDrv, RT_BOOL(Report.fReportPosition), vbvaViewFromBufferPtr(pIns, pCtx, pvBuffer), Report.x, Report.y);
    26362665                /* This was only ever briefly used by the guest, and a value
    26372666                 * of zero in both was taken to mean "ignore". */
     
    26522681}
    26532682
    2654 /* When VBVA is paused, then VGA device is allowed to work but
     2683/** When VBVA is paused, the VGA device is allowed to work but
    26552684 * no HGSMI etc state is changed.
    26562685 */
    2657 void VBVAPause(PVGASTATE pVGAState, bool fPause)
    2658 {
    2659     if (!pVGAState || !pVGAState->pHGSMI)
    2660     {
     2686static void vbvaPause(PVGASTATECC pThisCC, bool fPause)
     2687{
     2688    if (!pThisCC || !pThisCC->pHGSMI)
    26612689        return;
    2662     }
    2663 
    2664     VBVACONTEXT *pCtx = (VBVACONTEXT *)HGSMIContext(pVGAState->pHGSMI);
    2665 
     2690
     2691    VBVACONTEXT *pCtx = (VBVACONTEXT *)HGSMIContext(pThisCC->pHGSMI);
    26662692    if (pCtx)
    2667     {
    26682693        pCtx->fPaused = fPause;
    2669     }
    2670 }
    2671 
    2672 bool VBVAIsPaused(PVGASTATE pVGAState)
    2673 {
    2674     if (pVGAState && pVGAState->pHGSMI)
    2675     {
    2676         const VBVACONTEXT *pCtx = (VBVACONTEXT *)HGSMIContext(pVGAState->pHGSMI);
     2694}
     2695
     2696bool VBVAIsPaused(PVGASTATECC pThisCC)
     2697{
     2698    if (pThisCC && pThisCC->pHGSMI)
     2699    {
     2700        const VBVACONTEXT *pCtx = (VBVACONTEXT *)HGSMIContext(pThisCC->pHGSMI);
    26772701        if (pCtx && pCtx->cViews)
    26782702        {
     
    26872711}
    26882712
    2689 void VBVAOnVBEChanged(PVGASTATE pVGAState)
     2713void VBVAOnVBEChanged(PVGASTATE pThis, PVGASTATECC pThisCC)
    26902714{
    26912715    /* The guest does not depend on host handling the VBE registers. */
    2692     if (pVGAState->fGuestCaps & VBVACAPS_USE_VBVA_ONLY)
    2693     {
     2716    if (pThis->fGuestCaps & VBVACAPS_USE_VBVA_ONLY)
    26942717        return;
    2695     }
    2696 
    2697     VBVAPause(pVGAState, (pVGAState->vbe_regs[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_ENABLED) == 0);
    2698 }
    2699 
    2700 void VBVAReset (PVGASTATE pVGAState)
    2701 {
    2702     if (!pVGAState || !pVGAState->pHGSMI)
    2703     {
     2718
     2719    vbvaPause(pThisCC, (pThis->vbe_regs[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_ENABLED) == 0);
     2720}
     2721
     2722void VBVAReset(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC)
     2723{
     2724    if (!pThis || !pThisCC->pHGSMI)
    27042725        return;
    2705     }
    2706 
    2707     VBVACONTEXT *pCtx = (VBVACONTEXT *)HGSMIContext (pVGAState->pHGSMI);
     2726
     2727    VBVACONTEXT *pCtx = (VBVACONTEXT *)HGSMIContext(pThisCC->pHGSMI);
    27082728
    27092729#ifdef VBOX_WITH_VIDEOHWACCEL
    2710     vbvaVHWAReset (pVGAState);
     2730    vbvaVHWAReset(pDevIns, pThis, pThisCC);
    27112731#endif
    27122732
    2713     HGSMIReset(pVGAState->pHGSMI);
     2733    HGSMIReset(pThisCC->pHGSMI);
    27142734    /* Make sure the IRQ is reset. */
    2715     PDMDevHlpPCISetIrq(pVGAState->pDevInsR3, 0, PDM_IRQ_LEVEL_LOW);
    2716     pVGAState->fu32PendingGuestFlags = 0;
     2735    PDMDevHlpPCISetIrq(pDevIns, 0, PDM_IRQ_LEVEL_LOW);
     2736    pThis->fu32PendingGuestFlags = 0;
    27172737
    27182738    if (pCtx)
    27192739    {
    2720         vbvaFlush (pVGAState, pCtx);
    2721 
    2722         unsigned uScreenId;
    2723 
    2724         for (uScreenId = 0; uScreenId < pCtx->cViews; uScreenId++)
    2725         {
    2726             vbvaDisable (uScreenId, pVGAState, pCtx);
    2727         }
     2740        vbvaFlush(pThis, pThisCC, pCtx);
     2741
     2742        for (unsigned idScreen = 0; idScreen < pCtx->cViews; idScreen++)
     2743            vbvaDisable(pThis, pThisCC, pCtx, idScreen);
    27282744
    27292745        pCtx->mouseShapeInfo.fSet = false;
     
    27362752}
    27372753
    2738 int VBVAUpdateDisplay (PVGASTATE pVGAState)
     2754int VBVAUpdateDisplay(PVGASTATE pThis, PVGASTATECC pThisCC)
    27392755{
    27402756    int rc = VERR_NOT_SUPPORTED; /* Assuming that the VGA device will have to do updates. */
    27412757
    2742     VBVACONTEXT *pCtx = (VBVACONTEXT *)HGSMIContext (pVGAState->pHGSMI);
    2743 
     2758    VBVACONTEXT *pCtx = (VBVACONTEXT *)HGSMIContext(pThisCC->pHGSMI);
    27442759    if (pCtx)
    27452760    {
    27462761        if (!pCtx->fPaused)
    27472762        {
    2748             rc = vbvaFlush (pVGAState, pCtx);
    2749 
    2750             if (RT_SUCCESS (rc))
     2763            rc = vbvaFlush(pThis, pThisCC, pCtx);
     2764            if (RT_SUCCESS(rc))
    27512765            {
    27522766                if (!pCtx->aViews[0].vbva.guest.pVBVA)
     
    27622776}
    27632777
    2764 static int vbvaSendModeHintWorker(PVGASTATE pThis, uint32_t cx, uint32_t cy,
    2765                                   uint32_t cBPP, uint32_t iDisplay, uint32_t dx,
     2778static int vbvaSendModeHintWorker(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC,
     2779                                  uint32_t cx, uint32_t cy, uint32_t cBPP, uint32_t iDisplay, uint32_t dx,
    27662780                                  uint32_t dy, uint32_t fEnabled,
    27672781                                  uint32_t fNotifyGuest)
    27682782{
    2769     VBVACONTEXT *pCtx = (VBVACONTEXT *)HGSMIContext(pThis->pHGSMI);
     2783    VBVACONTEXT *pCtx = (VBVACONTEXT *)HGSMIContext(pThisCC->pHGSMI);
    27702784    /** @note See Display::setVideoModeHint: "It is up to the guest to decide
    27712785     *  whether the hint is valid. Therefore don't do any VRAM sanity checks
     
    27812795    pCtx->aModeHints[iDisplay].fEnabled = fEnabled;
    27822796    if (fNotifyGuest && pThis->fGuestCaps & VBVACAPS_IRQ && pThis->fGuestCaps & VBVACAPS_VIDEO_MODE_HINTS)
    2783         VBVARaiseIrq(pThis, HGSMIHOSTFLAGS_HOTPLUG);
     2797        VBVARaiseIrq(pDevIns, pThis, pThisCC, HGSMIHOSTFLAGS_HOTPLUG);
    27842798    return VINF_SUCCESS;
    27852799}
    27862800
    2787 /** Converts a display port interface pointer to a vga state pointer. */
    2788 #define IDISPLAYPORT_2_VGASTATE(pInterface) ( (PVGASTATE)((uintptr_t)pInterface - RT_OFFSETOF(VGASTATE, IPort)) )
    27892801
    27902802/**
     
    27942806                                         uint32_t iDisplay, uint32_t dx, uint32_t dy, uint32_t fEnabled, uint32_t fNotifyGuest)
    27952807{
    2796     PVGASTATE pThis = IDISPLAYPORT_2_VGASTATE(pInterface);
    2797     int rc = PDMDevHlpCritSectEnter(pThis->pDevInsR3, &pThis->CritSect, VERR_SEM_BUSY);
     2808    PVGASTATECC pThisCC = RT_FROM_MEMBER(pInterface, VGASTATECC, IPort);
     2809    PPDMDEVINS  pDevIns = pThisCC->pDevIns;
     2810    PVGASTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
     2811    int rc = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_SEM_BUSY);
    27982812    AssertRC(rc);
    27992813
    2800     rc = vbvaSendModeHintWorker(pThis, cx, cy, cBPP, iDisplay, dx, dy, fEnabled, fNotifyGuest);
    2801 
    2802     PDMDevHlpCritSectLeave(pThis->pDevInsR3, &pThis->CritSect);
     2814    rc = vbvaSendModeHintWorker(pDevIns, pThis, pThisCC, cx, cy, cBPP, iDisplay, dx, dy, fEnabled, fNotifyGuest);
     2815
     2816    PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect);
    28032817    return rc;
    28042818}
    28052819
    2806 int VBVAInit(PVGASTATE pVGAState)
    2807 {
    2808     PPDMDEVINS pDevIns = pVGAState->pDevInsR3;
    2809 
     2820int VBVAInit(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC)
     2821{
    28102822    PVM pVM = PDMDevHlpGetVM(pDevIns);
    28112823
    2812     int rc = HGSMICreate(&pVGAState->pHGSMI,
     2824    int rc = HGSMICreate(&pThisCC->pHGSMI,
    28132825                         pVM,
    28142826                         "VBVA",
    28152827                         0,
    2816                          pVGAState->vram_ptrR3,
    2817                          pVGAState->vram_size,
     2828                         pThisCC->pbVRam,
     2829                         pThis->vram_size,
    28182830                         vbvaNotifyGuest,
    2819                          pVGAState,
     2831                         pDevIns,
    28202832                         sizeof(VBVACONTEXT));
    28212833     if (RT_SUCCESS(rc))
    28222834     {
    2823          rc = HGSMIHostChannelRegister(pVGAState->pHGSMI,
     2835         rc = HGSMIHostChannelRegister(pThisCC->pHGSMI,
    28242836                                       HGSMI_CH_VBVA,
    28252837                                       vbvaChannelHandler,
    2826                                        pVGAState);
     2838                                       pDevIns);
    28272839         if (RT_SUCCESS(rc))
    28282840         {
    2829              VBVACONTEXT *pCtx = (VBVACONTEXT *)HGSMIContext(pVGAState->pHGSMI);
    2830              pCtx->cViews = pVGAState->cMonitors;
     2841             VBVACONTEXT *pCtx = (VBVACONTEXT *)HGSMIContext(pThisCC->pHGSMI);
     2842             pCtx->cViews = pThis->cMonitors;
    28312843             pCtx->fPaused = true;
    28322844             memset(pCtx->aModeHints, ~0, sizeof(pCtx->aModeHints));
     
    28382850}
    28392851
    2840 void VBVADestroy(PVGASTATE pVGAState)
    2841 {
    2842     PHGSMIINSTANCE pHgsmi = pVGAState->pHGSMI;
     2852void VBVADestroy(PVGASTATECC pThisCC)
     2853{
     2854    PHGSMIINSTANCE pHgsmi = pThisCC->pHGSMI;
    28432855    if (pHgsmi)
    28442856    {
     
    28512863
    28522864        HGSMIDestroy(pHgsmi);
    2853         pVGAState->pHGSMI = NULL;
    2854     }
    2855 }
    2856 
     2865        pThisCC->pHGSMI = NULL;
     2866    }
     2867}
     2868
  • trunk/src/VBox/Devices/Graphics/DevVGA_VDMA.cpp

    r82048 r82109  
    172172{
    173173    PHGSMIINSTANCE pHgsmi; /**< Same as VGASTATE::pHgsmi. */
    174     PVGASTATE pVGAState;
     174    PVGASTATE pThis;
    175175} VBOXVDMAHOST, *PVBOXVDMAHOST;
    176176
     
    186186
    187187
    188 /*********************************************************************************************************************************
    189 *   Internal Functions                                                                                                           *
    190 *********************************************************************************************************************************/
    191188
    192189
     
    196193 * @returns VBox status code.
    197194 */
    198 int vboxVDMAConstruct(PVGASTATE pVGAState, uint32_t cPipeElements)
     195int vboxVDMAConstruct(PVGASTATE pThis, PVGASTATECC pThisCC, uint32_t cPipeElements)
    199196{
    200197    RT_NOREF(cPipeElements);
    201     int rc;
    202198    PVBOXVDMAHOST pVdma = (PVBOXVDMAHOST)RTMemAllocZ(sizeof(*pVdma));
    203199    Assert(pVdma);
    204200    if (pVdma)
    205201    {
    206         pVdma->pHgsmi    = pVGAState->pHGSMI;
    207         pVdma->pVGAState = pVGAState;
    208 
    209         rc = VINF_SUCCESS;
    210         if (RT_SUCCESS(rc))
    211         {
    212                         pVGAState->pVdma = pVdma;
    213 
    214                         return VINF_SUCCESS;
    215             /* the timer is cleaned up automatically */
    216         }
    217         RTMemFree(pVdma);
    218     }
    219     else
    220         rc = VERR_OUT_OF_RESOURCES;
    221     return rc;
     202        pVdma->pHgsmi = pThisCC->pHGSMI;
     203        pVdma->pThis  = pThis;
     204
     205        pThisCC->pVdma = pVdma;
     206        return VINF_SUCCESS;
     207    }
     208    return VERR_NO_MEMORY;
    222209}
    223210
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