VirtualBox

Ignore:
Timestamp:
Nov 9, 2010 11:20:54 AM (14 years ago)
Author:
vboxsync
Message:

Additions/WINNT/Graphics: more refactoring

Location:
trunk/src/VBox/Additions/WINNT/Graphics
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Display/vbox.c

    r33048 r33890  
    480480{
    481481    VBVAHOSTCMD * pCmd, * pNextCmd;
    482     int rc = ppdev->pfnHGSMIRequestCommands(ppdev->hMpHGSMI, HGSMI_CH_VBVA, &pCmd);
     482    int rc = ppdev->pfnHGSMIRequestCommands(ppdev->hMpHGSMI, HGSMI_CH_VBVA, ppdev->iDevice, &pCmd);
    483483    /* don't assert here, otherwise NT4 will be unhappy */
    484484    if(RT_SUCCESS(rc))
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxHGSMI.h

    r33540 r33890  
    2626
    2727/* request the host commands addressed to the display */
    28 typedef DECLCALLBACK(int) FNVBOXVIDEOHGSMICOMMANDS(HVBOXVIDEOHGSMI hHGSMI, uint8_t u8Channel, struct _VBVAHOSTCMD ** ppCmd);
     28typedef DECLCALLBACK(int) FNVBOXVIDEOHGSMICOMMANDS(HVBOXVIDEOHGSMI hHGSMI, uint8_t u8Channel, uint32_t iDevice, struct _VBVAHOSTCMD ** ppCmd);
    2929typedef FNVBOXVIDEOHGSMICOMMANDS *PFNVBOXVIDEOHGSMICOMMANDS;
    3030
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp

    r33879 r33890  
    35783578            HGSMIQUERYCALLBACKS *pInfo = (HGSMIQUERYCALLBACKS *)RequestPacket->OutputBuffer;
    35793579
    3580             pInfo->hContext = pDevExt;
     3580            pInfo->hContext = commonFromDeviceExt(pDevExt);
    35813581            pInfo->pfnCompletionHandler = hgsmiHostCmdComplete;
    35823582            pInfo->pfnRequestCommandsHandler = hgsmiHostCmdRequest;
     
    36323632            HGSMIHANDLERENABLE *pInfo = (HGSMIHANDLERENABLE *)RequestPacket->InputBuffer;
    36333633
    3634             int rc = vboxVBVAChannelDisplayEnable(pDevExt->pPrimary,
     3634            int rc = vboxVBVAChannelDisplayEnable(commonFromDeviceExt(pDevExt),
    36353635                    pDevExt->iDevice,
    36363636                    pInfo->u8Channel);
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h

    r33876 r33890  
    691691#ifndef VBOX_WITH_WDDM
    692692DECLCALLBACK(void) hgsmiHostCmdComplete (HVBOXVIDEOHGSMI hHGSMI, struct _VBVAHOSTCMD * pCmd);
    693 DECLCALLBACK(int) hgsmiHostCmdRequest (HVBOXVIDEOHGSMI hHGSMI, uint8_t u8Channel, struct _VBVAHOSTCMD ** ppCmd);
    694 #endif
    695 
    696 
    697 int vboxVBVAChannelDisplayEnable(PDEVICE_EXTENSION PrimaryExtension,
     693DECLCALLBACK(int) hgsmiHostCmdRequest (HVBOXVIDEOHGSMI hHGSMI, uint8_t u8Channel, uint32_t iDisplay, struct _VBVAHOSTCMD ** ppCmd);
     694#endif
     695
     696
     697int vboxVBVAChannelDisplayEnable(PVBOXVIDEO_COMMON pCommon,
    698698        int iDisplay, /* negative would mean this is a miniport handler */
    699699        uint8_t u8Channel);
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideoHGSMI.cpp

    r33876 r33890  
    689689}
    690690
    691 void dbgCheckList(PDEVICE_EXTENSION PrimaryExtension, VBVADISP_CHANNELCONTEXT *pList, struct _VBVAHOSTCMD * pCmd)
     691void dbgCheckList(PVBOXVIDEO_COMMON pCommon, VBVADISP_CHANNELCONTEXT *pList, struct _VBVAHOSTCMD * pCmd)
    692692{
    693693    VBOXVCMNIRQL oldIrql;
    694     VBoxVideoCmnSpinLockAcquire(PrimaryExtension, &pList->pSynchLock, &oldIrql);
     694    VBoxVideoCmnSpinLockAcquire(commonToPrimaryExt(pCommon), &pList->pSynchLock, &oldIrql);
    695695
    696696    dbgCheckListLocked(pList, pCmd);
    697697
    698     VBoxVideoCmnSpinLockRelease(PrimaryExtension, &pList->pSynchLock, oldIrql);
     698    VBoxVideoCmnSpinLockRelease(commonToPrimaryExt(pCommon), &pList->pSynchLock, oldIrql);
    699699}
    700700
    701701#define DBG_CHECKLIST_LOCKED(_pl, pc) dbgCheckListLocked(_pl, pc)
    702 #define DBG_CHECKLIST(_pe, _pl, pc) dbgCheckList(_pe, _pl, pc)
     702#define DBG_CHECKLIST(_pv, _pl, pc) dbgCheckList(_pv, _pl, pc)
    703703
    704704#else
    705705#define DBG_CHECKLIST_LOCKED(_pl, pc) do{}while(0)
    706 #define DBG_CHECKLIST(_pe, _pl, pc) do{}while(0)
     706#define DBG_CHECKLIST(_pv, _pl, pc) do{}while(0)
    707707#endif
    708708
     
    710710typedef struct _VBVA_CHANNELCONTEXTS
    711711{
    712     PDEVICE_EXTENSION PrimaryExtension;
     712    PVBOXVIDEO_COMMON pCommon;
    713713    uint32_t cUsed;
    714714    uint32_t cContexts;
     
    724724}
    725725
    726 static int vboxVBVACreateChannelContexts(PDEVICE_EXTENSION PrimaryExtension, VBVA_CHANNELCONTEXTS ** ppContext)
    727 {
    728     uint32_t cDisplays = (uint32_t)commonFromDeviceExt(PrimaryExtension)->cDisplays;
     726static int vboxVBVACreateChannelContexts(PVBOXVIDEO_COMMON pCommon, VBVA_CHANNELCONTEXTS ** ppContext)
     727{
     728    uint32_t cDisplays = (uint32_t)pCommon->cDisplays;
    729729    const size_t size = RT_OFFSETOF(VBVA_CHANNELCONTEXTS, aContexts[cDisplays]);
    730     VBVA_CHANNELCONTEXTS * pContext = (VBVA_CHANNELCONTEXTS*)VBoxVideoCmnMemAllocDriver(commonFromDeviceExt(PrimaryExtension), size);
     730    VBVA_CHANNELCONTEXTS * pContext = (VBVA_CHANNELCONTEXTS*)VBoxVideoCmnMemAllocDriver(pCommon, size);
    731731    if(pContext)
    732732    {
    733733        memset(pContext, 0, size);
    734734        pContext->cContexts = cDisplays;
    735         pContext->PrimaryExtension = PrimaryExtension;
     735        pContext->pCommon = pCommon;
    736736        *ppContext = pContext;
    737737        return VINF_SUCCESS;
     
    755755DECLCALLBACK(void) hgsmiHostCmdComplete (HVBOXVIDEOHGSMI hHGSMI, struct _VBVAHOSTCMD * pCmd)
    756756{
    757     PDEVICE_EXTENSION PrimaryExtension = ((PDEVICE_EXTENSION)hHGSMI)->pPrimary;
    758     HGSMIHostCmdComplete (commonFromDeviceExt(PrimaryExtension), pCmd);
    759 }
    760 
    761 DECLCALLBACK(int) hgsmiHostCmdRequest (HVBOXVIDEOHGSMI hHGSMI, uint8_t u8Channel, struct _VBVAHOSTCMD ** ppCmd)
     757    PVBOXVIDEO_COMMON pCommon = (PVBOXVIDEO_COMMON)hHGSMI;
     758    HGSMIHostCmdComplete (pCommon, pCmd);
     759}
     760
     761DECLCALLBACK(int) hgsmiHostCmdRequest (HVBOXVIDEOHGSMI hHGSMI, uint8_t u8Channel, uint32_t iDevice, struct _VBVAHOSTCMD ** ppCmd)
    762762{
    763763//    if(display < 0)
     
    766766        return VERR_INVALID_PARAMETER;
    767767
    768     PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)hHGSMI;
    769     PDEVICE_EXTENSION PrimaryExtension = pDevExt->pPrimary;
     768    PVBOXVIDEO_COMMON pCommon = (PVBOXVIDEO_COMMON)hHGSMI;
    770769
    771770    /* pick up the host commands */
    772     hgsmiProcessHostCommandQueue(commonFromDeviceExt(PrimaryExtension));
    773 
    774     HGSMICHANNEL * pChannel = HGSMIChannelFindById (&commonFromDeviceExt(PrimaryExtension)->channels, u8Channel);
     771    hgsmiProcessHostCommandQueue(pCommon);
     772
     773    HGSMICHANNEL * pChannel = HGSMIChannelFindById (&pCommon->channels, u8Channel);
    775774    if(pChannel)
    776775    {
    777776        VBVA_CHANNELCONTEXTS * pContexts = (VBVA_CHANNELCONTEXTS *)pChannel->handler.pvHandler;
    778         VBVADISP_CHANNELCONTEXT *pDispContext = vboxVBVAFindHandlerInfo(pContexts, pDevExt->iDevice);
     777        VBVADISP_CHANNELCONTEXT *pDispContext = vboxVBVAFindHandlerInfo(pContexts, iDevice);
    779778        Assert(pDispContext);
    780779        if(pDispContext)
    781780        {
    782781            UCHAR oldIrql;
    783             VBoxVideoCmnSpinLockAcquire(PrimaryExtension, &pDispContext->pSynchLock, &oldIrql);
     782            VBoxVideoCmnSpinLockAcquire(commonToPrimaryExt(pCommon), &pDispContext->pSynchLock, &oldIrql);
    784783
    785784            DBG_CHECKLIST_LOCKED(pDispContext, NULL);
     
    791790            pDispContext->cCmds = 0;
    792791#endif
    793             VBoxVideoCmnSpinLockRelease(PrimaryExtension, &pDispContext->pSynchLock, oldIrql);
    794 
    795             DBG_CHECKLIST(PrimaryExtension, pDispContext, NULL);
     792            VBoxVideoCmnSpinLockRelease(commonToPrimaryExt(pCommon), &pDispContext->pSynchLock, oldIrql);
     793
     794            DBG_CHECKLIST(pCommon, pDispContext, NULL);
    796795
    797796            return VINF_SUCCESS;
     
    857856                        {
    858857                            VBVAHOSTCMDEVENT *pEventCmd = VBVAHOSTCMD_BODY(pCur, VBVAHOSTCMDEVENT);
    859                             VBoxVideoCmnSignalEvent(commonFromDeviceExt(pCallbacks->PrimaryExtension), pEventCmd->pEvent);
     858                            VBoxVideoCmnSignalEvent(pCallbacks->pCommon, pEventCmd->pEvent);
    860859                        }
    861860                        default:
    862861                        {
    863                             DBG_CHECKLIST(pCallbacks->PrimaryExtension, pHandler, pCur);
     862                            DBG_CHECKLIST(pCallbacks->pCommon, pHandler, pCur);
    864863                            Assert(u16ChannelInfo==VBVAHG_EVENT);
    865864                            Assert(!pCur->u.Data);
     
    873872                            Assert(!pCur->u.pNext);
    874873#endif
    875                             HGSMIHostCmdComplete(commonFromDeviceExt(pCallbacks->PrimaryExtension), pCur);
     874                            HGSMIHostCmdComplete(pCallbacks->pCommon, pCur);
    876875#if 0  /* pNext is NULL, and the other things have already been asserted */
    877876                            pCur = pNext;
     
    887886                }
    888887
    889                 DBG_CHECKLIST(pCallbacks->PrimaryExtension, pHandler, pFirst);
     888                DBG_CHECKLIST(pCallbacks->pCommon, pHandler, pFirst);
    890889
    891890                /* we do not support lists currently */
     
    900899                    Assert(pLast);
    901900                    UCHAR oldIrql;
    902                     VBoxVideoCmnSpinLockAcquire(pCallbacks->PrimaryExtension,
     901                    VBoxVideoCmnSpinLockAcquire(commonToPrimaryExt(pCallbacks->pCommon),
    903902                                                &pHandler->pSynchLock,
    904903                                                &oldIrql);
     
    922921                    DBG_CHECKLIST_LOCKED(pHandler, NULL);
    923922
    924                     VBoxVideoCmnSpinLockRelease(pCallbacks->PrimaryExtension,
     923                    VBoxVideoCmnSpinLockRelease(commonToPrimaryExt(pCallbacks->pCommon),
    925924                                                &pHandler->pSynchLock,
    926925                                                oldIrql);
     
    946945    }
    947946    /* no handlers were found, need to complete the command here */
    948     HGSMIHostCmdComplete(commonFromDeviceExt(pCallbacks->PrimaryExtension), pvBuffer);
     947    HGSMIHostCmdComplete(pCallbacks->pCommon, pvBuffer);
    949948    return VINF_SUCCESS;
    950949}
     
    952951static HGSMICHANNELHANDLER g_OldHandler;
    953952
    954 int vboxVBVAChannelDisplayEnable(PDEVICE_EXTENSION PrimaryExtension,
     953int vboxVBVAChannelDisplayEnable(PVBOXVIDEO_COMMON pCommon,
    955954        int iDisplay, /* negative would mean this is a miniport handler */
    956955        uint8_t u8Channel)
    957956{
    958957    VBVA_CHANNELCONTEXTS * pContexts;
    959     HGSMICHANNEL * pChannel = HGSMIChannelFindById (&commonFromDeviceExt(PrimaryExtension)->channels, u8Channel);
     958    HGSMICHANNEL * pChannel = HGSMIChannelFindById (&pCommon->channels, u8Channel);
    960959    if(!pChannel)
    961960    {
    962         int rc = vboxVBVACreateChannelContexts(PrimaryExtension, &pContexts);
     961        int rc = vboxVBVACreateChannelContexts(pCommon, &pContexts);
    963962        if(RT_FAILURE(rc))
    964963        {
     
    989988#endif
    990989
    991             VBoxVideoCmnSpinLockCreate(PrimaryExtension, &pDispContext->pSynchLock);
     990            VBoxVideoCmnSpinLockCreate(commonToPrimaryExt(pCommon), &pDispContext->pSynchLock);
    992991
    993992            int rc = VINF_SUCCESS;
    994993            if(!pChannel)
    995994            {
    996                 rc = HGSMIChannelRegister (&commonFromDeviceExt(PrimaryExtension)->channels,
     995                rc = HGSMIChannelRegister (&pCommon->channels,
    997996                                           u8Channel,
    998997                                           "VGA Miniport HGSMI channel",
     
    10121011    if(!pChannel)
    10131012    {
    1014         vboxVBVADeleteChannelContexts(commonFromDeviceExt(PrimaryExtension), pContexts);
     1013        vboxVBVADeleteChannelContexts(pCommon, pContexts);
    10151014    }
    10161015
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