VirtualBox

Changeset 22448 in vbox for trunk/src/VBox/Additions/WINNT


Ignore:
Timestamp:
Aug 25, 2009 11:12:49 PM (15 years ago)
Author:
vboxsync
Message:

hgsmi/guest video driver: backwards compatibility with < WinXP: make newer videoport functions picked up at runtime

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Display/driver.h

    r22440 r22448  
    4141
    4242#include <VBox/VBoxVideo.h>
     43#ifdef VBOX_WITH_VIDEOHWACCEL
     44#include <iprt/asm.h>
     45#endif
    4346
    4447/* Forward declaration. */
     
    207210    PFNVBOXVIDEOHGSMICOMPLETION pfnHGSMICommandComplete; /* called to complete the command we receive from the miniport */
    208211    PFNVBOXVIDEOHGSMICOMMANDS   pfnHGSMIRequestCommands; /* called to requests the commands posted to us from the host */
     212
     213    PVOID pVideoPortContext;
     214    VBOXVIDEOPORTPROCS VideoPortProcs;
    209215#endif /* VBOX_WITH_HGSMI */
    210216
     
    329335BOOL vboxVHWACommandSubmit (PPDEV ppdev, VBOXVHWACMD* pCmd);
    330336void vboxVHWACommandSubmitAsynch (PPDEV ppdev, VBOXVHWACMD* pCmd, PFNVBOXVHWACMDCOMPLETION pfnCompletion, void * pContext);
    331 void vboxVHWACommandSubmitAsynchByEvent (PPDEV ppdev, VBOXVHWACMD* pCmd, PEVENT pEvent);
     337void vboxVHWACommandSubmitAsynchByEvent (PPDEV ppdev, VBOXVHWACMD* pCmd, VBOXPEVENT pEvent);
    332338void vboxVHWACommandCheckHostCmds(PPDEV ppdev);
    333339void vboxVHWACommandSubmitAsynchAndComplete (PPDEV ppdev, VBOXVHWACMD* pCmd);
  • trunk/src/VBox/Additions/WINNT/Graphics/Display/screen.c

    r22440 r22448  
    119119        if(!err)
    120120        {
    121             HGSMIHANDLERENABLE HandlerReg;
    122             RtlZeroMemory(&HandlerReg, sizeof(HandlerReg));
     121            HGSMIQUERYCPORTPROCS PortProcs;
     122            RtlZeroMemory(&PortProcs, sizeof(PortProcs));
    123123
    124124            ppdev->hMpHGSMI = Callbacks.hContext;
     
    127127            ppdev->pfnHGSMIRequestCommands = Callbacks.pfnRequestCommandsHandler;
    128128
    129             HandlerReg.u8Channel = HGSMI_CH_VBVA;
    130129            err = EngDeviceIoControl(ppdev->hDriver,
    131                     IOCTL_VIDEO_HGSMI_HANDLER_ENABLE,
    132                     &HandlerReg,
    133                     sizeof(HandlerReg),
     130                    IOCTL_VIDEO_HGSMI_QUERY_PORTPROCS,
    134131                    NULL,
    135132                    0,
     133                    &PortProcs,
     134                    sizeof(PortProcs),
    136135                    &returnedDataLength);
    137136            Assert(!err);
     137            if(!err)
     138            {
     139                HGSMIHANDLERENABLE HandlerReg;
     140                RtlZeroMemory(&HandlerReg, sizeof(HandlerReg));
     141
     142                ppdev->pVideoPortContext = PortProcs.pContext;
     143                ppdev->VideoPortProcs = PortProcs.VideoPortProcs;
     144
     145                HandlerReg.u8Channel = HGSMI_CH_VBVA;
     146                err = EngDeviceIoControl(ppdev->hDriver,
     147                        IOCTL_VIDEO_HGSMI_HANDLER_ENABLE,
     148                        &HandlerReg,
     149                        sizeof(HandlerReg),
     150                        NULL,
     151                        0,
     152                        &returnedDataLength);
     153                Assert(!err);
     154            }
    138155        }
    139156
     
    142159            ppdev->bHGSMISupported = FALSE;
    143160        }
    144 
    145161    }
    146162#endif /* VBOX_WITH_HGSMI */
  • trunk/src/VBox/Additions/WINNT/Graphics/Display/vbox.c

    r22440 r22448  
    729729static DECLCALLBACK(void) vboxVHWACommandCompletionCallbackEvent(PPDEV ppdev, VBOXVHWACMD * pCmd, void * pContext)
    730730{
    731     PEVENT pEvent = (PEVENT)pContext;
    732     LONG oldState = EngSetEvent(pEvent);
     731    VBOXPEVENT pEvent = (VBOXPEVENT)pContext;
     732    LONG oldState = ppdev->VideoPortProcs.pfnSetEvent(ppdev->pVideoPortContext, pEvent);
    733733    Assert(!oldState);
    734734}
     
    783783}
    784784
    785 void vboxVHWACommandSubmitAsynchByEvent (PPDEV ppdev, VBOXVHWACMD* pCmd, PEVENT pEvent)
     785void vboxVHWACommandSubmitAsynchByEvent (PPDEV ppdev, VBOXVHWACMD* pCmd, VBOXPEVENT pEvent)
    786786{
    787787//    Assert(0);
     
    798798    {
    799799        /* the command is completed */
    800         EngSetEvent(pEvent);
     800        ppdev->VideoPortProcs.pfnSetEvent(ppdev->pVideoPortContext, pEvent);
    801801    }
    802802
     
    806806BOOL vboxVHWACommandSubmit (PPDEV ppdev, VBOXVHWACMD* pCmd)
    807807{
    808     PEVENT pEvent;
    809     BOOL brc = EngCreateEvent(&pEvent);
    810     Assert(brc);
    811 
    812     if(brc)
     808    VBOXPEVENT pEvent;
     809    VBOXVP_STATUS rc = ppdev->VideoPortProcs.pfnCreateEvent(ppdev->pVideoPortContext, VBOXNOTIFICATION_EVENT, NULL, &pEvent);
     810    Assert(rc == VBOXNO_ERROR);
     811
     812    if(rc == VBOXNO_ERROR)
    813813    {
    814814        pCmd->Flags |= VBOXVHWACMD_FLAG_GH_ASYNCH_IRQ;
    815815        vboxVHWACommandSubmitAsynchByEvent (ppdev, pCmd, pEvent);
    816816
    817         brc = EngWaitForSingleObject(pEvent,
     817        rc = ppdev->VideoPortProcs.pfnWaitForSingleObject(ppdev->pVideoPortContext, pEvent,
    818818                NULL /*IN PLARGE_INTEGER  pTimeOut*/
    819819                );
    820         Assert(brc);
    821         if(brc)
    822         {
    823             EngDeleteEvent(pEvent);
    824         }
    825     }
    826     return brc;
     820        Assert(rc == VBOXNO_ERROR);
     821        if(rc == VBOXNO_ERROR)
     822        {
     823            ppdev->VideoPortProcs.pfnDeleteEvent(ppdev->pVideoPortContext, pEvent);
     824        }
     825    }
     826    return rc == VBOXNO_ERROR;
    827827}
    828828
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp

    r22446 r22448  
    11581158
    11591159#ifdef VBOX_WITH_HGSMI
    1160    VideoPortCreateSpinLock(HwDeviceExtension, &((PDEVICE_EXTENSION)HwDeviceExtension)->u.primary.pGHRWLock);
     1160   VBoxSetupVideoPortFunctions((PDEVICE_EXTENSION)HwDeviceExtension, &((PDEVICE_EXTENSION)HwDeviceExtension)->u.primary.VideoPortProcs, ConfigInfo);
     1161   ((PDEVICE_EXTENSION)HwDeviceExtension)->u.primary.VideoPortProcs.pfnCreateSpinLock(HwDeviceExtension, &((PDEVICE_EXTENSION)HwDeviceExtension)->u.primary.pGHRWLock);
    11611162#endif
    11621163
     
    19981999            break;
    19992000        }
     2001        case IOCTL_VIDEO_HGSMI_QUERY_PORTPROCS:
     2002        {
     2003            dprintf(("VBoxVideo::VBoxVideoStartIO: IOCTL_VIDEO_HGSMI_QUERY_PORTPROCS\n"));
     2004
     2005            if (RequestPacket->OutputBufferLength < sizeof(HGSMIQUERYCPORTPROCS))
     2006            {
     2007                dprintf(("VBoxVideo::VBoxVideoStartIO: Output buffer too small: %d needed: %d!!!\n",
     2008                         RequestPacket->OutputBufferLength, sizeof(HGSMIQUERYCPORTPROCS)));
     2009                RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER;
     2010                return FALSE;
     2011            }
     2012
     2013            if (!pDevExt->pPrimary->u.primary.bHGSMI)
     2014            {
     2015                RequestPacket->StatusBlock->Status = ERROR_INVALID_FUNCTION;
     2016                return FALSE;
     2017            }
     2018
     2019            HGSMIQUERYCPORTPROCS *pInfo = (HGSMIQUERYCPORTPROCS *)RequestPacket->OutputBuffer;
     2020            pInfo->pContext = pDevExt->pPrimary;
     2021            pInfo->VideoPortProcs = pDevExt->pPrimary->u.primary.VideoPortProcs;
     2022
     2023            RequestPacket->StatusBlock->Information = sizeof(HGSMIQUERYCPORTPROCS);
     2024            Result = TRUE;
     2025            break;
     2026        }
    20002027        case IOCTL_VIDEO_HGSMI_HANDLER_ENABLE:
    20012028        {
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h

    r22446 r22448  
    4040RT_C_DECLS_END
    4141
    42 
    4342#define VBE_DISPI_IOPORT_INDEX          0x01CE
    4443#define VBE_DISPI_IOPORT_DATA           0x01CF
     
    151150           /* The IO Port Number for guest commands. */
    152151           RTIOPORT IOPortGuest;
     152
     153           /* Video Port API dynamically picked up at runtime for binary backwards compatibility with older NT versions */
     154           VBOXVIDEOPORTPROCS VideoPortProcs;
    153155#endif /* VBOX_WITH_HGSMI */
    154156       } primary;
     
    296298{
    297299    UCHAR oldIrql;
    298     VideoPortAcquireSpinLock(PrimaryExtension,
     300    PrimaryExtension->u.primary.VideoPortProcs.pfnAcquireSpinLock(PrimaryExtension,
    299301                PrimaryExtension->u.primary.pGHRWLock,
    300302            &oldIrql);
    301303    VBoxVideoVBEWriteUlongLocked(dataType, data);
    302     VideoPortReleaseSpinLock(PrimaryExtension,
     304    PrimaryExtension->u.primary.VideoPortProcs.pfnReleaseSpinLock(PrimaryExtension,
    303305                PrimaryExtension->u.primary.pGHRWLock,
    304306            oldIrql);
     
    308310{
    309311    UCHAR oldIrql;
    310     VideoPortAcquireSpinLock(PrimaryExtension,
     312    PrimaryExtension->u.primary.VideoPortProcs.pfnAcquireSpinLock(PrimaryExtension,
    311313                PrimaryExtension->u.primary.pGHRWLock,
    312314            &oldIrql);
    313315    VBoxVideoVBEWriteUshortLocked(dataType, data);
    314     VideoPortReleaseSpinLock(PrimaryExtension,
     316    PrimaryExtension->u.primary.VideoPortProcs.pfnReleaseSpinLock(PrimaryExtension,
    315317                PrimaryExtension->u.primary.pGHRWLock,
    316318            oldIrql);
     
    321323    ULONG data;
    322324    UCHAR oldIrql;
    323     VideoPortAcquireSpinLock(PrimaryExtension,
     325    PrimaryExtension->u.primary.VideoPortProcs.pfnAcquireSpinLock(PrimaryExtension,
    324326                PrimaryExtension->u.primary.pGHRWLock,
    325327            &oldIrql);
    326328    data = VBoxVideoVBEReadUlongLocked(dataType);
    327     VideoPortReleaseSpinLock(PrimaryExtension,
     329    PrimaryExtension->u.primary.VideoPortProcs.pfnReleaseSpinLock(PrimaryExtension,
    328330                PrimaryExtension->u.primary.pGHRWLock,
    329331            oldIrql);
     
    355357
    356358BOOLEAN VBoxHGSMIIsSupported (PDEVICE_EXTENSION PrimaryExtension);
     359
     360void VBoxSetupVideoPortFunctions(PDEVICE_EXTENSION PrimaryExtension,
     361                                VBOXVIDEOPORTPROCS *pCallbacks,
     362                                PVIDEO_PORT_CONFIG_INFO pConfigInfo);
    357363
    358364VOID VBoxSetupDisplaysHGSMI (PDEVICE_EXTENSION PrimaryExtension,
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/vboxioctl.h

    r22136 r22448  
    6060#define IOCTL_VIDEO_HGSMI_HANDLER_DISABLE \
    6161    CTL_CODE(FILE_DEVICE_VIDEO, 0x433, METHOD_BUFFERED, FILE_ANY_ACCESS)
     62
     63#define IOCTL_VIDEO_HGSMI_QUERY_PORTPROCS \
     64    CTL_CODE(FILE_DEVICE_VIDEO, 0x434, METHOD_BUFFERED, FILE_ANY_ACCESS)
    6265
    6366#endif /* VBOX_WITH_HGSMI */
     
    136139
    137140/**
     141 * Data returned by IOCTL_VIDEO_HGSMI_QUERY_PORTPROCS
     142 */
     143typedef struct _HGSMIQUERYCPORTPROCS
     144{
     145    PVOID pContext;
     146    VBOXVIDEOPORTPROCS VideoPortProcs;
     147} HGSMIQUERYCPORTPROCS;
     148
     149/**
    138150 * Data returned by IOCTL_VIDEO_HGSMI_HANDLER_ENABLE.
    139151 *
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