1 | /** @file
|
---|
2 | * VirtualBox Video miniport driver
|
---|
3 | *
|
---|
4 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
5 | *
|
---|
6 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
7 | * available from http://www.virtualbox.org. This file is free software;
|
---|
8 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
9 | * General Public License (GPL) as published by the Free Software
|
---|
10 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
11 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
12 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
13 | *
|
---|
14 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
15 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
16 | * additional information or have any questions.
|
---|
17 | */
|
---|
18 |
|
---|
19 | #ifndef VBOXVIDEO_H
|
---|
20 | #define VBOXVIDEO_H
|
---|
21 |
|
---|
22 | #include <VBox/cdefs.h>
|
---|
23 | #include <VBox/types.h>
|
---|
24 | #include <iprt/assert.h>
|
---|
25 |
|
---|
26 | #ifdef VBOX_WITH_HGSMI
|
---|
27 | //#include <iprt/thread.h>
|
---|
28 |
|
---|
29 | #include <VBox/HGSMI/HGSMI.h>
|
---|
30 | #include <VBox/HGSMI/HGSMIChSetup.h>
|
---|
31 | #include "VBoxHGSMI.h"
|
---|
32 | #endif /* VBOX_WITH_HGSMI */
|
---|
33 |
|
---|
34 | RT_C_DECLS_BEGIN
|
---|
35 | #ifndef VBOXWDDM
|
---|
36 | #include "dderror.h"
|
---|
37 | #include "devioctl.h"
|
---|
38 | #include "miniport.h"
|
---|
39 | #include "ntddvdeo.h"
|
---|
40 | #include "video.h"
|
---|
41 | #else
|
---|
42 | # define VBOX_WITH_WORKAROUND_MISSING_PACK
|
---|
43 | # if (_MSC_VER >= 1400) && !defined(VBOX_WITH_PATCHED_DDK)
|
---|
44 | # define _InterlockedExchange _InterlockedExchange_StupidDDKVsCompilerCrap
|
---|
45 | # define _InterlockedExchangeAdd _InterlockedExchangeAdd_StupidDDKVsCompilerCrap
|
---|
46 | # define _InterlockedCompareExchange _InterlockedCompareExchange_StupidDDKVsCompilerCrap
|
---|
47 | # define _InterlockedAddLargeStatistic _InterlockedAddLargeStatistic_StupidDDKVsCompilerCrap
|
---|
48 | # define _interlockedbittestandset _interlockedbittestandset_StupidDDKVsCompilerCrap
|
---|
49 | # define _interlockedbittestandreset _interlockedbittestandreset_StupidDDKVsCompilerCrap
|
---|
50 | # define _interlockedbittestandset64 _interlockedbittestandset64_StupidDDKVsCompilerCrap
|
---|
51 | # define _interlockedbittestandreset64 _interlockedbittestandreset64_StupidDDKVsCompilerCrap
|
---|
52 | # pragma warning(disable : 4163)
|
---|
53 | # ifdef VBOX_WITH_WORKAROUND_MISSING_PACK
|
---|
54 | # pragma warning(disable : 4103)
|
---|
55 | # endif
|
---|
56 | # include <ntddk.h>
|
---|
57 | # pragma warning(default : 4163)
|
---|
58 | # ifdef VBOX_WITH_WORKAROUND_MISSING_PACK
|
---|
59 | # pragma pack()
|
---|
60 | # pragma warning(default : 4103)
|
---|
61 | # endif
|
---|
62 | # undef _InterlockedExchange
|
---|
63 | # undef _InterlockedExchangeAdd
|
---|
64 | # undef _InterlockedCompareExchange
|
---|
65 | # undef _InterlockedAddLargeStatistic
|
---|
66 | # undef _interlockedbittestandset
|
---|
67 | # undef _interlockedbittestandreset
|
---|
68 | # undef _interlockedbittestandset64
|
---|
69 | # undef _interlockedbittestandreset64
|
---|
70 | # else
|
---|
71 | # include <ntddk.h>
|
---|
72 | # endif
|
---|
73 | #include "dispmprt.h"
|
---|
74 | #include "ntddvdeo.h"
|
---|
75 | #include "dderror.h"
|
---|
76 | #endif
|
---|
77 | RT_C_DECLS_END
|
---|
78 |
|
---|
79 | #define VBE_DISPI_IOPORT_INDEX 0x01CE
|
---|
80 | #define VBE_DISPI_IOPORT_DATA 0x01CF
|
---|
81 | #define VBE_DISPI_INDEX_ID 0x0
|
---|
82 | #define VBE_DISPI_INDEX_XRES 0x1
|
---|
83 | #define VBE_DISPI_INDEX_YRES 0x2
|
---|
84 | #define VBE_DISPI_INDEX_BPP 0x3
|
---|
85 | #define VBE_DISPI_INDEX_ENABLE 0x4
|
---|
86 | #define VBE_DISPI_INDEX_VIRT_WIDTH 0x6
|
---|
87 | #define VBE_DISPI_INDEX_VIRT_HEIGHT 0x7
|
---|
88 | #define VBE_DISPI_INDEX_VBOX_VIDEO 0xa
|
---|
89 |
|
---|
90 | #define VBE_DISPI_ID2 0xB0C2
|
---|
91 | /* The VBOX interface id. Indicates support for VBE_DISPI_INDEX_VBOX_VIDEO. */
|
---|
92 | #define VBE_DISPI_ID_VBOX_VIDEO 0xBE00
|
---|
93 | #ifdef VBOX_WITH_HGSMI
|
---|
94 | #define VBE_DISPI_ID_HGSMI 0xBE01
|
---|
95 | #endif /* VBOX_WITH_HGSMI */
|
---|
96 | #define VBE_DISPI_DISABLED 0x00
|
---|
97 | #define VBE_DISPI_ENABLED 0x01
|
---|
98 | #define VBE_DISPI_LFB_ENABLED 0x40
|
---|
99 | #define VBE_DISPI_LFB_PHYSICAL_ADDRESS 0xE0000000
|
---|
100 | #define VBE_DISPI_TOTAL_VIDEO_MEMORY_MB 4
|
---|
101 | #define VBE_DISPI_TOTAL_VIDEO_MEMORY_KB (VBE_DISPI_TOTAL_VIDEO_MEMORY_MB * 1024)
|
---|
102 | #define VBE_DISPI_TOTAL_VIDEO_MEMORY_BYTES (VBE_DISPI_TOTAL_VIDEO_MEMORY_KB * 1024)
|
---|
103 |
|
---|
104 | #ifdef VBOX_WITH_HGSMI
|
---|
105 | #define VGA_PORT_HGSMI_HOST 0x3b0
|
---|
106 | #define VGA_PORT_HGSMI_GUEST 0x3d0
|
---|
107 | #endif /* VBOX_WITH_HGSMI */
|
---|
108 |
|
---|
109 | /* common API types */
|
---|
110 | #ifndef VBOXWDDM
|
---|
111 | typedef PSPIN_LOCK VBOXVCMNSPIN_LOCK, *PVBOXVCMNSPIN_LOCK;
|
---|
112 | typedef UCHAR VBOXVCMNIRQL, *PVBOXVCMNIRQL;
|
---|
113 |
|
---|
114 | typedef PEVENT VBOXVCMNEVENT, *PVBOXVCMNEVENT;
|
---|
115 | #else
|
---|
116 | typedef KSPIN_LOCK VBOXVCMNSPIN_LOCK, *PVBOXVCMNSPIN_LOCK;
|
---|
117 | typedef KIRQL VBOXVCMNIRQL, *PVBOXVCMNIRQL;
|
---|
118 |
|
---|
119 | typedef KEVENT VBOXVCMNEVENT, *PVBOXVCMNEVENT;
|
---|
120 | #endif
|
---|
121 |
|
---|
122 | typedef struct _DEVICE_EXTENSION
|
---|
123 | {
|
---|
124 | struct _DEVICE_EXTENSION *pNext; /* Next extension in the DualView extension list.
|
---|
125 | * The primary extension is the first one.
|
---|
126 | */
|
---|
127 |
|
---|
128 | struct _DEVICE_EXTENSION *pPrimary; /* Pointer to the primary device extension. */
|
---|
129 |
|
---|
130 | ULONG iDevice; /* Device index: 0 for primary, otherwise a secondary device. */
|
---|
131 |
|
---|
132 |
|
---|
133 | ULONG CurrentMode; /* Saved information about video modes */
|
---|
134 | ULONG CurrentModeWidth;
|
---|
135 | ULONG CurrentModeHeight;
|
---|
136 | ULONG CurrentModeBPP;
|
---|
137 |
|
---|
138 | ULONG ulFrameBufferOffset; /* The framebuffer position in the VRAM. */
|
---|
139 | ULONG ulFrameBufferSize; /* The size of the current framebuffer. */
|
---|
140 |
|
---|
141 | union {
|
---|
142 | /* Information that is only relevant to the primary device or is the same for all devices. */
|
---|
143 | struct {
|
---|
144 |
|
---|
145 | void *pvReqFlush; /* Pointer to preallocated generic request structure for
|
---|
146 | * VMMDevReq_VideoAccelFlush. Allocated when VBVA status
|
---|
147 | * is changed. Deallocated on HwReset.
|
---|
148 | */
|
---|
149 |
|
---|
150 |
|
---|
151 | ULONG ulVbvaEnabled; /* Indicates that VBVA mode is enabled. */
|
---|
152 |
|
---|
153 | BOOLEAN bVBoxVideoSupported; /* TRUE if VBoxVideo extensions, including DualView, are supported by the host. */
|
---|
154 |
|
---|
155 | int cDisplays; /* Number of displays. */
|
---|
156 |
|
---|
157 | ULONG cbVRAM; /* The VRAM size. */
|
---|
158 |
|
---|
159 | ULONG cbMiniportHeap; /* The size of reserved VRAM for miniport driver heap.
|
---|
160 | * It is at offset:
|
---|
161 | * cbAdapterMemorySize - VBOX_VIDEO_ADAPTER_INFORMATION_SIZE - cbMiniportHeap
|
---|
162 | */
|
---|
163 | PVOID pvMiniportHeap; /* The pointer to the miniport heap VRAM.
|
---|
164 | * This is mapped by miniport separately.
|
---|
165 | */
|
---|
166 | #ifdef VBOX_WITH_HGSMI
|
---|
167 | volatile HGSMIHOSTFLAGS * pHostFlags; /* HGSMI host flags */
|
---|
168 | volatile bool bHostCmdProcessing;
|
---|
169 | VBOXVCMNSPIN_LOCK pSynchLock;
|
---|
170 | #endif
|
---|
171 |
|
---|
172 | PVOID pvAdapterInformation; /* The pointer to the last 4K of VRAM.
|
---|
173 | * This is mapped by miniport separately.
|
---|
174 | */
|
---|
175 |
|
---|
176 | ULONG ulMaxFrameBufferSize; /* The size of the VRAM allocated for the a single framebuffer. */
|
---|
177 |
|
---|
178 | BOOLEAN fMouseHidden; /* Has the mouse cursor been hidden by the guest? */
|
---|
179 |
|
---|
180 | #ifndef VBOX_WITH_HGSMI
|
---|
181 | ULONG ulDisplayInformationSize; /* The size of the Display information, which is at offset:
|
---|
182 | * ulFrameBufferOffset + ulMaxFrameBufferSize.
|
---|
183 | */
|
---|
184 | #endif /* !VBOX_WITH_HGSMI */
|
---|
185 |
|
---|
186 | #ifdef VBOX_WITH_HGSMI
|
---|
187 | BOOLEAN bHGSMI; /* Whether HGSMI is enabled. */
|
---|
188 |
|
---|
189 | HGSMIAREA areaHostHeap; /* Host heap VRAM area. */
|
---|
190 |
|
---|
191 | HGSMICHANNELINFO channels;
|
---|
192 |
|
---|
193 | HGSMIHEAP hgsmiAdapterHeap;
|
---|
194 |
|
---|
195 | /* The IO Port Number for host commands. */
|
---|
196 | RTIOPORT IOPortHost;
|
---|
197 |
|
---|
198 | /* The IO Port Number for guest commands. */
|
---|
199 | RTIOPORT IOPortGuest;
|
---|
200 | # ifndef VBOXWDDM
|
---|
201 | /* Video Port API dynamically picked up at runtime for binary backwards compatibility with older NT versions */
|
---|
202 | VBOXVIDEOPORTPROCS VideoPortProcs;
|
---|
203 | # else
|
---|
204 | /* Display Port handle and callbacks */
|
---|
205 | DXGKRNL_INTERFACE DxgkInterface;
|
---|
206 | # endif
|
---|
207 | #endif /* VBOX_WITH_HGSMI */
|
---|
208 | } primary;
|
---|
209 |
|
---|
210 | /* Secondary device information. */
|
---|
211 | struct {
|
---|
212 | BOOLEAN bEnabled; /* Device enabled flag */
|
---|
213 | } secondary;
|
---|
214 | } u;
|
---|
215 |
|
---|
216 | #ifdef VBOX_WITH_HGSMI
|
---|
217 | HGSMIAREA areaDisplay; /* Entire VRAM chunk for this display device. */
|
---|
218 | #endif /* VBOX_WITH_HGSMI */
|
---|
219 | } DEVICE_EXTENSION, *PDEVICE_EXTENSION;
|
---|
220 |
|
---|
221 | #define DEV_MOUSE_HIDDEN(dev) ((dev)->pPrimary->u.primary.fMouseHidden)
|
---|
222 | #define DEV_SET_MOUSE_HIDDEN(dev) \
|
---|
223 | do { \
|
---|
224 | (dev)->pPrimary->u.primary.fMouseHidden = TRUE; \
|
---|
225 | } while (0)
|
---|
226 | #define DEV_SET_MOUSE_SHOWN(dev) \
|
---|
227 | do { \
|
---|
228 | (dev)->pPrimary->u.primary.fMouseHidden = FALSE; \
|
---|
229 | } while (0)
|
---|
230 |
|
---|
231 | extern "C"
|
---|
232 | {
|
---|
233 | #ifndef VBOXWDDM
|
---|
234 | /* XPDM-WDDM common API */
|
---|
235 |
|
---|
236 | typedef PEVENT VBOXVCMNEVENT, *PVBOXVCMNEVENT;
|
---|
237 |
|
---|
238 | DECLINLINE(VOID) VBoxVideoCmnPortWriteUchar(IN PUCHAR Port, IN UCHAR Value)
|
---|
239 | {
|
---|
240 | VideoPortWritePortUchar(Port,Value);
|
---|
241 | }
|
---|
242 |
|
---|
243 | DECLINLINE(VOID) VBoxVideoCmnPortWriteUshort(IN PUSHORT Port, IN USHORT Value)
|
---|
244 | {
|
---|
245 | VideoPortWritePortUshort(Port,Value);
|
---|
246 | }
|
---|
247 |
|
---|
248 | DECLINLINE(VOID) VBoxVideoCmnPortWriteUlong(IN PULONG Port, IN ULONG Value)
|
---|
249 | {
|
---|
250 | VideoPortWritePortUlong(Port,Value);
|
---|
251 | }
|
---|
252 |
|
---|
253 | DECLINLINE(UCHAR) VBoxVideoCmnPortReadUchar(IN PUCHAR Port)
|
---|
254 | {
|
---|
255 | return VideoPortReadPortUchar(Port);
|
---|
256 | }
|
---|
257 |
|
---|
258 | DECLINLINE(USHORT) VBoxVideoCmnPortReadUshort(IN PUSHORT Port)
|
---|
259 | {
|
---|
260 | return VideoPortReadPortUshort(Port);
|
---|
261 | }
|
---|
262 |
|
---|
263 | DECLINLINE(ULONG) VBoxVideoCmnPortReadUlong(IN PULONG Port)
|
---|
264 | {
|
---|
265 | return VideoPortReadPortUlong(Port);
|
---|
266 | }
|
---|
267 |
|
---|
268 | DECLINLINE(VOID) VBoxVideoCmnMemZero(PVOID pvMem, ULONG cbMem)
|
---|
269 | {
|
---|
270 | VideoPortZeroMemory(pvMem, cbMem);
|
---|
271 | }
|
---|
272 |
|
---|
273 | DECLINLINE(VOID) VBoxVideoCmnSpinLockAcquire(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock, OUT PVBOXVCMNIRQL OldIrql)
|
---|
274 | {
|
---|
275 | pDeviceExtension->u.primary.VideoPortProcs.pfnAcquireSpinLock(pDeviceExtension, *SpinLock, OldIrql);
|
---|
276 | }
|
---|
277 |
|
---|
278 | DECLINLINE(VOID) VBoxVideoCmnSpinLockAcquireAtDpcLevel(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
|
---|
279 | {
|
---|
280 | pDeviceExtension->u.primary.VideoPortProcs.pfnAcquireSpinLockAtDpcLevel(pDeviceExtension, *SpinLock);
|
---|
281 | }
|
---|
282 |
|
---|
283 | DECLINLINE(VOID) VBoxVideoCmnSpinLockRelease(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock, IN VBOXVCMNIRQL NewIrql)
|
---|
284 | {
|
---|
285 | pDeviceExtension->u.primary.VideoPortProcs.pfnReleaseSpinLock(pDeviceExtension, *SpinLock, NewIrql);
|
---|
286 | }
|
---|
287 |
|
---|
288 | DECLINLINE(VOID) VBoxVideoCmnSpinLockReleaseFromDpcLevel(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
|
---|
289 | {
|
---|
290 | pDeviceExtension->u.primary.VideoPortProcs.pfnReleaseSpinLockFromDpcLevel(pDeviceExtension, *SpinLock);
|
---|
291 | }
|
---|
292 |
|
---|
293 | DECLINLINE(VP_STATUS) VBoxVideoCmnSpinLockCreate(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
|
---|
294 | {
|
---|
295 | return pDeviceExtension->u.primary.VideoPortProcs.pfnCreateSpinLock(pDeviceExtension, SpinLock);
|
---|
296 | }
|
---|
297 |
|
---|
298 | DECLINLINE(VP_STATUS) VBoxVideoCmnSpinLockDelete(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
|
---|
299 | {
|
---|
300 | return pDeviceExtension->u.primary.VideoPortProcs.pfnDeleteSpinLock(pDeviceExtension, *SpinLock);
|
---|
301 | }
|
---|
302 |
|
---|
303 | DECLINLINE(LONG) VBoxVideoCmnEventSet(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent)
|
---|
304 | {
|
---|
305 | return pDeviceExtension->u.primary.VideoPortProcs.pfnSetEvent(pDeviceExtension, *pEvent);
|
---|
306 | }
|
---|
307 |
|
---|
308 | DECLINLINE(VP_STATUS) VBoxVideoCmnEventCreateNotification(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent, IN BOOLEAN bSignaled)
|
---|
309 | {
|
---|
310 | ULONG fFlags = NOTIFICATION_EVENT;
|
---|
311 | if(bSignaled)
|
---|
312 | fFlags |= INITIAL_EVENT_SIGNALED;
|
---|
313 |
|
---|
314 | return pDeviceExtension->u.primary.VideoPortProcs.pfnCreateEvent(pDeviceExtension, fFlags, NULL, pEvent);
|
---|
315 | }
|
---|
316 |
|
---|
317 | DECLINLINE(VP_STATUS) VBoxVideoCmnEventDelete(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent)
|
---|
318 | {
|
---|
319 | return pDeviceExtension->u.primary.VideoPortProcs.pfnDeleteEvent(pDeviceExtension, *pEvent);
|
---|
320 | }
|
---|
321 |
|
---|
322 | DECLINLINE(PVOID) VBoxVideoCmnMemAllocNonPaged(IN PDEVICE_EXTENSION pDeviceExtension, IN SIZE_T NumberOfBytes, IN ULONG Tag)
|
---|
323 | {
|
---|
324 | return pDeviceExtension->u.primary.VideoPortProcs.pfnAllocatePool(pDeviceExtension, (VBOXVP_POOL_TYPE)VpNonPagedPool, NumberOfBytes, Tag);
|
---|
325 | }
|
---|
326 |
|
---|
327 | DECLINLINE(VOID) VBoxVideoCmnMemFree(IN PDEVICE_EXTENSION pDeviceExtension, IN PVOID Ptr)
|
---|
328 | {
|
---|
329 | pDeviceExtension->u.primary.VideoPortProcs.pfnFreePool(pDeviceExtension, Ptr);
|
---|
330 | }
|
---|
331 | /* */
|
---|
332 |
|
---|
333 | RT_C_DECLS_BEGIN
|
---|
334 | ULONG DriverEntry(IN PVOID Context1, IN PVOID Context2);
|
---|
335 | RT_C_DECLS_END
|
---|
336 |
|
---|
337 | VP_STATUS VBoxVideoFindAdapter(
|
---|
338 | IN PVOID HwDeviceExtension,
|
---|
339 | IN PVOID HwContext,
|
---|
340 | IN PWSTR ArgumentString,
|
---|
341 | IN OUT PVIDEO_PORT_CONFIG_INFO ConfigInfo,
|
---|
342 | OUT PUCHAR Again);
|
---|
343 |
|
---|
344 | BOOLEAN VBoxVideoInitialize(PVOID HwDeviceExtension);
|
---|
345 |
|
---|
346 | BOOLEAN VBoxVideoStartIO(
|
---|
347 | PVOID HwDeviceExtension,
|
---|
348 | PVIDEO_REQUEST_PACKET RequestPacket);
|
---|
349 |
|
---|
350 | #if defined(VBOX_WITH_HGSMI) && defined(VBOX_WITH_VIDEOHWACCEL)
|
---|
351 | BOOLEAN VBoxVideoInterrupt(PVOID HwDeviceExtension);
|
---|
352 | #endif
|
---|
353 |
|
---|
354 |
|
---|
355 | BOOLEAN VBoxVideoResetHW(
|
---|
356 | PVOID HwDeviceExtension,
|
---|
357 | ULONG Columns,
|
---|
358 | ULONG Rows);
|
---|
359 |
|
---|
360 | VP_STATUS VBoxVideoGetPowerState(
|
---|
361 | PVOID HwDeviceExtension,
|
---|
362 | ULONG HwId,
|
---|
363 | PVIDEO_POWER_MANAGEMENT VideoPowerControl);
|
---|
364 |
|
---|
365 | VP_STATUS VBoxVideoSetPowerState(
|
---|
366 | PVOID HwDeviceExtension,
|
---|
367 | ULONG HwId,
|
---|
368 | PVIDEO_POWER_MANAGEMENT VideoPowerControl);
|
---|
369 |
|
---|
370 | VP_STATUS VBoxVideoGetChildDescriptor(
|
---|
371 | PVOID HwDeviceExtension,
|
---|
372 | PVIDEO_CHILD_ENUM_INFO ChildEnumInfo,
|
---|
373 | PVIDEO_CHILD_TYPE VideoChildType,
|
---|
374 | PUCHAR pChildDescriptor,
|
---|
375 | PULONG pUId,
|
---|
376 | PULONG pUnused);
|
---|
377 |
|
---|
378 |
|
---|
379 | void VBoxSetupVideoPortFunctions(PDEVICE_EXTENSION PrimaryExtension,
|
---|
380 | VBOXVIDEOPORTPROCS *pCallbacks,
|
---|
381 | PVIDEO_PORT_CONFIG_INFO pConfigInfo);
|
---|
382 |
|
---|
383 | #else
|
---|
384 |
|
---|
385 | /* XPDM-WDDM common API */
|
---|
386 | DECLINLINE(VOID) VBoxVideoCmnPortWriteUchar(IN PUCHAR Port, IN UCHAR Value)
|
---|
387 | {
|
---|
388 | WRITE_PORT_UCHAR(Port,Value);
|
---|
389 | }
|
---|
390 |
|
---|
391 | DECLINLINE(VOID) VBoxVideoCmnPortWriteUshort(IN PUSHORT Port, IN USHORT Value)
|
---|
392 | {
|
---|
393 | WRITE_PORT_USHORT(Port,Value);
|
---|
394 | }
|
---|
395 |
|
---|
396 | DECLINLINE(VOID) VBoxVideoCmnPortWriteUlong(IN PULONG Port, IN ULONG Value)
|
---|
397 | {
|
---|
398 | WRITE_PORT_ULONG(Port,Value);
|
---|
399 | }
|
---|
400 |
|
---|
401 | DECLINLINE(UCHAR) VBoxVideoCmnPortReadUchar(IN PUCHAR Port)
|
---|
402 | {
|
---|
403 | return READ_PORT_UCHAR(Port);
|
---|
404 | }
|
---|
405 |
|
---|
406 | DECLINLINE(USHORT) VBoxVideoCmnPortReadUshort(IN PUSHORT Port)
|
---|
407 | {
|
---|
408 | return READ_PORT_USHORT(Port);
|
---|
409 | }
|
---|
410 |
|
---|
411 | DECLINLINE(ULONG) VBoxVideoCmnPortReadUlong(IN PULONG Port)
|
---|
412 | {
|
---|
413 | return READ_PORT_ULONG(Port);
|
---|
414 | }
|
---|
415 |
|
---|
416 | DECLINLINE(VOID) VBoxVideoCmnMemZero(PVOID pvMem, ULONG cbMem)
|
---|
417 | {
|
---|
418 | memset(pvMem, 0, cbMem);
|
---|
419 | }
|
---|
420 |
|
---|
421 | DECLINLINE(VOID) VBoxVideoCmnSpinLockAcquire(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock, OUT PVBOXVCMNIRQL OldIrql)
|
---|
422 | {
|
---|
423 | KeAcquireSpinLock(SpinLock, OldIrql);
|
---|
424 | }
|
---|
425 |
|
---|
426 | DECLINLINE(VOID) VBoxVideoCmnSpinLockAcquireAtDpcLevel(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
|
---|
427 | {
|
---|
428 | KeAcquireSpinLockAtDpcLevel(SpinLock);
|
---|
429 | }
|
---|
430 |
|
---|
431 | DECLINLINE(VOID) VBoxVideoCmnSpinLockRelease(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock, IN VBOXVCMNIRQL NewIrql)
|
---|
432 | {
|
---|
433 | KeReleaseSpinLock(SpinLock, NewIrql);
|
---|
434 | }
|
---|
435 |
|
---|
436 | DECLINLINE(VOID) VBoxVideoCmnSpinLockReleaseFromDpcLevel(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
|
---|
437 | {
|
---|
438 | KeReleaseSpinLockFromDpcLevel(SpinLock);
|
---|
439 | }
|
---|
440 |
|
---|
441 | DECLINLINE(VP_STATUS) VBoxVideoCmnSpinLockCreate(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
|
---|
442 | {
|
---|
443 | KeInitializeSpinLock(SpinLock);
|
---|
444 | return NO_ERROR;
|
---|
445 | }
|
---|
446 |
|
---|
447 | DECLINLINE(VP_STATUS) VBoxVideoCmnSpinLockDelete(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
|
---|
448 | {
|
---|
449 | return NO_ERROR;
|
---|
450 | }
|
---|
451 |
|
---|
452 | DECLINLINE(LONG) VBoxVideoCmnEventSet(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent)
|
---|
453 | {
|
---|
454 | return KeSetEvent(pEvent, 0, FALSE);
|
---|
455 | }
|
---|
456 |
|
---|
457 | DECLINLINE(VP_STATUS) VBoxVideoCmnEventCreateNotification(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent, IN BOOLEAN bSignaled)
|
---|
458 | {
|
---|
459 | KeInitializeEvent(pEvent, NotificationEvent, bSignaled);
|
---|
460 | return NO_ERROR;
|
---|
461 | }
|
---|
462 |
|
---|
463 | DECLINLINE(VP_STATUS) VBoxVideoCmnEventDelete(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent)
|
---|
464 | {
|
---|
465 | return NO_ERROR;
|
---|
466 | }
|
---|
467 |
|
---|
468 | DECLINLINE(PVOID) VBoxVideoCmnMemAllocNonPaged(IN PDEVICE_EXTENSION pDeviceExtension, IN SIZE_T NumberOfBytes, IN ULONG Tag)
|
---|
469 | {
|
---|
470 | return ExAllocatePoolWithTag(NonPagedPool, NumberOfBytes, Tag);
|
---|
471 | }
|
---|
472 |
|
---|
473 | DECLINLINE(VOID) VBoxVideoCmnMemFree(IN PDEVICE_EXTENSION pDeviceExtension, IN PVOID Ptr)
|
---|
474 | {
|
---|
475 | ExFreePool(Ptr);
|
---|
476 | }
|
---|
477 |
|
---|
478 | /* */
|
---|
479 |
|
---|
480 | RT_C_DECLS_BEGIN
|
---|
481 | NTSTATUS
|
---|
482 | DriverEntry(
|
---|
483 | IN PDRIVER_OBJECT DriverObject,
|
---|
484 | IN PUNICODE_STRING RegistryPath
|
---|
485 | );
|
---|
486 | RT_C_DECLS_END
|
---|
487 |
|
---|
488 | NTSTATUS vboxVidPnCheckTopology(const D3DKMDT_HVIDPN hDesiredVidPn,
|
---|
489 | D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
|
---|
490 | BOOLEAN *pbSupported);
|
---|
491 |
|
---|
492 | NTSTATUS vboxVidPnCheckSourceModeInfo(const D3DKMDT_HVIDPN hDesiredVidPn,
|
---|
493 | const D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo,
|
---|
494 | BOOLEAN *pbSupported);
|
---|
495 |
|
---|
496 | NTSTATUS vboxVidPnCheckSourceModeSet(const D3DKMDT_HVIDPN hDesiredVidPn,
|
---|
497 | D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
|
---|
498 | BOOLEAN *pbSupported);
|
---|
499 |
|
---|
500 | NTSTATUS vboxVidPnCheckTargetModeInfo(const D3DKMDT_HVIDPN hDesiredVidPn,
|
---|
501 | const D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo,
|
---|
502 | BOOLEAN *pbSupported);
|
---|
503 |
|
---|
504 | NTSTATUS vboxVidPnCheckTargetModeSet(const D3DKMDT_HVIDPN hDesiredVidPn,
|
---|
505 | D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet, const DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface,
|
---|
506 | BOOLEAN *pbSupported);
|
---|
507 | #endif
|
---|
508 |
|
---|
509 | BOOLEAN FASTCALL VBoxVideoSetCurrentMode(
|
---|
510 | PDEVICE_EXTENSION DeviceExtension,
|
---|
511 | PVIDEO_MODE RequestedMode,
|
---|
512 | PSTATUS_BLOCK StatusBlock);
|
---|
513 |
|
---|
514 | BOOLEAN FASTCALL VBoxVideoResetDevice(
|
---|
515 | PDEVICE_EXTENSION DeviceExtension,
|
---|
516 | PSTATUS_BLOCK StatusBlock);
|
---|
517 |
|
---|
518 | BOOLEAN FASTCALL VBoxVideoMapVideoMemory(
|
---|
519 | PDEVICE_EXTENSION DeviceExtension,
|
---|
520 | PVIDEO_MEMORY RequestedAddress,
|
---|
521 | PVIDEO_MEMORY_INFORMATION MapInformation,
|
---|
522 | PSTATUS_BLOCK StatusBlock);
|
---|
523 |
|
---|
524 | BOOLEAN FASTCALL VBoxVideoUnmapVideoMemory(
|
---|
525 | PDEVICE_EXTENSION DeviceExtension,
|
---|
526 | PVIDEO_MEMORY VideoMemory,
|
---|
527 | PSTATUS_BLOCK StatusBlock);
|
---|
528 |
|
---|
529 | BOOLEAN FASTCALL VBoxVideoQueryNumAvailModes(
|
---|
530 | PDEVICE_EXTENSION DeviceExtension,
|
---|
531 | PVIDEO_NUM_MODES Modes,
|
---|
532 | PSTATUS_BLOCK StatusBlock);
|
---|
533 |
|
---|
534 | BOOLEAN FASTCALL VBoxVideoQueryAvailModes(
|
---|
535 | PDEVICE_EXTENSION DeviceExtension,
|
---|
536 | PVIDEO_MODE_INFORMATION ReturnedModes,
|
---|
537 | PSTATUS_BLOCK StatusBlock);
|
---|
538 |
|
---|
539 | BOOLEAN FASTCALL VBoxVideoQueryCurrentMode(
|
---|
540 | PDEVICE_EXTENSION DeviceExtension,
|
---|
541 | PVIDEO_MODE_INFORMATION VideoModeInfo,
|
---|
542 | PSTATUS_BLOCK StatusBlock);
|
---|
543 |
|
---|
544 | BOOLEAN FASTCALL VBoxVideoSetColorRegisters(
|
---|
545 | PDEVICE_EXTENSION DeviceExtension,
|
---|
546 | PVIDEO_CLUT ColorLookUpTable,
|
---|
547 | PSTATUS_BLOCK StatusBlock);
|
---|
548 |
|
---|
549 | int VBoxMapAdapterMemory (PDEVICE_EXTENSION PrimaryExtension,
|
---|
550 | void **ppv,
|
---|
551 | ULONG ulOffset,
|
---|
552 | ULONG ulSize);
|
---|
553 |
|
---|
554 | void VBoxUnmapAdapterMemory (PDEVICE_EXTENSION PrimaryExtension,
|
---|
555 | void **ppv, ULONG ulSize);
|
---|
556 |
|
---|
557 | void VBoxComputeFrameBufferSizes (PDEVICE_EXTENSION PrimaryExtension);
|
---|
558 |
|
---|
559 | #ifdef VBOX_WITH_HGSMI
|
---|
560 |
|
---|
561 | /*
|
---|
562 | * Host and Guest port IO helpers.
|
---|
563 | */
|
---|
564 | DECLINLINE(void) VBoxHGSMIHostWrite(PDEVICE_EXTENSION PrimaryExtension, ULONG data)
|
---|
565 | {
|
---|
566 | VBoxVideoCmnPortWriteUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortHost, data);
|
---|
567 | }
|
---|
568 |
|
---|
569 | DECLINLINE(ULONG) VBoxHGSMIHostRead(PDEVICE_EXTENSION PrimaryExtension)
|
---|
570 | {
|
---|
571 | return VBoxVideoCmnPortReadUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortHost);
|
---|
572 | }
|
---|
573 |
|
---|
574 | DECLINLINE(void) VBoxHGSMIGuestWrite(PDEVICE_EXTENSION PrimaryExtension, ULONG data)
|
---|
575 | {
|
---|
576 | VBoxVideoCmnPortWriteUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortGuest, data);
|
---|
577 | }
|
---|
578 |
|
---|
579 | DECLINLINE(ULONG) VBoxHGSMIGuestRead(PDEVICE_EXTENSION PrimaryExtension)
|
---|
580 | {
|
---|
581 | return VBoxVideoCmnPortReadUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortGuest);
|
---|
582 | }
|
---|
583 |
|
---|
584 | BOOLEAN VBoxHGSMIIsSupported (PDEVICE_EXTENSION PrimaryExtension);
|
---|
585 |
|
---|
586 | VOID VBoxSetupDisplaysHGSMI (PDEVICE_EXTENSION PrimaryExtension,
|
---|
587 | #ifndef VBOXWDDM
|
---|
588 | PVIDEO_PORT_CONFIG_INFO pConfigInfo,
|
---|
589 | #endif
|
---|
590 | ULONG AdapterMemorySize);
|
---|
591 | BOOLEAN vboxUpdatePointerShape (PDEVICE_EXTENSION DeviceExtension,
|
---|
592 | PVIDEO_POINTER_ATTRIBUTES pointerAttr,
|
---|
593 | uint32_t cbLength);
|
---|
594 | DECLCALLBACK(void) hgsmiHostCmdComplete (HVBOXVIDEOHGSMI hHGSMI, struct _VBVAHOSTCMD * pCmd);
|
---|
595 | DECLCALLBACK(int) hgsmiHostCmdRequest (HVBOXVIDEOHGSMI hHGSMI, uint8_t u8Channel, struct _VBVAHOSTCMD ** ppCmd);
|
---|
596 |
|
---|
597 |
|
---|
598 | int vboxVBVAChannelDisplayEnable(PDEVICE_EXTENSION PrimaryExtension,
|
---|
599 | int iDisplay, /* negative would mean this is a miniport handler */
|
---|
600 | uint8_t u8Channel);
|
---|
601 |
|
---|
602 | VOID VBoxVideoHGSMIDpc(
|
---|
603 | IN PVOID HwDeviceExtension,
|
---|
604 | IN PVOID Context
|
---|
605 | );
|
---|
606 |
|
---|
607 | void HGSMIClearIrq (PDEVICE_EXTENSION PrimaryExtension);
|
---|
608 |
|
---|
609 | #endif /* VBOX_WITH_HGSMI */
|
---|
610 | } /* extern "C" */
|
---|
611 |
|
---|
612 | #endif /* VBOXVIDEO_H */
|
---|