VirtualBox

Changeset 26556 in vbox


Ignore:
Timestamp:
Feb 15, 2010 10:10:11 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
57735
Message:

wddm: more impl

Location:
trunk
Files:
4 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/HGSMI/HGSMI.h

    r25062 r26556  
    258258void HGSMIAreaClear (HGSMIAREA *pArea);
    259259
     260DECLINLINE(bool) HGSMIAreaContainsOffset(HGSMIAREA *pArea, HGSMIOFFSET offSet)
     261{
     262    return pArea->offBase <= offSet && pArea->offBase + pArea->cbArea < offSet;
     263}
     264
    260265HGSMIOFFSET HGSMIBufferInitializeSingle (const HGSMIAREA *pArea,
    261266                                         HGSMIBUFFERHEADER *pHeader,
  • trunk/include/VBox/HGSMI/HGSMIChSetup.h

    r22652 r26556  
    5050#define HGSMIHOSTFLAGS_COMMANDS_PENDING 0x1
    5151#define HGSMIHOSTFLAGS_IRQ              0x2
     52#ifdef VBOXVDMA
     53/* one or more guest commands is completed */
     54# define HGSMIHOSTFLAGS_GCOMMAND_COMPLETED 0x4
     55#endif
    5256
    5357typedef struct _HGSMIHOSTFLAGS
  • trunk/include/VBox/VBoxVideo.h

    r26296 r26556  
    797797# define VBVA_VHWA_CMD    9
    798798#endif /* # ifdef VBOX_WITH_VIDEOHWACCEL */
     799#ifdef VBOXVDMA
     800# define VBVA_VDMA_CTL   10 /* setup G<->H DMA channel info */
     801# define VBVA_VDMA_CMD    11 /* G->H DMA command             */
     802#endif
    799803
    800804/* host->guest commands */
    801 # define VBVAHG_EVENT 1
    802 # define VBVAHG_DISPLAY_CUSTOM 2
     805# define VBVAHG_EVENT              1
     806# define VBVAHG_DISPLAY_CUSTOM     2
     807#ifdef VBOXVDMA
     808# define VBVAHG_SHGSMI_COMPLETION  3
     809#endif
    803810
    804811# ifdef VBOX_WITH_VIDEOHWACCEL
     
    988995#endif /* VBOX_WITH_HGSMI */
    989996
     997#ifdef VBOXVDMA
     998# pragma pack(1)
     999
     1000/*
     1001 * VBOXSHGSMI made on top HGSMI and allows receiving notifications
     1002 * about G->H command completion
     1003 */
     1004/* SHGSMI command header */
     1005typedef struct VBOXSHGSMIHEADER
     1006{
     1007    uint64_t pvNext;    /*<- completion processing queue */
     1008    uint32_t fFlags;    /*<- see VBOXSHGSMI_FLAG_XXX Flags */
     1009    uint32_t cRefs;     /*<- command referece count */
     1010    uint64_t u64Info1;  /*<- contents depends on the fFlags value */
     1011    uint64_t u64Info2;  /*<- contents depends on the fFlags value */
     1012} VBOXSHGSMIHEADER, *PVBOXSHGSMIHEADER;
     1013
     1014/* the command processing was asynch, set by the host to indicate asynch command completion
     1015 * must not be cleared once set, the command completion is performed by issuing a host->guest completion command
     1016 * while keeping this flag unchanged */
     1017#define VBOXSHGSMI_FLAG_HG_ASYNCH               0x00010000
     1018///* if set     - asynch completion is performed by issuing the event,
     1019// * if cleared - asynch completion is performed by calling a callback */
     1020//#define VBOXSHGSMI_FLAG_GH_ASYNCH_EVENT         0x00000001
     1021/* issue interrupt on asynch completion, used for critical G->H commands,
     1022 * i.e. for completion of which guest is waiting. */
     1023#define VBOXSHGSMI_FLAG_GH_ASYNCH_IRQ           0x00000002
     1024/* guest does not do any op on completion of this command,
     1025 * the host may copy the command and indicate that it does not need the command anymore
     1026 * by not setting VBOXSHGSMI_FLAG_HG_ASYNCH */
     1027#define VBOXSHGSMI_FLAG_GH_ASYNCH_NOCOMPLETION  0x00000004
     1028/* guest requires the command to be processed asynchronously,
     1029 * not setting VBOXSHGSMI_FLAG_HG_ASYNCH by the host in this case is treated as command failure */
     1030#define VBOXSHGSMI_FLAG_GH_ASYNCH_FORCE         0x00000008
     1031/* force IRQ on cmd completion */
     1032#define VBOXSHGSMI_FLAG_GH_ASYNCH_IRQ_FORCE     0x00000010
     1033/* an IRQ-level callback is associated with the command */
     1034#define VBOXSHGSMI_FLAG_GH_ASYNCH_CALLBACK_IRQ  0x00000020
     1035/* guest expects this command to be completed synchronously */
     1036#define VBOXSHGSMI_FLAG_GH_SYNCH                0x00000040
     1037
     1038/* VDMA - Video DMA */
     1039
     1040/* VDMA Control API */
     1041/* VBOXVDMA_CTL::u32Flags */
     1042#define VBOXVDMA_CTL_NONE    0x00000000
     1043#define VBOXVDMA_CTL_ENABLE  0x00000001
     1044#define VBOXVDMA_CTL_DISABLE 0x00000002
     1045#define VBOXVDMA_CTL_FLUSH   0x00000004
     1046
     1047typedef struct VBOXVDMA_CTL
     1048{
     1049    uint32_t u32Flags;
     1050    uint32_t u32Offset;
     1051    int32_t  i32Result;
     1052} VBOXVDMA_CTL, *PVBOXVDMA_CTL;
     1053
     1054typedef struct VBOXVDMA_RECTL
     1055{
     1056    int16_t left;
     1057    int16_t top;
     1058    uint16_t width;
     1059    uint16_t height;
     1060} VBOXVDMA_RECTL, *PVBOXVDMA_RECTL;
     1061
     1062//typedef uint64_t VBOXVDMAPHADDRESS;
     1063typedef uint64_t VBOXVDMASURFHANDLE;
     1064
     1065typedef enum
     1066{
     1067    VBOXVDMACMD_TYPE_UNDEFINED        = 0,
     1068    VBOXVDMACMD_TYPE_DMATRANSFER      = 1
     1069} VBOXVDMACMD_TYPE;
     1070
     1071/* region specified as a rectangle, otherwize it is a size of memory pointed to by phys address */
     1072#define VBOXVDMAOPERAND_FLAGS_RECTL       0x1
     1073/* Surface handle is valid */
     1074#define VBOXVDMAOPERAND_FLAGS_PRIMARY        0x2
     1075/* address is offset in VRAM */
     1076#define VBOXVDMAOPERAND_FLAGS_VRAMOFFSET  0x4
     1077
     1078typedef struct VBOXVDMA_RANGE_RECTL
     1079{
     1080    VBOXVDMA_RECTL RangeRectl;
     1081    VBOXVDMA_RECTL SurfSize;
     1082}VBOXVDMA_RANGE_RECTL, *PVBOXVDMA_RANGE_RECTL;
     1083
     1084typedef struct VBOXVDMA_RANGE_SIZE
     1085{
     1086    uint32_t cbSize;
     1087    uint32_t u32Reserved;
     1088}VBOXVDMA_RANGE_SIZE, *PVBOXVDMA_RANGE_SIZE;
     1089
     1090typedef struct VBOXVDMAOPERAND
     1091{
     1092    uint32_t fFlags;
     1093    union
     1094    {
     1095        /* for Src specifies num of Dsts */
     1096        uint32_t cDsts;
     1097        /* for Dst specifies Screen ID in case VBOXVDMAOPERAND_FLAGS_PRIMARY flag is present in fFlags */
     1098        uint32_t iScreen;
     1099    } Info;
     1100    RTGCPHYS phAddress;
     1101    union
     1102    {
     1103        VBOXVDMA_RANGE_RECTL Rectl;
     1104        VBOXVDMA_RANGE_SIZE  Size;
     1105    } Range;
     1106} VBOXVDMAOPERAND, *PVBOXVDMAOPERAND;
     1107
     1108/* VBOXVDMACBUF_DR::phBuf specifies offset in VRAM */
     1109#define VBOXVDMACBUF_FLAG_BUF_VRAM_OFFSET 0x00000001
     1110/* command buffer follows the VBOXVDMACBUF_DR in VRAM, VBOXVDMACBUF_DR::phBuf is ignored */
     1111#define VBOXVDMACBUF_FLAG_BUF_FOLLOWS_DR  0x00000002
     1112
     1113/*
     1114 * We can not submit the DMA command via VRAM since we do not have control over
     1115 * DMA command buffer [de]allocation, i.e. we only control the buffer contents.
     1116 * In other words the system may call one of our callbacks to fill a command buffer
     1117 * with the necessary commands and then discard the buffer w/o any notification.
     1118 *
     1119 * We have only DMA command buffer physical address at submission time.
     1120 *
     1121 * so the only way is to */
     1122typedef struct VBOXVDMACBUF_DR
     1123{
     1124    uint32_t fFlags;
     1125    uint32_t cbBuf;
     1126    uint32_t u32FenceId;
     1127    /* RT_SUCCESS()     - on success
     1128     * VERR_INTERRUPTED - on preemption
     1129     * VERR_xxx         - on error */
     1130    int32_t  rc;
     1131    uint64_t phBuf;
     1132} VBOXVDMACBUF_DR, *PVBOXVDMACBUF_DR;
     1133
     1134#define VBOXVDMACBUF_DR_TAIL(_pCmd, _t) ( (_t)(((uint8_t*)(_pCmd)) + sizeof (VBOXVDMACBUF_DR)) )
     1135
     1136typedef struct VBOXVDMACMD
     1137{
     1138    VBOXVDMACMD_TYPE enmType;
     1139    uint32_t cbCmd;
     1140} VBOXVDMACMD, *PVBOXVDMACMD;
     1141
     1142#define VBOXVDMACMD_HEADER_SIZE() sizeof (VBOXVDMACMD)
     1143#define VBOXVDMACMD_BODY_SIZE(_pCmd) ((_pCmd)->cbBody)
     1144#define VBOXVDMACMD_SIZE(_pCmd) (VBOXVDMACMD_HEADER_SIZE() + VBOXVDMACMD_BODY_SIZE(_pCmd))
     1145#define VBOXVDMACMD_BODY(_pCmd, _t) ( (_t)(((uint8_t*)(_pCmd)) + VBOXVDMACMD_HEADER_SIZE()) )
     1146
     1147typedef struct VBOXVDMACMD_DMATRANSFER
     1148{
     1149    VBOXVDMAOPERAND Src;
     1150    /* the size of aDst is specified in Src::u32CmdSpecific*/
     1151    VBOXVDMAOPERAND aDst[1];
     1152} VBOXVDMACMD_DMATRANSFER, *PVBOXVDMACMD_DMATRANSFER;
     1153# pragma pack()
     1154#endif /* #ifdef VBOXVDMA */
     1155
    9901156#endif
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/Makefile.kmk

    r26493 r26556  
    8282  VBoxVideoWddm_NOINST     = true
    8383 endif
     84 
    8485 VBoxVideoWddm_SDKS=WINDDKWLH
    8586 VBoxVideoWddm_DEFS       += LOG_TO_BACKDOOR VBOX_WITH_8BPP_MODES
    86  VBoxVideoWddm_DEFS       += VBOX_WITH_HGSMI VBOXWDDM
     87 VBoxVideoWddm_DEFS       += VBOX_WITH_HGSMI VBOXWDDM VBOXVDMA
    8788 ifdef VBOX_WITH_VIDEOHWACCEL
    8889  VBoxVideoWddm_DEFS      += VBOX_WITH_VIDEOHWACCEL
     
    9899        wddm/VBoxVideoWddm.cpp \
    99100        wddm/VBoxVideoVidPn.cpp \
     101        wddm/VBoxVideoVdma.cpp \
     102        wddm/VBoxVideoShgsmi.cpp \
    100103        wddm/VBoxVideoWddm.def \
    101104        wddm/VBoxVideoWddm.rc
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp

    r26493 r26556  
    263263
    264264    /* size of the VRAM in bytes */
     265
     266#ifndef VBOXWDDM
    265267    ULONG vramSize = DeviceExtension->pPrimary->u.primary.ulMaxFrameBufferSize;
    266 
    267     gNumVideoModes = 0;
    268 #ifdef VBOXWDDM
     268#else
     269    ULONG vramSize = vboxWddmVramReportedSize(DeviceExtension);
     270
    269271    gPreferredVideoMode = 0;
    270272#endif
     273
     274    gNumVideoModes = 0;
    271275
    272276    size_t numModesCurrentColorDepth;
     
    751755        || (gCustomXRes || gCustomYRes || gCustomBPP))
    752756    {
     757#ifndef VBOXWDDM
    753758        dprintf(("VBoxVideo: adding custom video mode as #%d, current mode: %d \n", gNumVideoModes + 1, DeviceExtension->CurrentMode));
    754759        /* handle the startup case */
    755760        if (DeviceExtension->CurrentMode == 0)
     761#else
     762        if (!DeviceExtension->cSources || !DeviceExtension->aSources[0].ulFrameBufferSize)
     763#endif
    756764        {
    757765            /* Use the stored custom resolution values only if nothing was read from host.
     
    771779        xres &= 0xfff8;
    772780        /* take the current values for the fields that are not set */
     781#ifndef VBOXWDDM
    773782        if (DeviceExtension->CurrentMode != 0)
    774783        {
     
    780789                bpp  = DeviceExtension->CurrentModeBPP;
    781790        }
     791#else
     792        if (DeviceExtension->cSources && DeviceExtension->aSources[0].ulFrameBufferSize)
     793        {
     794            if (!xres)
     795                xres = DeviceExtension->aSources[0].VisScreenWidth;
     796            if (!yres)
     797                yres = DeviceExtension->aSources[0].VisScreenHeight;
     798            if (!bpp)
     799                bpp  = DeviceExtension->aSources[0].BitsPerPlane;
     800        }
     801#endif
    782802
    783803        /* Use a default value. */
     
    801821            {
    802822                /* we need an alternating index */
     823#ifndef VBOXWDDM
    803824                if (DeviceExtension->CurrentMode != 0)
     825#else
     826                if (DeviceExtension->cSources && DeviceExtension->aSources[0].ulFrameBufferSize)
     827#endif
    804828                {
    805829                    if (gInvocationCounter % 2)
     
    877901
    878902                /* for the startup case, we need this mode twice due to the alternating mode number */
     903#ifndef VBOXWDDM
    879904                if (DeviceExtension->CurrentMode == 0)
     905#else
     906                if (!DeviceExtension->cSources || !DeviceExtension->aSources[0].ulFrameBufferSize)
     907#endif
    880908                {
    881909                    dprintf(("VBoxVideo: making a copy of the custom mode as #%d\n", gNumVideoModes + 1));
     
    918946    {
    919947        int i;
     948#ifndef VBOXWDDM
    920949        dprintf(("VBoxVideo: VideoModes (CurrentMode = %d)\n", DeviceExtension->CurrentMode));
     950#endif
    921951        for (i=0; i<MAX_VIDEO_MODES + 2; i++)
    922952        {
     
    965995}
    966996
    967 #endif
     997#else
    968998
    969999/* Computes the size of a framebuffer. DualView has a few framebuffers of the computed size. */
     
    10331063    }
    10341064}
     1065
     1066#endif
    10351067
    10361068int VBoxMapAdapterMemory (PDEVICE_EXTENSION PrimaryExtension, void **ppv, ULONG ulOffset, ULONG ulSize)
     
    10871119        VideoPortUnmapMemory(PrimaryExtension, *ppv, NULL);
    10881120#else
    1089         MmUnmapIoSpace(*ppv, ulSize);
     1121        NTSTATUS ntStatus = PrimaryExtension->u.primary.DxgkInterface.DxgkCbUnmapMemory(PrimaryExtension->u.primary.DxgkInterface.DeviceHandle,
     1122                *ppv);
     1123        Assert(ntStatus == STATUS_SUCCESS);
    10901124#endif
    10911125    }
     
    24302464}
    24312465
    2432 #ifndef VBOXWDDM
    2433 
    24342466/**
    24352467 * VBoxVideoSetCurrentMode
     
    24382470 */
    24392471BOOLEAN FASTCALL VBoxVideoSetCurrentMode(PDEVICE_EXTENSION DeviceExtension,
    2440                                          PVIDEO_MODE RequestedMode, PSTATUS_BLOCK StatusBlock)
    2441 {
     2472#ifndef VBOXWDDM
     2473                                         PVIDEO_MODE RequestedMode, PSTATUS_BLOCK StatusBlock
     2474#else
     2475                                         D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId,
     2476                                         PVBOXWDDM_SOURCE ModeInfo
     2477#endif
     2478                                         )
     2479{
     2480#ifndef VBOXWDDM
    24422481    PVIDEO_MODE_INFORMATION ModeInfo;
    24432482
     
    24592498        return TRUE;
    24602499    }
     2500#else
     2501    Assert(!srcId);
     2502
     2503    if (srcId)
     2504    {
     2505        dprintf(("VBoxVideo::VBoxVideoSetCurrentMode: Skipping for ? non-primary ? source ? %d\n",
     2506                srcId));
     2507        return TRUE;
     2508    }
     2509#endif
    24612510
    24622511    /* set the mode characteristics */
     
    24812530}
    24822531
     2532#ifndef VBOXWDDM
     2533
    24832534/*
    24842535 * VBoxVideoResetDevice
     
    26772728   return TRUE;
    26782729}
     2730
     2731#ifndef VBOXWDDM
    26792732
    26802733VP_STATUS VBoxVideoGetChildDescriptor(
     
    28702923    return rc;
    28712924}
     2925#endif
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h

    r26505 r26556  
    117117#else
    118118#include <VBox/VBoxVideo.h>
     119#include "wddm/VBoxVideoShgsmi.h"
     120#include "wddm/VBoxVideoVdma.h"
    119121
    120122typedef KSPIN_LOCK VBOXVCMNSPIN_LOCK, *PVBOXVCMNSPIN_LOCK;
     
    125127typedef HANDLE VBOXCMNREG;
    126128
    127 typedef enum
    128 {
    129     VBOXWDDM_CMD_UNEFINED = 0,
    130     VBOXWDDM_CMD_DMA_TRANSFER
    131 } VBOXWDDM_CMD_TYPE;
    132 
    133129typedef struct VBOXWDDM_SOURCE
    134130{
    135     HGSMIHEAP hgsmiDisplayHeap;
    136 //    VBVABUFFER *pVBVA; /* Pointer to the pjScreen + layout->offVBVABuffer. NULL if VBVA is not enabled. */
     131    ULONG VisScreenWidth;
     132    ULONG VisScreenHeight;
     133    ULONG BitsPerPlane;
     134
     135    ULONG ulFrameBufferOffset;                  /* The framebuffer position in the VRAM. */
     136    ULONG ulFrameBufferSize;                    /* The size of the current framebuffer. */
    137137} VBOXWDDM_SOURCE, *PVBOXWDDM_SOURCE;
    138138
     
    211211    DXGK_DEVICEINFO DeviceInfo;
    212212} VBOXWDDM_DEVICE, *PVBOXWDDM_DEVICE;
    213 
    214213#endif
    215214
     
    219218                                                * The primary extension is the first one.
    220219                                                */
    221 
     220#ifndef VBOXWDDM
    222221   struct _DEVICE_EXTENSION *pPrimary;         /* Pointer to the primary device extension. */
    223222
    224223   ULONG iDevice;                              /* Device index: 0 for primary, otherwise a secondary device. */
    225 
    226224
    227225   ULONG CurrentMode;                          /* Saved information about video modes */
     
    232230   ULONG ulFrameBufferOffset;                  /* The framebuffer position in the VRAM. */
    233231   ULONG ulFrameBufferSize;                    /* The size of the current framebuffer. */
    234 
     232#endif
    235233   union {
    236234       /* Information that is only relevant to the primary device or is the same for all devices. */
     
    258256                                                * This is mapped by miniport separately.
    259257                                                */
     258#ifdef VBOXWDDM
     259           VBOXVDMAINFO Vdma;
     260#endif
     261
    260262#ifdef VBOX_WITH_HGSMI
    261263           volatile HGSMIHOSTFLAGS * pHostFlags; /* HGSMI host flags */
     
    315317   PDEVICE_OBJECT pPDO;
    316318
     319   VBOXSHGSMILIST CtlList;
     320   VBOXSHGSMILIST DmaCmdList;
     321   BOOL bSetNotifyDxDpc;
     322   BOOL bNotifyDxDpc;
     323
    317324   ULONG cSources;
    318325   /* currently we define the array for the max possible size since we do not know
     
    326333} DEVICE_EXTENSION, *PDEVICE_EXTENSION;
    327334
     335#ifndef VBOXWDDM
    328336#define DEV_MOUSE_HIDDEN(dev) ((dev)->pPrimary->u.primary.fMouseHidden)
    329337#define DEV_SET_MOUSE_HIDDEN(dev)   \
     
    335343    (dev)->pPrimary->u.primary.fMouseHidden = FALSE; \
    336344} while (0)
    337 
     345#else
     346#define DEV_MOUSE_HIDDEN(dev) ((dev)->u.primary.fMouseHidden)
     347#define DEV_SET_MOUSE_HIDDEN(dev)   \
     348do { \
     349    (dev)->u.primary.fMouseHidden = TRUE; \
     350} while (0)
     351#define DEV_SET_MOUSE_SHOWN(dev)   \
     352do { \
     353    (dev)->u.primary.fMouseHidden = FALSE; \
     354} while (0)
     355#endif
    338356extern "C"
    339357{
     
    626644VOID VBoxWddmGetModesTable(PDEVICE_EXTENSION DeviceExtension, bool bRebuildTable,
    627645        VIDEO_MODE_INFORMATION ** ppModes, uint32_t * pcModes, uint32_t * pPreferrableMode,
    628         D3DKMDT_2DREGION **pResolutions, uint32_t * pcResolutions);
     646        D3DKMDT_2DREGION **ppResolutions, uint32_t * pcResolutions);
    629647
    630648D3DDDIFORMAT vboxWddmCalcPixelFormat(VIDEO_MODE_INFORMATION *pInfo);
    631649UINT vboxWddmCalcBitsPerPixel(D3DDDIFORMAT format);
     650
     651DECLINLINE(ULONG) vboxWddmVramReportedSize(PDEVICE_EXTENSION pDevExt)
     652{
     653    return pDevExt->u.primary.Vdma.CmdHeap.area.offBase;
     654}
    632655
    633656NTSTATUS vboxVidPnCheckTopology(const D3DKMDT_HVIDPN hDesiredVidPn,
     
    764787DECLINLINE(void) VBoxHGSMIHostWrite(PDEVICE_EXTENSION PrimaryExtension, ULONG data)
    765788{
     789#ifndef VBOXWDDM
    766790    VBoxVideoCmnPortWriteUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortHost, data);
     791#else
     792    VBoxVideoCmnPortWriteUlong((PULONG)PrimaryExtension->u.primary.IOPortHost, data);
     793#endif
    767794}
    768795
    769796DECLINLINE(ULONG) VBoxHGSMIHostRead(PDEVICE_EXTENSION PrimaryExtension)
    770797{
     798#ifndef VBOXWDDM
    771799    return VBoxVideoCmnPortReadUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortHost);
     800#else
     801    return VBoxVideoCmnPortReadUlong((PULONG)PrimaryExtension->u.primary.IOPortHost);
     802#endif
    772803}
    773804
    774805DECLINLINE(void) VBoxHGSMIGuestWrite(PDEVICE_EXTENSION PrimaryExtension, ULONG data)
    775806{
     807#ifndef VBOXWDDM
    776808    VBoxVideoCmnPortWriteUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortGuest, data);
     809#else
     810    VBoxVideoCmnPortWriteUlong((PULONG)PrimaryExtension->u.primary.IOPortGuest, data);
     811#endif
    777812}
    778813
    779814DECLINLINE(ULONG) VBoxHGSMIGuestRead(PDEVICE_EXTENSION PrimaryExtension)
    780815{
     816#ifndef VBOXWDDM
    781817    return VBoxVideoCmnPortReadUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortGuest);
     818#else
     819    return VBoxVideoCmnPortReadUlong((PULONG)PrimaryExtension->u.primary.IOPortGuest);
     820#endif
    782821}
    783822
     
    792831                                PVIDEO_POINTER_ATTRIBUTES pointerAttr,
    793832                                uint32_t cbLength);
     833#ifndef VBOXWDDM
    794834DECLCALLBACK(void) hgsmiHostCmdComplete (HVBOXVIDEOHGSMI hHGSMI, struct _VBVAHOSTCMD * pCmd);
    795835DECLCALLBACK(int) hgsmiHostCmdRequest (HVBOXVIDEOHGSMI hHGSMI, uint8_t u8Channel, struct _VBVAHOSTCMD ** ppCmd);
     836#endif
    796837
    797838
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideoHGSMI.cpp

    r26505 r26556  
    186186typedef FNHGSMICALLFINALIZE *PFNHGSMICALLFINALIZE;
    187187
     188void* VBoxHGSMIBufferAlloc (PDEVICE_EXTENSION PrimaryExtension,
     189                         HGSMISIZE cbData,
     190                         uint8_t u8Ch,
     191                         uint16_t u16Op)
     192{
     193#ifdef VBOXWDDM
     194    /* @todo: add synchronization */
     195#endif
     196    return HGSMIHeapAlloc (&PrimaryExtension->u.primary.hgsmiAdapterHeap, cbData, u8Ch, u16Op);
     197}
     198
     199void* VBoxHGSMIBufferAlloc (PDEVICE_EXTENSION PrimaryExtension,
     200                         uint8_t u8Ch,
     201                         uint16_t u16Op,
     202                         HGSMISIZE cbData)
     203{
     204#ifdef VBOXWDDM
     205    /* @todo: add synchronization */
     206#endif
     207    return HGSMIHeapAlloc (&PrimaryExtension->u.primary.hgsmiAdapterHeap, cbData, u8Ch, u16Op);
     208}
     209
     210void VBoxHGSMIBufferFree (PDEVICE_EXTENSION PrimaryExtension, void *pvBuffer)
     211{
     212#ifdef VBOXWDDM
     213    /* @todo: add synchronization */
     214#endif
     215    HGSMIHeapFree (&PrimaryExtension->u.primary.hgsmiAdapterHeap, pvBuffer);
     216}
     217
     218int VBoxHGSMIBufferSubmit (PDEVICE_EXTENSION PrimaryExtension, void *pvBuffer)
     219{
     220    /* Initialize the buffer and get the offset for port IO. */
     221    HGSMIOFFSET offBuffer = HGSMIHeapBufferOffset (&PrimaryExtension->u.primary.hgsmiAdapterHeap, pvBuffer);
     222
     223    Assert(offBuffer != HGSMIOFFSET_VOID);
     224    if (offBuffer != HGSMIOFFSET_VOID)
     225    {
     226        /* Submit the buffer to the host. */
     227        VBoxHGSMIGuestWrite(PrimaryExtension, offBuffer);
     228        return VINF_SUCCESS;
     229    }
     230
     231    return VERR_INVALID_PARAMETER;
     232}
     233
    188234static int vboxCallChannel (PDEVICE_EXTENSION PrimaryExtension,
    189235                         uint8_t u8Ch,
     
    197243
    198244    /* Allocate the IO buffer. */
     245#ifndef VBOXWDDM
    199246    if (PrimaryExtension->pPrimary != PrimaryExtension)
    200247    {
     
    202249        return VERR_INVALID_PARAMETER;
    203250    }
     251#endif
    204252
    205253    void *p = HGSMIHeapAlloc (&PrimaryExtension->u.primary.hgsmiAdapterHeap, cbData, u8Ch, u16Op);
     
    315363    return rc;
    316364}
    317 
     365#ifndef VBOXWDDM
    318366static int vbvaInitInfoDisplay (PDEVICE_EXTENSION PrimaryExtension, void *pvContext, void *pvData)
    319367{
     
    348396    return VERR_INTERNAL_ERROR;
    349397}
     398#endif
    350399
    351400static int vbvaInitInfoHeap (PDEVICE_EXTENSION PrimaryExtension, void *pvContext, void *pvData)
     
    389438    if(RT_SUCCESS (rc))
    390439    {
     440#ifndef VBOXWDDM
    391441        rc = vboxCallVBVA (PrimaryExtension,
    392442                               VBVA_INFO_VIEW,
     
    397447        AssertRC(rc);
    398448        if (RT_SUCCESS (rc))
     449#else
     450        /* in case of WDDM we do not control the framebuffer location,
     451         * i.e. it is assigned by Video Memory Manager,
     452         * The FB information should be passed to guest from our DxgkDdiSetVidPnSourceAddress callback */
     453#endif
    399454        {
    400455            /* Report the host heap location. */
     
    660715     */
    661716    PrimaryExtension->pNext                              = NULL;
     717#ifndef VBOXWDDM
    662718    PrimaryExtension->pPrimary                           = PrimaryExtension;
    663719    PrimaryExtension->iDevice                            = 0;
    664720    PrimaryExtension->ulFrameBufferOffset                = 0;
    665721    PrimaryExtension->ulFrameBufferSize                  = 0;
     722#endif
    666723    PrimaryExtension->u.primary.ulVbvaEnabled            = 0;
    667724    PrimaryExtension->u.primary.bVBoxVideoSupported      = FALSE;
     
    861918    }
    862919
     920#ifndef VBOXWDDM
    863921    /* Now when the number of monitors is known and extensions are created,
    864922     * calculate the layout of framebuffers.
    865923     */
    866924    VBoxComputeFrameBufferSizes (PrimaryExtension);
     925#endif
    867926
    868927    if (PrimaryExtension->u.primary.bHGSMI)
     
    876935        }
    877936    }
     937
     938#ifdef VBOXWDDM
     939    if (PrimaryExtension->u.primary.bHGSMI)
     940    {
     941        ULONG ulAvailable = PrimaryExtension->u.primary.cbVRAM
     942                            - PrimaryExtension->u.primary.cbMiniportHeap
     943                            - VBVA_ADAPTER_INFORMATION_SIZE;
     944
     945        /* use 25% od VRAM for DMA command buffer
     946         * @todo: ^^^? */
     947        ULONG ulSize = ulAvailable / 4;
     948
     949        /* Align down to 4096 bytes. */
     950        ulSize &= ~0xFFF;
     951        ULONG offset = ulAvailable - ulSize;
     952
     953        Assert(!(offset & 0xFFF));
     954
     955        rc = vboxVdmaCreate (PrimaryExtension, &PrimaryExtension->u.primary.Vdma, offset, ulSize);
     956        AssertRC(rc);
     957        if (RT_SUCCESS(rc))
     958        {
     959            /* can enable it right away since the host does not need any screen/FB info
     960             * for basic DMA functionality */
     961            rc = vboxVdmaEnable(PrimaryExtension, &PrimaryExtension->u.primary.Vdma);
     962            AssertRC(rc);
     963            if (RT_FAILURE(rc))
     964                vboxVdmaDestroy(PrimaryExtension, &PrimaryExtension->u.primary.Vdma);
     965        }
     966
     967        if (RT_FAILURE(rc))
     968            PrimaryExtension->u.primary.bHGSMI = FALSE;
     969    }
     970#endif
    878971
    879972    if (!PrimaryExtension->u.primary.bHGSMI)
     
    9531046                                uint32_t cbLength)
    9541047{
     1048#ifndef VBOXWDDM
    9551049    PDEVICE_EXTENSION PrimaryExtension = DeviceExtension->pPrimary;
    9561050
     
    9771071        return TRUE;
    9781072    }
     1073#else
     1074    PDEVICE_EXTENSION PrimaryExtension = DeviceExtension;
     1075#endif
    9791076
    9801077    uint32_t cbData = 0;
     
    11161213}
    11171214
     1215#ifndef VBOXWDDM
    11181216DECLCALLBACK(void) hgsmiHostCmdComplete (HVBOXVIDEOHGSMI hHGSMI, struct _VBVAHOSTCMD * pCmd)
    11191217{
     
    11641262    return VERR_INVALID_PARAMETER;
    11651263}
     1264#endif
    11661265
    11671266static DECLCALLBACK(int) vboxVBVAChannelGenericHandler(void *pvHandler, uint16_t u16ChannelInfo, void *pvBuffer, HGSMISIZE cbBuffer)
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVidPn.cpp

    r26324 r26556  
    508508    pNewVidPnTargetModeInfo->VideoSignalInfo.VSyncFreq.Numerator = 60000;
    509509    pNewVidPnTargetModeInfo->VideoSignalInfo.VSyncFreq.Denominator = 1000;
    510     pNewVidPnTargetModeInfo->VideoSignalInfo.HSyncFreq.Numerator = pNewVidPnTargetModeInfo->VideoSignalInfo.ActiveSize.cy * 60 * 1.05;
     510    pNewVidPnTargetModeInfo->VideoSignalInfo.HSyncFreq.Numerator = pNewVidPnTargetModeInfo->VideoSignalInfo.ActiveSize.cy * 63; /* 63 is (60 * 1.05)*/
    511511    pNewVidPnTargetModeInfo->VideoSignalInfo.HSyncFreq.Denominator = 1;
    512512    pNewVidPnTargetModeInfo->VideoSignalInfo.PixelRate = 165000; /* @todo: ? */
     
    543543                if (Status == STATUS_SUCCESS)
    544544                {
    545                     if (iPreferredMomde == i)
     545                    if (bPreferred)
    546546                    {
    547547                        Status = pNewVidPnTargetModeSetInterface->pfnPinMode(hNewVidPnTargetModeSet, modeId);
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp

    r26324 r26556  
    3939    ExFreePool(pvMem);
    4040}
     41
     42void vboxSHGSMICbCommandWrite(struct _HGSMIHEAP * pHeap, HGSMIOFFSET data)
     43{
     44    /* @todo: this should be taken from PDEVICE_EXTENSION */
     45    //VBoxHGSMIGuestWrite(pDevExt, data);
     46    VBoxVideoCmnPortWriteUlong((PULONG)VGA_PORT_HGSMI_GUEST, data);
     47}
     48
     49#if 0
     50void vboxWddmProcessDisplayInfo (PPDEV ppdev)
     51{
     52    if (ppdev->bHGSMISupported)
     53    {
     54        /* Issue the screen info command. */
     55        void *p = HGSMIHeapAlloc (&ppdev->hgsmiDisplayHeap,
     56                                  sizeof (VBVAINFOSCREEN),
     57                                  HGSMI_CH_VBVA,
     58                                  VBVA_INFO_SCREEN);
     59        if (!p)
     60        {
     61            DISPDBG((0, "VBoxDISP::VBoxProcessDisplayInfo: HGSMIHeapAlloc failed\n"));
     62        }
     63        else
     64        {
     65            VBVAINFOSCREEN *pScreen = (VBVAINFOSCREEN *)p;
     66
     67            pScreen->u32ViewIndex    = ppdev->iDevice;
     68            pScreen->i32OriginX      = ppdev->ptlDevOrg.x;
     69            pScreen->i32OriginY      = ppdev->ptlDevOrg.y;
     70            pScreen->u32StartOffset  = 0;
     71            pScreen->u32LineSize     = ppdev->lDeltaScreen > 0?ppdev->lDeltaScreen: -ppdev->lDeltaScreen;
     72            pScreen->u32Width        = ppdev->cxScreen;
     73            pScreen->u32Height       = ppdev->cyScreen;
     74            pScreen->u16BitsPerPixel = (uint16_t)ppdev->ulBitCount;
     75            pScreen->u16Flags        = VBVA_SCREEN_F_ACTIVE;
     76
     77            vboxHGSMIBufferSubmit (ppdev, p);
     78
     79            HGSMIHeapFree (&ppdev->hgsmiDisplayHeap, p);
     80        }
     81    }
     82
     83    return;
     84}
     85
     86NTSTATUS vboxWddmGhInitPrimary(PDEVICE_EXTENSION pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId, D3DKMDT_VIDPN_SOURCE_MODE *pVidPnSourceModeInfo)
     87{
     88    NTSTATUS Status;
     89    PVBOXWDDM_SOURCE pSourceInfo = &pDevExt->aSources[srcId];
     90    memset(pSourceInfo, 0, sizeof (VBOXWDDM_SOURCE));
     91    pSourceInfo->VisScreenWidth = pVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cx;
     92    pSourceInfo->VisScreenHeight = pVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cy;
     93    pSourceInfo->BitsPerPlane = vboxWddmCalcBitsPerPixel(pVidPnSourceModeInfo->Format.Graphics.PixelFormat);
     94    Assert(pSourceInfo->BitsPerPlane);
     95    if (pSourceInfo->BitsPerPlane)
     96    {
     97        /*
     98         * Set the current mode into the hardware.
     99         */
     100        if (VBoxVideoSetCurrentMode(pDevExt, srcId, pSourceInfo))
     101        {
     102
     103
     104        }
     105        else
     106        {
     107            AssertBreakpoint();
     108
     109        }
     110    }
     111    else
     112    {
     113        drprintf((__FUNCTION__":ERROR: failed to caltulate bpp from pixel format (%d)\n",
     114                pVidPnSourceModeInfo->Format.Graphics.PixelFormat));
     115        return STATUS_INVALID_PARAMETER;
     116    }
     117
     118    return Status;
     119
     120
     121
     122//    DWORD returnedDataLength;
     123//    DWORD MaxWidth, MaxHeight;
     124//    VIDEO_MEMORY videoMemory;
     125//    VIDEO_MEMORY_INFORMATION videoMemoryInformation;
     126//    ULONG RemappingNeeded = 0;
     127
     128
     129    /*
     130     * don't need to map anything here, we use one common HGSMI heap for all sources
     131     */
     132
     133    // If this is the first time we enable the surface we need to map in the
     134    // memory also.
     135    //
     136
     137    if (bFirst || RemappingNeeded)
     138    {
     139//        videoMemory.RequestedVirtualAddress = NULL;
     140//
     141//        if (EngDeviceIoControl(ppdev->hDriver,
     142//                               IOCTL_VIDEO_MAP_VIDEO_MEMORY,
     143//                               &videoMemory,
     144//                               sizeof(VIDEO_MEMORY),
     145//                               &videoMemoryInformation,
     146//                               sizeof(VIDEO_MEMORY_INFORMATION),
     147//                               &returnedDataLength))
     148//        {
     149//            DISPDBG((1, "DISP bInitSURF failed IOCTL_VIDEO_MAP\n"));
     150//            return(FALSE);
     151//        }
     152//
     153//        ppdev->pjScreen = (PBYTE)(videoMemoryInformation.FrameBufferBase);
     154//
     155//        if (videoMemoryInformation.FrameBufferBase !=
     156//            videoMemoryInformation.VideoRamBase)
     157//        {
     158//            DISPDBG((0, "VideoRamBase does not correspond to FrameBufferBase\n"));
     159//        }
     160//
     161//        //
     162//        // Make sure we can access this video memory
     163//        //
     164//
     165//        *(PULONG)(ppdev->pjScreen) = 0xaa55aa55;
     166//
     167//        if (*(PULONG)(ppdev->pjScreen) != 0xaa55aa55) {
     168//
     169//            DISPDBG((1, "Frame buffer memory is not accessible.\n"));
     170//            return(FALSE);
     171//        }
     172//
     173//        /* Clear VRAM to avoid distortions during the video mode change. */
     174//        RtlZeroMemory(ppdev->pjScreen,
     175//                      ppdev->cyScreen * (ppdev->lDeltaScreen > 0? ppdev->lDeltaScreen: -ppdev->lDeltaScreen));
     176//
     177//        //
     178//        // Initialize the head of the offscreen list to NULL.
     179//        //
     180//
     181//        ppdev->pOffscreenList = NULL;
     182//
     183//        // It's a hardware pointer; set up pointer attributes.
     184//
     185//        MaxHeight = ppdev->PointerCapabilities.MaxHeight;
     186//
     187//        // Allocate space for two DIBs (data/mask) for the pointer. If this
     188//        // device supports a color Pointer, we will allocate a larger bitmap.
     189//        // If this is a color bitmap we allocate for the largest possible
     190//        // bitmap because we have no idea of what the pixel depth might be.
     191//
     192//        // Width rounded up to nearest byte multiple
     193//
     194//        if (!(ppdev->PointerCapabilities.Flags & VIDEO_MODE_COLOR_POINTER))
     195//        {
     196//            MaxWidth = (ppdev->PointerCapabilities.MaxWidth + 7) / 8;
     197//        }
     198//        else
     199//        {
     200//            MaxWidth = ppdev->PointerCapabilities.MaxWidth * sizeof(DWORD);
     201//        }
     202//
     203//        ppdev->cjPointerAttributes =
     204//                sizeof(VIDEO_POINTER_ATTRIBUTES) +
     205//                ((sizeof(UCHAR) * MaxWidth * MaxHeight) * 2);
     206//
     207//        ppdev->pPointerAttributes = (PVIDEO_POINTER_ATTRIBUTES)
     208//                EngAllocMem(0, ppdev->cjPointerAttributes, ALLOC_TAG);
     209//
     210//        if (ppdev->pPointerAttributes == NULL) {
     211//
     212//            DISPDBG((0, "bInitPointer EngAllocMem failed\n"));
     213//            return(FALSE);
     214//        }
     215//
     216//        ppdev->pPointerAttributes->Flags = ppdev->PointerCapabilities.Flags;
     217//        ppdev->pPointerAttributes->WidthInBytes = MaxWidth;
     218//        ppdev->pPointerAttributes->Width = ppdev->PointerCapabilities.MaxWidth;
     219//        ppdev->pPointerAttributes->Height = MaxHeight;
     220//        ppdev->pPointerAttributes->Column = 0;
     221//        ppdev->pPointerAttributes->Row = 0;
     222//        ppdev->pPointerAttributes->Enable = 0;
     223
     224        vboxInitVBoxVideo (ppdev, &videoMemoryInformation);
     225
     226#ifndef VBOX_WITH_HGSMI
     227        if (ppdev->bVBoxVideoSupported)
     228        {
     229            /* Setup the display information. */
     230            vboxSetupDisplayInfo (ppdev, &videoMemoryInformation);
     231        }
     232#endif /* !VBOX_WITH_HGSMI */
     233    }
     234
     235
     236    DISPDBG((1, "DISP bInitSURF: ppdev->ulBitCount %d\n", ppdev->ulBitCount));
     237
     238    if (   ppdev->ulBitCount == 16
     239        || ppdev->ulBitCount == 24
     240        || ppdev->ulBitCount == 32)
     241    {
     242#ifndef VBOX_WITH_HGSMI
     243        if (ppdev->pInfo) /* Do not use VBVA on old hosts. */
     244        {
     245            /* Enable VBVA for this video mode. */
     246            vboxVbvaEnable (ppdev);
     247        }
     248#else
     249        if (ppdev->bHGSMISupported)
     250        {
     251            /* Enable VBVA for this video mode. */
     252            ppdev->bHGSMISupported = vboxVbvaEnable (ppdev);
     253            LogRel(("VBoxDisp[%d]: VBVA %senabled\n", ppdev->iDevice, ppdev->bHGSMISupported? "": "not "));
     254        }
     255#endif /* VBOX_WITH_HGSMI */
     256    }
     257
     258    DISPDBG((1, "DISP bInitSURF success\n"));
     259
     260#ifndef VBOX_WITH_HGSMI
     261    /* Update the display information. */
     262    vboxUpdateDisplayInfo (ppdev);
     263#else
     264    /* Inform the host about this screen layout. */
     265    DISPDBG((1, "bInitSURF: %d,%d\n", ppdev->ptlDevOrg.x, ppdev->ptlDevOrg.y));
     266    VBoxProcessDisplayInfo (ppdev);
     267#endif /* VBOX_WITH_HGSMI */
     268
     269#ifdef VBOX_WITH_VIDEOHWACCEL
     270    /* tells we can process host commands */
     271    vboxVHWAEnable(ppdev);
     272#endif
     273
     274    return(TRUE);
     275}
     276#endif
     277
     278HGSMIHEAP* vboxWddmHgsmiGetHeapFromCmdOffset(PDEVICE_EXTENSION pDevExt, HGSMIOFFSET offCmd)
     279{
     280    if(HGSMIAreaContainsOffset(&pDevExt->u.primary.Vdma.CmdHeap.area, offCmd))
     281        return &pDevExt->u.primary.Vdma.CmdHeap;
     282    if (HGSMIAreaContainsOffset(&pDevExt->u.primary.hgsmiAdapterHeap.area, offCmd))
     283        return &pDevExt->u.primary.hgsmiAdapterHeap;
     284    return NULL;
     285}
     286
     287typedef enum
     288{
     289    VBOXWDDM_HGSMICMD_TYPE_UNDEFINED = 0,
     290    VBOXWDDM_HGSMICMD_TYPE_CTL       = 1,
     291    VBOXWDDM_HGSMICMD_TYPE_DMACMD    = 2
     292} VBOXWDDM_HGSMICMD_TYPE;
     293
     294VBOXWDDM_HGSMICMD_TYPE vboxWddmHgsmiGetCmdTypeFromOffset(PDEVICE_EXTENSION pDevExt, HGSMIOFFSET offCmd)
     295{
     296    if(HGSMIAreaContainsOffset(&pDevExt->u.primary.Vdma.CmdHeap.area, offCmd))
     297        return VBOXWDDM_HGSMICMD_TYPE_DMACMD;
     298    if (HGSMIAreaContainsOffset(&pDevExt->u.primary.hgsmiAdapterHeap.area, offCmd))
     299        return VBOXWDDM_HGSMICMD_TYPE_CTL;
     300    return VBOXWDDM_HGSMICMD_TYPE_UNDEFINED;
     301}
     302
    41303
    42304#define VBOXWDDM_REG_DRVKEY_PREFIX L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Class\\"
     
    491753    )
    492754{
    493     return false;
     755    PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)MiniportDeviceContext;
     756    BOOLEAN bOur = FALSE;
     757    if (pDevExt->u.primary.pHostFlags) /* If HGSMI is enabled at all. */
     758    {
     759        VBOXSHGSMILIST CtlList;
     760        VBOXSHGSMILIST DmaCmdList;
     761        vboxSHGSMIListInit(&CtlList);
     762        vboxSHGSMIListInit(&DmaCmdList);
     763        do
     764        {
     765            uint32_t flags = pDevExt->u.primary.pHostFlags->u32HostFlags;
     766            if (flags & HGSMIHOSTFLAGS_GCOMMAND_COMPLETED)
     767            {
     768                bOur = TRUE;
     769                /* read the command offset */
     770                HGSMIOFFSET offCmd = VBoxHGSMIGuestRead(pDevExt);
     771                Assert(offCmd != HGSMIOFFSET_VOID);
     772                if (offCmd != HGSMIOFFSET_VOID)
     773                {
     774                    VBOXWDDM_HGSMICMD_TYPE enmType = vboxWddmHgsmiGetCmdTypeFromOffset(pDevExt, offCmd);
     775                    PVBOXSHGSMILIST pList;
     776                    HGSMIHEAP * pHeap = NULL;
     777                    switch (enmType)
     778                    {
     779                        case VBOXWDDM_HGSMICMD_TYPE_DMACMD:
     780                            pList = &DmaCmdList;
     781                            pHeap = &pDevExt->u.primary.Vdma.CmdHeap;
     782                            break;
     783                        case VBOXWDDM_HGSMICMD_TYPE_CTL:
     784                            pList = &CtlList;
     785                            pHeap = &pDevExt->u.primary.hgsmiAdapterHeap;
     786                            break;
     787                        default:
     788                            AssertBreakpoint();
     789                    }
     790
     791                    if (pHeap)
     792                    {
     793                        int rc = VBoxSHGSMICommandProcessCompletion (pHeap, offCmd, TRUE /*bool bIrq*/ , pList);
     794                        AssertRC(rc);
     795                    }
     796                }
     797            }
     798            else if (flags & HGSMIHOSTFLAGS_COMMANDS_PENDING)
     799            {
     800                bOur = TRUE;
     801                AssertBreakpoint();
     802                /* @todo: FIXME: implement !!! */
     803            }
     804            else if (flags & HGSMIHOSTFLAGS_IRQ)
     805            {
     806                bOur = TRUE;
     807                AssertBreakpoint();
     808                /* unknown command */
     809            }
     810            else
     811                break;
     812        } while (1);
     813
     814        if (!vboxSHGSMIListIsEmpty(&CtlList))
     815            vboxSHGSMIListCat(&pDevExt->CtlList, &CtlList);
     816
     817        if (!vboxSHGSMIListIsEmpty(&DmaCmdList))
     818            vboxSHGSMIListCat(&pDevExt->DmaCmdList, &DmaCmdList);
     819
     820        if (pDevExt->bSetNotifyDxDpc)
     821        {
     822            pDevExt->bNotifyDxDpc = TRUE;
     823            pDevExt->bSetNotifyDxDpc = FALSE;
     824        }
     825
     826        if (bOur)
     827            HGSMIClearIrq (pDevExt);
     828    }
     829
     830    return bOur;
     831}
     832
     833
     834typedef struct VBOXWDDM_DPCDATA
     835{
     836    VBOXSHGSMILIST CtlList;
     837    VBOXSHGSMILIST DmaCmdList;
     838    BOOL bNotifyDpc;
     839} VBOXWDDM_DPCDATA, *PVBOXWDDM_DPCDATA;
     840
     841typedef struct VBOXWDDM_GETDPCDATA_CONTEXT
     842{
     843    PDEVICE_EXTENSION pDevExt;
     844    VBOXWDDM_DPCDATA data;
     845} VBOXWDDM_GETDPCDATA_CONTEXT, *PVBOXWDDM_GETDPCDATA_CONTEXT;
     846
     847BOOLEAN vboxWddmGetDPCDataCallback(PVOID Context)
     848{
     849    PVBOXWDDM_GETDPCDATA_CONTEXT pdc = (PVBOXWDDM_GETDPCDATA_CONTEXT)Context;
     850
     851    vboxSHGSMICmdListDetach2List(&pdc->pDevExt->CtlList, &pdc->data.CtlList);
     852    vboxSHGSMICmdListDetach2List(&pdc->pDevExt->DmaCmdList, &pdc->data.DmaCmdList);
     853    pdc->data.bNotifyDpc = pdc->pDevExt->bNotifyDxDpc;
     854    pdc->pDevExt->bNotifyDxDpc = FALSE;
     855    return TRUE;
    494856}
    495857
     
    498860    )
    499861{
    500 
     862    PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)MiniportDeviceContext;
     863
     864    VBOXWDDM_DPCDATA dpcData = {0};
     865    BOOLEAN bRet;
     866
     867    /* get DPC data at IRQL */
     868    NTSTATUS Status = pDevExt->u.primary.DxgkInterface.DxgkCbSynchronizeExecution(
     869            pDevExt->u.primary.DxgkInterface.DeviceHandle,
     870            vboxWddmGetDPCDataCallback,
     871            &dpcData,
     872            0,
     873            &bRet);
     874    Assert(Status == STATUS_SUCCESS);
     875
     876    if (!vboxSHGSMIListIsEmpty(&dpcData.CtlList))
     877    {
     878        int rc = VBoxSHGSMICommandPostprocessCompletion (&pDevExt->u.primary.hgsmiAdapterHeap, &dpcData.CtlList);
     879        AssertRC(rc);
     880    }
     881
     882    if (!vboxSHGSMIListIsEmpty(&dpcData.DmaCmdList))
     883    {
     884        int rc = VBoxSHGSMICommandPostprocessCompletion (&pDevExt->u.primary.Vdma.CmdHeap, &dpcData.DmaCmdList);
     885        AssertRC(rc);
     886    }
     887
     888    if (dpcData.bNotifyDpc)
     889        pDevExt->u.primary.DxgkInterface.DxgkCbNotifyDpc(pDevExt->u.primary.DxgkInterface.DeviceHandle);
    501890}
    502891
     
    9761365}
    9771366
     1367/**
     1368 *
     1369 */
    9781370NTSTATUS
    9791371APIENTRY
     
    15071899            VBOXVIDPNCOFUNCMODALITY CbContext = {0};
    15081900            CbContext.pEnumCofuncModalityArg = pEnumCofuncModalityArg;
    1509             VBoxWddmGetModesTable(pContext, true, &CbContext.pModes, &CbContext.cModes, &CbContext.iPreferredMode, &CbContext.cResolutions, &CbContext.pResolutions);
     1901            VBoxWddmGetModesTable(pContext, /* PDEVICE_EXTENSION DeviceExtension */
     1902                    true, /* bool bRebuildTable*/
     1903                    &CbContext.pModes, /* VIDEO_MODE_INFORMATION ** ppModes*/
     1904                    &CbContext.cModes, /* uint32_t * pcModes */
     1905                    &CbContext.iPreferredMode, /* uint32_t * pPreferrableMode*/
     1906                    &CbContext.pResolutions, /* D3DKMDT_2DREGION **ppResolutions */
     1907                    &CbContext.cResolutions /* uint32_t * pcResolutions */);
    15101908            Assert(CbContext.cModes);
    15111909            Assert(CbContext.cModes > CbContext.iPreferredMode);
  • trunk/src/VBox/Devices/Graphics/HGSMI/HGSMIHost.cpp

    r25226 r26556  
    152152    HGSMILIST hostFIFOProcessed;       /* Processed by the guest. */
    153153    HGSMILIST hostFIFOFree;            /* Buffers for reuse. */
     154#ifdef VBOXVDMA
     155    HGSMILIST guestCmdCompleted;       /* list of completed guest commands to be returned to the guest*/
     156#endif
    154157    RTCRITSECT    hostFIFOCritSect;    /* FIFO serialization lock. */
    155158
     
    198201#define HGSMILISTENTRY_2_FIFOENTRY(_pe) \
    199202    ( (HGSMIHOSTFIFOENTRY*)((uint8_t *)(_pe) - RT_OFFSETOF(HGSMIHOSTFIFOENTRY, entry)) )
     203
    200204//AssertCompile(RT_OFFSETOF(HGSMIHOSTFIFOENTRY, entry) == 0);
    201205
     
    209213
    210214static DECLCALLBACK(void) hgsmiHostCommandFreeCallback (void *pvCallback);
     215
     216#ifdef VBOXVDMA
     217
     218typedef struct _HGSMIGUESTCOMPLENTRY
     219{
     220    /* The list field. Must be the first field. */
     221    HGSMILISTENTRY entry;
     222    /* guest command buffer */
     223    HGSMIOFFSET offBuffer;
     224} HGSMIGUESTCOMPLENTRY;
     225
     226#define HGSMILISTENTRY_2_HGSMIGUESTCOMPLENTRY(_pe) \
     227    ( (HGSMIGUESTCOMPLENTRY*)((uint8_t *)(_pe) - RT_OFFSETOF(HGSMIGUESTCOMPLENTRY, entry)) )
     228
     229static void hgsmiGuestCompletionFIFOFree (HGSMIINSTANCE *pIns, HGSMIGUESTCOMPLENTRY *pEntry)
     230{
     231    NOREF (pIns);
     232    RTMemFree (pEntry);
     233}
     234
     235static int hgsmiGuestCompletionFIFOAlloc (HGSMIINSTANCE *pIns, HGSMIGUESTCOMPLENTRY **ppEntry)
     236{
     237    int rc = VINF_SUCCESS;
     238
     239    NOREF (pIns);
     240
     241    HGSMIGUESTCOMPLENTRY *pEntry = (HGSMIGUESTCOMPLENTRY *)RTMemAllocZ (sizeof (HGSMIGUESTCOMPLENTRY));
     242
     243    if (pEntry)
     244        *ppEntry = pEntry;
     245    else
     246        rc = VERR_NO_MEMORY;
     247
     248    return rc;
     249}
     250
     251#endif
    211252
    212253static int hgsmiLock (HGSMIINSTANCE *pIns)
     
    341382    VM_ASSERT_EMT(pIns->pVM);
    342383
     384#ifndef VBOXVDMA
    343385    /* Currently there is no functionality here. */
    344386    NOREF(pIns);
    345387
    346388    return HGSMIOFFSET_VOID;
     389#else
     390    /* use this to speedup guest cmd completion
     391     * this mechanism is alternative to submitting H->G command for notification */
     392    HGSMIOFFSET offCmd = HGSMIOFFSET_VOID;
     393    int rc = hgsmiFIFOLock(pIns);
     394    AssertRC(rc);
     395    if(RT_SUCCESS(rc))
     396    {
     397        /* Get the host FIFO head entry. */
     398        HGSMILISTENTRY *pHead = pIns->guestCmdCompleted.pHead;
     399        if(pHead)
     400            hgsmiListRemove (&pIns->guestCmdCompleted, pHead, NULL);
     401
     402        if(!pIns->guestCmdCompleted.pHead)
     403            pIns->pHGFlags->u32HostFlags &= (~HGSMIHOSTFLAGS_GCOMMAND_COMPLETED);
     404
     405        hgsmiFIFOUnlock(pIns);
     406
     407        if (pHead)
     408        {
     409            HGSMIGUESTCOMPLENTRY *pEntry = HGSMILISTENTRY_2_HGSMIGUESTCOMPLENTRY(pHead);
     410            offCmd = pEntry->offBuffer;
     411
     412            LogFlowFunc(("host FIFO head %p.\n", pEntry));
     413
     414            hgsmiGuestCompletionFIFOFree (pIns, pEntry);
     415        }
     416    }
     417    /* Special value that means there is no host buffers to be processed. */
     418    return offCmd;
     419#endif
    347420}
    348421
     
    15961669    LogFlowFunc(("leave\n"));
    15971670}
     1671
     1672#ifdef VBOXVDMA
     1673
     1674static int hgsmiGuestCommandComplete (HGSMIINSTANCE *pIns, HGSMIOFFSET offMem)
     1675{
     1676    HGSMIGUESTCOMPLENTRY *pEntry;
     1677
     1678    int rc = hgsmiGuestCompletionFIFOAlloc (pIns, &pEntry);
     1679
     1680    if (RT_SUCCESS (rc))
     1681    {
     1682        pEntry->offBuffer = offMem;
     1683
     1684        rc = hgsmiFIFOLock(pIns);
     1685        if (RT_SUCCESS (rc))
     1686        {
     1687            hgsmiListAppend (&pIns->guestCmdCompleted, &pEntry->entry);
     1688            pIns->pHGFlags->u32HostFlags |= HGSMIHOSTFLAGS_GCOMMAND_COMPLETED;
     1689
     1690            hgsmiFIFOUnlock(pIns);
     1691        }
     1692        else
     1693        {
     1694            hgsmiGuestCompletionFIFOFree(pIns, pEntry);
     1695        }
     1696    }
     1697
     1698    return rc;
     1699}
     1700
     1701int hgsmiCompleteGuestCommand(PHGSMIINSTANCE pIns,
     1702        HGSMIOFFSET offBuffer,
     1703        bool bDoIrq)
     1704{
     1705    int rc = hgsmiGuestCommandComplete (pIns, offBuffer);
     1706    if (RT_SUCCESS (rc))
     1707    {
     1708        if(bDoIrq)
     1709        {
     1710            /* Now guest can read the FIFO, the notification is informational. */
     1711            hgsmiNotifyGuest (pIns);
     1712        }
     1713    }
     1714    return rc;
     1715}
     1716
     1717int HGSMICompleteGuestCommand(PHGSMIINSTANCE pIns,
     1718        void *pvMem,
     1719        bool bDoIrq)
     1720{
     1721    LogFlowFunc(("pIns = %p, pvMem = %p\n", pIns, pvMem));
     1722
     1723    VM_ASSERT_OTHER_THREAD(pIns->pVM);
     1724
     1725    int rc = VINF_SUCCESS;
     1726    HGSMIOFFSET offBuffer = HGSMIHeapBufferOffset (&pIns->hostHeap, pvMem);
     1727    Assert(offBuffer != HGSMIOFFSET_VOID);
     1728    if (offBuffer != HGSMIOFFSET_VOID)
     1729    {
     1730        rc = hgsmiCompleteGuestCommand (pIns, offBuffer, bDoIrq);
     1731        AssertRC (rc);
     1732    }
     1733    else
     1734    {
     1735        LogRel(("invalid cmd offset \n"));
     1736        rc = VERR_INVALID_PARAMETER;
     1737    }
     1738
     1739    LogFlowFunc(("rc = %Rrc\n", rc));
     1740
     1741    return rc;
     1742}
     1743#endif
  • trunk/src/VBox/Devices/Makefile.kmk

    r26523 r26556  
    340340
    341341endif
     342ifdef VBOXVDMA
     343 DevicesR3_DEFS         += VBOXVDMA
     344endif
     345
    342346ifdef VBOX_WITH_VIDEOHWACCEL
    343347 DevicesR3_DEFS         += VBOX_WITH_VIDEOHWACCEL
     
    571575  VBoxDDGC_DEFS         += VBOX_WITH_HGSMI
    572576 endif
     577 ifdef VBOXVDMA
     578  VBoxDDGC_DEFS         += VBOXVDMA
     579 endif
    573580
    574581 ifdef VBOX_WITH_USB
     
    588595  VBoxDDGC_DEFS         += VBOX_WITH_HGSMI
    589596 endif
     597 ifdef VBOXVDMA
     598  VBoxDDGC_DEFS         += VBOXVDMA
     599 endif
     600 
    590601 ifdef VBOX_WITH_VIDEOHWACCEL
    591602  VBoxDDGC_DEFS         += VBOX_WITH_VIDEOHWACCEL
     
    669680 VBoxDDR0_DEFS         += VBOX_WITH_HGSMI
    670681endif
     682ifdef VBOXVDMA
     683 VBoxDDR0_DEFS         += VBOXVDMA
     684endif
     685
    671686
    672687ifdef VBOX_WITH_USB
     
    706721ifdef VBOX_WITH_VIDEOHWACCEL
    707722 VBoxDDR0_DEFS         += VBOX_WITH_VIDEOHWACCEL
     723endif
     724ifdef VBOXVDMA
     725 VBoxDDR0_DEFS         += VBOXVDMA
    708726endif
    709727
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette