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