1 | /* $Id: VBoxMPDevExt.h 50940 2014-04-01 11:22:34Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | * VBox Miniport device extension header
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2011-2012 Oracle Corporation
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | */
|
---|
18 |
|
---|
19 | #ifndef VBOXMPDEVEXT_H
|
---|
20 | #define VBOXMPDEVEXT_H
|
---|
21 |
|
---|
22 | #include "VBoxMPUtils.h"
|
---|
23 | #include <VBox/VBoxVideoGuest.h>
|
---|
24 |
|
---|
25 | #ifdef VBOX_XPDM_MINIPORT
|
---|
26 | # include <miniport.h>
|
---|
27 | # include <ntddvdeo.h>
|
---|
28 | # include <video.h>
|
---|
29 | # include "common/xpdm/VBoxVideoPortAPI.h"
|
---|
30 | #endif
|
---|
31 |
|
---|
32 | #ifdef VBOX_WDDM_MINIPORT
|
---|
33 | # ifdef VBOX_WDDM_WIN8
|
---|
34 | extern DWORD g_VBoxDisplayOnly;
|
---|
35 | # endif
|
---|
36 | # include "wddm/VBoxMPTypes.h"
|
---|
37 | #endif
|
---|
38 |
|
---|
39 | #define VBOXMP_MAX_VIDEO_MODES 128
|
---|
40 | typedef struct VBOXMP_COMMON
|
---|
41 | {
|
---|
42 | int cDisplays; /* Number of displays. */
|
---|
43 |
|
---|
44 | uint32_t cbVRAM; /* The VRAM size. */
|
---|
45 |
|
---|
46 | PHYSICAL_ADDRESS phVRAM; /* Physical VRAM base. */
|
---|
47 |
|
---|
48 | ULONG ulApertureSize; /* Size of the LFB aperture (>= VRAM size). */
|
---|
49 |
|
---|
50 | uint32_t cbMiniportHeap; /* The size of reserved VRAM for miniport driver heap.
|
---|
51 | * It is at offset:
|
---|
52 | * cbAdapterMemorySize - VBOX_VIDEO_ADAPTER_INFORMATION_SIZE - cbMiniportHeap
|
---|
53 | */
|
---|
54 | void *pvMiniportHeap; /* The pointer to the miniport heap VRAM.
|
---|
55 | * This is mapped by miniport separately.
|
---|
56 | */
|
---|
57 | void *pvAdapterInformation; /* The pointer to the last 4K of VRAM.
|
---|
58 | * This is mapped by miniport separately.
|
---|
59 | */
|
---|
60 |
|
---|
61 | /** Whether HGSMI is enabled. */
|
---|
62 | bool bHGSMI;
|
---|
63 | /** Context information needed to receive commands from the host. */
|
---|
64 | HGSMIHOSTCOMMANDCONTEXT hostCtx;
|
---|
65 | /** Context information needed to submit commands to the host. */
|
---|
66 | HGSMIGUESTCOMMANDCONTEXT guestCtx;
|
---|
67 |
|
---|
68 | BOOLEAN fAnyX; /* Unrestricted horizontal resolution flag. */
|
---|
69 | } VBOXMP_COMMON, *PVBOXMP_COMMON;
|
---|
70 |
|
---|
71 | typedef struct _VBOXMP_DEVEXT
|
---|
72 | {
|
---|
73 | struct _VBOXMP_DEVEXT *pNext; /* Next extension in the DualView extension list.
|
---|
74 | * The primary extension is the first one.
|
---|
75 | */
|
---|
76 | #ifdef VBOX_XPDM_MINIPORT
|
---|
77 | struct _VBOXMP_DEVEXT *pPrimary; /* Pointer to the primary device extension. */
|
---|
78 |
|
---|
79 | ULONG iDevice; /* Device index: 0 for primary, otherwise a secondary device. */
|
---|
80 | /* Standart video modes list.
|
---|
81 | * Additional space is reserved for a custom video mode for this guest monitor.
|
---|
82 | * The custom video mode index is alternating for each mode set and 2 indexes are needed for the custom mode.
|
---|
83 | */
|
---|
84 | VIDEO_MODE_INFORMATION aVideoModes[VBOXMP_MAX_VIDEO_MODES + 2];
|
---|
85 | /* Number of available video modes, set by VBoxMPCmnBuildVideoModesTable. */
|
---|
86 | uint32_t cVideoModes;
|
---|
87 | ULONG CurrentMode; /* Saved information about video modes */
|
---|
88 | ULONG CurrentModeWidth;
|
---|
89 | ULONG CurrentModeHeight;
|
---|
90 | ULONG CurrentModeBPP;
|
---|
91 |
|
---|
92 | ULONG ulFrameBufferOffset; /* The framebuffer position in the VRAM. */
|
---|
93 | ULONG ulFrameBufferSize; /* The size of the current framebuffer. */
|
---|
94 |
|
---|
95 | uint8_t iInvocationCounter;
|
---|
96 | uint32_t Prev_xres;
|
---|
97 | uint32_t Prev_yres;
|
---|
98 | uint32_t Prev_bpp;
|
---|
99 | #endif /*VBOX_XPDM_MINIPORT*/
|
---|
100 |
|
---|
101 | #ifdef VBOX_WDDM_MINIPORT
|
---|
102 | PDEVICE_OBJECT pPDO;
|
---|
103 | UNICODE_STRING RegKeyName;
|
---|
104 | UNICODE_STRING VideoGuid;
|
---|
105 |
|
---|
106 | uint8_t * pvVisibleVram;
|
---|
107 |
|
---|
108 | VBOXVIDEOCM_MGR CmMgr;
|
---|
109 | VBOXVIDEOCM_MGR SeamlessCtxMgr;
|
---|
110 | /* hgsmi allocation manager */
|
---|
111 | VBOXVIDEOCM_ALLOC_MGR AllocMgr;
|
---|
112 | VBOXVDMADDI_NODE aNodes[VBOXWDDM_NUM_NODES];
|
---|
113 | LIST_ENTRY DpcCmdQueue;
|
---|
114 | LIST_ENTRY SwapchainList3D;
|
---|
115 | /* mutex for context list operations */
|
---|
116 | KSPIN_LOCK ContextLock;
|
---|
117 | KSPIN_LOCK SynchLock;
|
---|
118 | volatile uint32_t cContexts3D;
|
---|
119 | volatile uint32_t cContexts2D;
|
---|
120 | volatile uint32_t cContextsDispIfResize;
|
---|
121 | volatile uint32_t cRenderFromShadowDisabledContexts;
|
---|
122 | volatile uint32_t cUnlockedVBVADisabled;
|
---|
123 |
|
---|
124 | volatile uint32_t fCompletingCommands;
|
---|
125 |
|
---|
126 | DWORD dwDrvCfgFlags;
|
---|
127 | /* this is examined and swicthed by DxgkDdiSubmitCommand only! */
|
---|
128 | volatile BOOLEAN fRenderToShadowDisabled;
|
---|
129 | #ifdef VBOX_WITH_CROGL
|
---|
130 | BOOLEAN f3DEnabled;
|
---|
131 | BOOLEAN fTexPresentEnabled;
|
---|
132 | BOOLEAN fCmdVbvaEnabled;
|
---|
133 |
|
---|
134 | uint32_t u32CrConDefaultClientID;
|
---|
135 |
|
---|
136 | VBOXCMDVBVA CmdVbva;
|
---|
137 |
|
---|
138 | VBOXMP_CRCTLCON CrCtlCon;
|
---|
139 | VBOXMP_CRSHGSMITRANSPORT CrHgsmiTransport;
|
---|
140 | #endif
|
---|
141 | VBOXWDDM_GLOBAL_POINTER_INFO PointerInfo;
|
---|
142 |
|
---|
143 | VBOXVTLIST CtlList;
|
---|
144 | VBOXVTLIST DmaCmdList;
|
---|
145 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
146 | VBOXVTLIST VhwaCmdList;
|
---|
147 | #endif
|
---|
148 | BOOL bNotifyDxDpc;
|
---|
149 |
|
---|
150 | #ifdef VBOX_VDMA_WITH_WATCHDOG
|
---|
151 | PKTHREAD pWdThread;
|
---|
152 | KEVENT WdEvent;
|
---|
153 | #endif
|
---|
154 | BOOL bVSyncTimerEnabled;
|
---|
155 | volatile uint32_t fVSyncInVBlank;
|
---|
156 | volatile LARGE_INTEGER VSyncTime;
|
---|
157 | KTIMER VSyncTimer;
|
---|
158 | KDPC VSyncDpc;
|
---|
159 |
|
---|
160 | #if 0
|
---|
161 | FAST_MUTEX ShRcTreeMutex;
|
---|
162 | AVLPVTREE ShRcTree;
|
---|
163 | #endif
|
---|
164 |
|
---|
165 | VBOXWDDM_SOURCE aSources[VBOX_VIDEO_MAX_SCREENS];
|
---|
166 | VBOXWDDM_TARGET aTargets[VBOX_VIDEO_MAX_SCREENS];
|
---|
167 | #endif /*VBOX_WDDM_MINIPORT*/
|
---|
168 |
|
---|
169 | union {
|
---|
170 | /* Information that is only relevant to the primary device or is the same for all devices. */
|
---|
171 | struct {
|
---|
172 |
|
---|
173 | void *pvReqFlush; /* Pointer to preallocated generic request structure for
|
---|
174 | * VMMDevReq_VideoAccelFlush. Allocated when VBVA status
|
---|
175 | * is changed. Deallocated on HwReset.
|
---|
176 | */
|
---|
177 | ULONG ulVbvaEnabled; /* Indicates that VBVA mode is enabled. */
|
---|
178 | ULONG ulMaxFrameBufferSize; /* The size of the VRAM allocated for the a single framebuffer. */
|
---|
179 | BOOLEAN fMouseHidden; /* Has the mouse cursor been hidden by the guest? */
|
---|
180 | VBOXMP_COMMON commonInfo;
|
---|
181 | #ifdef VBOX_XPDM_MINIPORT
|
---|
182 | /* Video Port API dynamically picked up at runtime for binary backwards compatibility with older NT versions */
|
---|
183 | VBOXVIDEOPORTPROCS VideoPortProcs;
|
---|
184 | #endif
|
---|
185 |
|
---|
186 | #ifdef VBOX_WDDM_MINIPORT
|
---|
187 | VBOXVDMAINFO Vdma;
|
---|
188 | # ifdef VBOXVDMA_WITH_VBVA
|
---|
189 | VBOXVBVAINFO Vbva;
|
---|
190 | # endif
|
---|
191 | D3DKMDT_HVIDPN hCommittedVidPn; /* committed VidPn handle */
|
---|
192 | DXGKRNL_INTERFACE DxgkInterface; /* Display Port handle and callbacks */
|
---|
193 | #endif
|
---|
194 | } primary;
|
---|
195 |
|
---|
196 | /* Secondary device information. */
|
---|
197 | struct {
|
---|
198 | BOOLEAN bEnabled; /* Device enabled flag */
|
---|
199 | } secondary;
|
---|
200 | } u;
|
---|
201 |
|
---|
202 | HGSMIAREA areaDisplay; /* Entire VRAM chunk for this display device. */
|
---|
203 | } VBOXMP_DEVEXT, *PVBOXMP_DEVEXT;
|
---|
204 |
|
---|
205 | DECLINLINE(PVBOXMP_DEVEXT) VBoxCommonToPrimaryExt(PVBOXMP_COMMON pCommon)
|
---|
206 | {
|
---|
207 | return RT_FROM_MEMBER(pCommon, VBOXMP_DEVEXT, u.primary.commonInfo);
|
---|
208 | }
|
---|
209 |
|
---|
210 | DECLINLINE(PVBOXMP_COMMON) VBoxCommonFromDeviceExt(PVBOXMP_DEVEXT pExt)
|
---|
211 | {
|
---|
212 | #ifdef VBOX_XPDM_MINIPORT
|
---|
213 | return &pExt->pPrimary->u.primary.commonInfo;
|
---|
214 | #else
|
---|
215 | return &pExt->u.primary.commonInfo;
|
---|
216 | #endif
|
---|
217 | }
|
---|
218 |
|
---|
219 | #ifdef VBOX_WDDM_MINIPORT
|
---|
220 | DECLINLINE(ULONG) vboxWddmVramCpuVisibleSize(PVBOXMP_DEVEXT pDevExt)
|
---|
221 | {
|
---|
222 | #ifdef VBOX_WITH_CROGL
|
---|
223 | if (pDevExt->fCmdVbvaEnabled)
|
---|
224 | {
|
---|
225 | /* all memory layout info should be initialized */
|
---|
226 | Assert(pDevExt->CmdVbva.Vbva.offVRAMBuffer);
|
---|
227 | /* page aligned */
|
---|
228 | Assert(!(pDevExt->CmdVbva.Vbva.offVRAMBuffer & 0xfff));
|
---|
229 |
|
---|
230 | return (ULONG)(pDevExt->CmdVbva.Vbva.offVRAMBuffer & ~0xfffULL);
|
---|
231 | }
|
---|
232 | #endif
|
---|
233 | /* all memory layout info should be initialized */
|
---|
234 | Assert(pDevExt->aSources[0].Vbva.Vbva.offVRAMBuffer);
|
---|
235 | /* page aligned */
|
---|
236 | Assert(!(pDevExt->aSources[0].Vbva.Vbva.offVRAMBuffer & 0xfff));
|
---|
237 |
|
---|
238 | return (ULONG)(pDevExt->aSources[0].Vbva.Vbva.offVRAMBuffer & ~0xfffULL);
|
---|
239 | }
|
---|
240 |
|
---|
241 | DECLINLINE(ULONG) vboxWddmVramCpuVisibleSegmentSize(PVBOXMP_DEVEXT pDevExt)
|
---|
242 | {
|
---|
243 | return vboxWddmVramCpuVisibleSize(pDevExt);
|
---|
244 | }
|
---|
245 |
|
---|
246 | #ifdef VBOXWDDM_RENDER_FROM_SHADOW
|
---|
247 | DECLINLINE(ULONG) vboxWddmVramCpuInvisibleSegmentSize(PVBOXMP_DEVEXT pDevExt)
|
---|
248 | {
|
---|
249 | return vboxWddmVramCpuVisibleSegmentSize(pDevExt);
|
---|
250 | }
|
---|
251 |
|
---|
252 | DECLINLINE(bool) vboxWddmCmpSurfDescsBase(VBOXWDDM_SURFACE_DESC *pDesc1, VBOXWDDM_SURFACE_DESC *pDesc2)
|
---|
253 | {
|
---|
254 | if (pDesc1->width != pDesc2->width)
|
---|
255 | return false;
|
---|
256 | if (pDesc1->height != pDesc2->height)
|
---|
257 | return false;
|
---|
258 | if (pDesc1->format != pDesc2->format)
|
---|
259 | return false;
|
---|
260 | if (pDesc1->bpp != pDesc2->bpp)
|
---|
261 | return false;
|
---|
262 | if (pDesc1->pitch != pDesc2->pitch)
|
---|
263 | return false;
|
---|
264 | return true;
|
---|
265 | }
|
---|
266 |
|
---|
267 | #endif
|
---|
268 | #endif /*VBOX_WDDM_MINIPORT*/
|
---|
269 |
|
---|
270 | #endif /*VBOXMPDEVEXT_H*/
|
---|