VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h@ 26833

Last change on this file since 26833 was 26794, checked in by vboxsync, 15 years ago

wddm: more impl + bugfix

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 24.5 KB
Line 
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
34RT_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
77RT_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
111typedef PSPIN_LOCK VBOXVCMNSPIN_LOCK, *PVBOXVCMNSPIN_LOCK;
112typedef UCHAR VBOXVCMNIRQL, *PVBOXVCMNIRQL;
113
114typedef PEVENT VBOXVCMNEVENT, *PVBOXVCMNEVENT;
115
116typedef struct _DEVICE_EXTENSION * VBOXCMNREG;
117#else
118#include <VBox/VBoxVideo.h>
119#include "wddm/VBoxVideoShgsmi.h"
120#include "wddm/VBoxVideoVdma.h"
121#include "wddm/VBoxVideoVidPn.h"
122#include "wddm/VBoxVideoWddm.h"
123
124typedef KSPIN_LOCK VBOXVCMNSPIN_LOCK, *PVBOXVCMNSPIN_LOCK;
125typedef KIRQL VBOXVCMNIRQL, *PVBOXVCMNIRQL;
126
127typedef KEVENT VBOXVCMNEVENT, *PVBOXVCMNEVENT;
128
129typedef HANDLE VBOXCMNREG;
130
131typedef struct VBOXWDDM_SOURCE
132{
133 struct VBOXWDDM_ALLOCATION * pAllocation;
134} VBOXWDDM_SOURCE, *PVBOXWDDM_SOURCE;
135
136#endif
137
138typedef struct _DEVICE_EXTENSION
139{
140 struct _DEVICE_EXTENSION *pNext; /* Next extension in the DualView extension list.
141 * The primary extension is the first one.
142 */
143#ifndef VBOXWDDM
144 struct _DEVICE_EXTENSION *pPrimary; /* Pointer to the primary device extension. */
145
146 ULONG iDevice; /* Device index: 0 for primary, otherwise a secondary device. */
147
148 ULONG CurrentMode; /* Saved information about video modes */
149 ULONG CurrentModeWidth;
150 ULONG CurrentModeHeight;
151 ULONG CurrentModeBPP;
152
153 ULONG ulFrameBufferOffset; /* The framebuffer position in the VRAM. */
154 ULONG ulFrameBufferSize; /* The size of the current framebuffer. */
155#endif
156 union {
157 /* Information that is only relevant to the primary device or is the same for all devices. */
158 struct {
159
160 void *pvReqFlush; /* Pointer to preallocated generic request structure for
161 * VMMDevReq_VideoAccelFlush. Allocated when VBVA status
162 * is changed. Deallocated on HwReset.
163 */
164
165
166 ULONG ulVbvaEnabled; /* Indicates that VBVA mode is enabled. */
167
168 BOOLEAN bVBoxVideoSupported; /* TRUE if VBoxVideo extensions, including DualView, are supported by the host. */
169#ifndef VBOXWDDM
170 int cDisplays; /* Number of displays. */
171#endif
172 ULONG cbVRAM; /* The VRAM size. */
173
174 ULONG cbMiniportHeap; /* The size of reserved VRAM for miniport driver heap.
175 * It is at offset:
176 * cbAdapterMemorySize - VBOX_VIDEO_ADAPTER_INFORMATION_SIZE - cbMiniportHeap
177 */
178 PVOID pvMiniportHeap; /* The pointer to the miniport heap VRAM.
179 * This is mapped by miniport separately.
180 */
181#ifdef VBOXWDDM
182 VBOXVDMAINFO Vdma;
183#endif
184
185#ifdef VBOX_WITH_HGSMI
186 volatile HGSMIHOSTFLAGS * pHostFlags; /* HGSMI host flags */
187 volatile bool bHostCmdProcessing;
188 VBOXVCMNSPIN_LOCK pSynchLock;
189#endif
190
191 PVOID pvAdapterInformation; /* The pointer to the last 4K of VRAM.
192 * This is mapped by miniport separately.
193 */
194
195 ULONG ulMaxFrameBufferSize; /* The size of the VRAM allocated for the a single framebuffer. */
196
197 BOOLEAN fMouseHidden; /* Has the mouse cursor been hidden by the guest? */
198
199#ifndef VBOX_WITH_HGSMI
200 ULONG ulDisplayInformationSize; /* The size of the Display information, which is at offset:
201 * ulFrameBufferOffset + ulMaxFrameBufferSize.
202 */
203#endif /* !VBOX_WITH_HGSMI */
204
205#ifdef VBOX_WITH_HGSMI
206 BOOLEAN bHGSMI; /* Whether HGSMI is enabled. */
207
208 HGSMIAREA areaHostHeap; /* Host heap VRAM area. */
209
210 HGSMICHANNELINFO channels;
211
212 HGSMIHEAP hgsmiAdapterHeap;
213
214 /* The IO Port Number for host commands. */
215 RTIOPORT IOPortHost;
216
217 /* The IO Port Number for guest commands. */
218 RTIOPORT IOPortGuest;
219# ifndef VBOXWDDM
220 /* Video Port API dynamically picked up at runtime for binary backwards compatibility with older NT versions */
221 VBOXVIDEOPORTPROCS VideoPortProcs;
222# else
223 /* Display Port handle and callbacks */
224 DXGKRNL_INTERFACE DxgkInterface;
225# endif
226#endif /* VBOX_WITH_HGSMI */
227 } primary;
228
229 /* Secondary device information. */
230 struct {
231 BOOLEAN bEnabled; /* Device enabled flag */
232 } secondary;
233 } u;
234
235#ifdef VBOX_WITH_HGSMI
236 HGSMIAREA areaDisplay; /* Entire VRAM chunk for this display device. */
237#endif /* VBOX_WITH_HGSMI */
238
239#ifdef VBOXWDDM
240 PDEVICE_OBJECT pPDO;
241
242 VBOXSHGSMILIST CtlList;
243 VBOXSHGSMILIST DmaCmdList;
244 BOOL bSetNotifyDxDpc;
245 BOOL bNotifyDxDpc;
246
247 ULONG cSources;
248 /* currently we define the array for the max possible size since we do not know
249 * the monitor count at the DxgkDdiAddDevice,
250 * i.e. we obtain the monitor count in DxgkDdiStartDevice due to implementation of the currently re-used XPDM functionality
251 *
252 * @todo: use the dynamic array size calculated at DxgkDdiAddDevice
253 * */
254 VBOXWDDM_SOURCE aSources[VBOX_VIDEO_MAX_SCREENS];
255#endif
256} DEVICE_EXTENSION, *PDEVICE_EXTENSION;
257
258#ifndef VBOXWDDM
259#define DEV_MOUSE_HIDDEN(dev) ((dev)->pPrimary->u.primary.fMouseHidden)
260#define DEV_SET_MOUSE_HIDDEN(dev) \
261do { \
262 (dev)->pPrimary->u.primary.fMouseHidden = TRUE; \
263} while (0)
264#define DEV_SET_MOUSE_SHOWN(dev) \
265do { \
266 (dev)->pPrimary->u.primary.fMouseHidden = FALSE; \
267} while (0)
268#else
269#define DEV_MOUSE_HIDDEN(dev) ((dev)->u.primary.fMouseHidden)
270#define DEV_SET_MOUSE_HIDDEN(dev) \
271do { \
272 (dev)->u.primary.fMouseHidden = TRUE; \
273} while (0)
274#define DEV_SET_MOUSE_SHOWN(dev) \
275do { \
276 (dev)->u.primary.fMouseHidden = FALSE; \
277} while (0)
278#endif
279extern "C"
280{
281#ifndef VBOXWDDM
282/* XPDM-WDDM common API */
283
284typedef PEVENT VBOXVCMNEVENT, *PVBOXVCMNEVENT;
285
286DECLINLINE(VOID) VBoxVideoCmnPortWriteUchar(IN PUCHAR Port, IN UCHAR Value)
287{
288 VideoPortWritePortUchar(Port,Value);
289}
290
291DECLINLINE(VOID) VBoxVideoCmnPortWriteUshort(IN PUSHORT Port, IN USHORT Value)
292{
293 VideoPortWritePortUshort(Port,Value);
294}
295
296DECLINLINE(VOID) VBoxVideoCmnPortWriteUlong(IN PULONG Port, IN ULONG Value)
297{
298 VideoPortWritePortUlong(Port,Value);
299}
300
301DECLINLINE(UCHAR) VBoxVideoCmnPortReadUchar(IN PUCHAR Port)
302{
303 return VideoPortReadPortUchar(Port);
304}
305
306DECLINLINE(USHORT) VBoxVideoCmnPortReadUshort(IN PUSHORT Port)
307{
308 return VideoPortReadPortUshort(Port);
309}
310
311DECLINLINE(ULONG) VBoxVideoCmnPortReadUlong(IN PULONG Port)
312{
313 return VideoPortReadPortUlong(Port);
314}
315
316DECLINLINE(VOID) VBoxVideoCmnMemZero(PVOID pvMem, ULONG cbMem)
317{
318 VideoPortZeroMemory(pvMem, cbMem);
319}
320
321DECLINLINE(VOID) VBoxVideoCmnSpinLockAcquire(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock, OUT PVBOXVCMNIRQL OldIrql)
322{
323 pDeviceExtension->u.primary.VideoPortProcs.pfnAcquireSpinLock(pDeviceExtension, *SpinLock, OldIrql);
324}
325
326DECLINLINE(VOID) VBoxVideoCmnSpinLockAcquireAtDpcLevel(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
327{
328 pDeviceExtension->u.primary.VideoPortProcs.pfnAcquireSpinLockAtDpcLevel(pDeviceExtension, *SpinLock);
329}
330
331DECLINLINE(VOID) VBoxVideoCmnSpinLockRelease(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock, IN VBOXVCMNIRQL NewIrql)
332{
333 pDeviceExtension->u.primary.VideoPortProcs.pfnReleaseSpinLock(pDeviceExtension, *SpinLock, NewIrql);
334}
335
336DECLINLINE(VOID) VBoxVideoCmnSpinLockReleaseFromDpcLevel(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
337{
338 pDeviceExtension->u.primary.VideoPortProcs.pfnReleaseSpinLockFromDpcLevel(pDeviceExtension, *SpinLock);
339}
340
341DECLINLINE(VP_STATUS) VBoxVideoCmnSpinLockCreate(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
342{
343 return pDeviceExtension->u.primary.VideoPortProcs.pfnCreateSpinLock(pDeviceExtension, SpinLock);
344}
345
346DECLINLINE(VP_STATUS) VBoxVideoCmnSpinLockDelete(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
347{
348 return pDeviceExtension->u.primary.VideoPortProcs.pfnDeleteSpinLock(pDeviceExtension, *SpinLock);
349}
350
351DECLINLINE(LONG) VBoxVideoCmnEventSet(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent)
352{
353 return pDeviceExtension->u.primary.VideoPortProcs.pfnSetEvent(pDeviceExtension, *pEvent);
354}
355
356DECLINLINE(VP_STATUS) VBoxVideoCmnEventCreateNotification(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent, IN BOOLEAN bSignaled)
357{
358 ULONG fFlags = NOTIFICATION_EVENT;
359 if(bSignaled)
360 fFlags |= INITIAL_EVENT_SIGNALED;
361
362 return pDeviceExtension->u.primary.VideoPortProcs.pfnCreateEvent(pDeviceExtension, fFlags, NULL, pEvent);
363}
364
365DECLINLINE(VP_STATUS) VBoxVideoCmnEventDelete(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent)
366{
367 return pDeviceExtension->u.primary.VideoPortProcs.pfnDeleteEvent(pDeviceExtension, *pEvent);
368}
369
370DECLINLINE(PVOID) VBoxVideoCmnMemAllocNonPaged(IN PDEVICE_EXTENSION pDeviceExtension, IN SIZE_T NumberOfBytes, IN ULONG Tag)
371{
372 return pDeviceExtension->u.primary.VideoPortProcs.pfnAllocatePool(pDeviceExtension, (VBOXVP_POOL_TYPE)VpNonPagedPool, NumberOfBytes, Tag);
373}
374
375DECLINLINE(VOID) VBoxVideoCmnMemFree(IN PDEVICE_EXTENSION pDeviceExtension, IN PVOID Ptr)
376{
377 pDeviceExtension->u.primary.VideoPortProcs.pfnFreePool(pDeviceExtension, Ptr);
378}
379
380DECLINLINE(VP_STATUS) VBoxVideoCmnRegInit(IN PDEVICE_EXTENSION pDeviceExtension, OUT VBOXCMNREG *pReg)
381{
382 *pReg = pDeviceExtension->pPrimary;
383 return NO_ERROR;
384}
385
386DECLINLINE(VP_STATUS) VBoxVideoCmnRegFini(IN VBOXCMNREG Reg)
387{
388 return NO_ERROR;
389}
390
391VP_STATUS VBoxVideoCmnRegQueryDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t *pVal);
392
393VP_STATUS VBoxVideoCmnRegSetDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t Val);
394
395/* */
396
397RT_C_DECLS_BEGIN
398ULONG DriverEntry(IN PVOID Context1, IN PVOID Context2);
399RT_C_DECLS_END
400
401VP_STATUS VBoxVideoFindAdapter(
402 IN PVOID HwDeviceExtension,
403 IN PVOID HwContext,
404 IN PWSTR ArgumentString,
405 IN OUT PVIDEO_PORT_CONFIG_INFO ConfigInfo,
406 OUT PUCHAR Again);
407
408BOOLEAN VBoxVideoInitialize(PVOID HwDeviceExtension);
409
410BOOLEAN VBoxVideoStartIO(
411 PVOID HwDeviceExtension,
412 PVIDEO_REQUEST_PACKET RequestPacket);
413
414#if defined(VBOX_WITH_HGSMI) && defined(VBOX_WITH_VIDEOHWACCEL)
415BOOLEAN VBoxVideoInterrupt(PVOID HwDeviceExtension);
416#endif
417
418
419BOOLEAN VBoxVideoResetHW(
420 PVOID HwDeviceExtension,
421 ULONG Columns,
422 ULONG Rows);
423
424VP_STATUS VBoxVideoGetPowerState(
425 PVOID HwDeviceExtension,
426 ULONG HwId,
427 PVIDEO_POWER_MANAGEMENT VideoPowerControl);
428
429VP_STATUS VBoxVideoSetPowerState(
430 PVOID HwDeviceExtension,
431 ULONG HwId,
432 PVIDEO_POWER_MANAGEMENT VideoPowerControl);
433
434VP_STATUS VBoxVideoGetChildDescriptor(
435 PVOID HwDeviceExtension,
436 PVIDEO_CHILD_ENUM_INFO ChildEnumInfo,
437 PVIDEO_CHILD_TYPE VideoChildType,
438 PUCHAR pChildDescriptor,
439 PULONG pUId,
440 PULONG pUnused);
441
442
443void VBoxSetupVideoPortFunctions(PDEVICE_EXTENSION PrimaryExtension,
444 VBOXVIDEOPORTPROCS *pCallbacks,
445 PVIDEO_PORT_CONFIG_INFO pConfigInfo);
446
447#else
448
449/* XPDM-WDDM common API */
450DECLINLINE(VOID) VBoxVideoCmnPortWriteUchar(IN PUCHAR Port, IN UCHAR Value)
451{
452 WRITE_PORT_UCHAR(Port,Value);
453}
454
455DECLINLINE(VOID) VBoxVideoCmnPortWriteUshort(IN PUSHORT Port, IN USHORT Value)
456{
457 WRITE_PORT_USHORT(Port,Value);
458}
459
460DECLINLINE(VOID) VBoxVideoCmnPortWriteUlong(IN PULONG Port, IN ULONG Value)
461{
462 WRITE_PORT_ULONG(Port,Value);
463}
464
465DECLINLINE(UCHAR) VBoxVideoCmnPortReadUchar(IN PUCHAR Port)
466{
467 return READ_PORT_UCHAR(Port);
468}
469
470DECLINLINE(USHORT) VBoxVideoCmnPortReadUshort(IN PUSHORT Port)
471{
472 return READ_PORT_USHORT(Port);
473}
474
475DECLINLINE(ULONG) VBoxVideoCmnPortReadUlong(IN PULONG Port)
476{
477 return READ_PORT_ULONG(Port);
478}
479
480DECLINLINE(VOID) VBoxVideoCmnMemZero(PVOID pvMem, ULONG cbMem)
481{
482 memset(pvMem, 0, cbMem);
483}
484
485DECLINLINE(VOID) VBoxVideoCmnSpinLockAcquire(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock, OUT PVBOXVCMNIRQL OldIrql)
486{
487 KeAcquireSpinLock(SpinLock, OldIrql);
488}
489
490DECLINLINE(VOID) VBoxVideoCmnSpinLockAcquireAtDpcLevel(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
491{
492 KeAcquireSpinLockAtDpcLevel(SpinLock);
493}
494
495DECLINLINE(VOID) VBoxVideoCmnSpinLockRelease(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock, IN VBOXVCMNIRQL NewIrql)
496{
497 KeReleaseSpinLock(SpinLock, NewIrql);
498}
499
500DECLINLINE(VOID) VBoxVideoCmnSpinLockReleaseFromDpcLevel(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
501{
502 KeReleaseSpinLockFromDpcLevel(SpinLock);
503}
504
505DECLINLINE(VP_STATUS) VBoxVideoCmnSpinLockCreate(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
506{
507 KeInitializeSpinLock(SpinLock);
508 return NO_ERROR;
509}
510
511DECLINLINE(VP_STATUS) VBoxVideoCmnSpinLockDelete(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
512{
513 return NO_ERROR;
514}
515
516DECLINLINE(LONG) VBoxVideoCmnEventSet(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent)
517{
518 return KeSetEvent(pEvent, 0, FALSE);
519}
520
521DECLINLINE(VP_STATUS) VBoxVideoCmnEventCreateNotification(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent, IN BOOLEAN bSignaled)
522{
523 KeInitializeEvent(pEvent, NotificationEvent, bSignaled);
524 return NO_ERROR;
525}
526
527DECLINLINE(VP_STATUS) VBoxVideoCmnEventDelete(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent)
528{
529 return NO_ERROR;
530}
531
532DECLINLINE(PVOID) VBoxVideoCmnMemAllocNonPaged(IN PDEVICE_EXTENSION pDeviceExtension, IN SIZE_T NumberOfBytes, IN ULONG Tag)
533{
534 return ExAllocatePoolWithTag(NonPagedPool, NumberOfBytes, Tag);
535}
536
537DECLINLINE(VOID) VBoxVideoCmnMemFree(IN PDEVICE_EXTENSION pDeviceExtension, IN PVOID Ptr)
538{
539 ExFreePool(Ptr);
540}
541
542VP_STATUS VBoxVideoCmnRegInit(IN PDEVICE_EXTENSION pDeviceExtension, OUT VBOXCMNREG *pReg);
543
544DECLINLINE(VP_STATUS) VBoxVideoCmnRegFini(IN VBOXCMNREG Reg)
545{
546 if(!Reg)
547 return ERROR_INVALID_PARAMETER;
548
549 NTSTATUS Status = ZwClose(Reg);
550 return Status == STATUS_SUCCESS ? NO_ERROR : ERROR_INVALID_PARAMETER;
551}
552
553VP_STATUS VBoxVideoCmnRegQueryDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t *pVal);
554
555VP_STATUS VBoxVideoCmnRegSetDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t Val);
556
557/* */
558
559RT_C_DECLS_BEGIN
560NTSTATUS
561DriverEntry(
562 IN PDRIVER_OBJECT DriverObject,
563 IN PUNICODE_STRING RegistryPath
564 );
565RT_C_DECLS_END
566
567VOID VBoxWddmGetModesTable(PDEVICE_EXTENSION DeviceExtension, bool bRebuildTable,
568 VIDEO_MODE_INFORMATION ** ppModes, uint32_t * pcModes, uint32_t * pPreferrableMode,
569 D3DKMDT_2DREGION **ppResolutions, uint32_t * pcResolutions);
570
571D3DDDIFORMAT vboxWddmCalcPixelFormat(VIDEO_MODE_INFORMATION *pInfo);
572UINT vboxWddmCalcBitsPerPixel(D3DDDIFORMAT format);
573
574DECLINLINE(ULONG) vboxWddmVramReportedSize(PDEVICE_EXTENSION pDevExt)
575{
576 /* all memory layout info should be initialized */
577 Assert(pDevExt->u.primary.Vdma.CmdHeap.area.offBase);
578 /* page aligned */
579 Assert(!(pDevExt->u.primary.Vdma.CmdHeap.area.offBase & 0xfff));
580 return pDevExt->u.primary.Vdma.CmdHeap.area.offBase;
581}
582
583DECLINLINE(VOID) vboxWddmAssignPrimary(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_SOURCE pSource, PVBOXWDDM_ALLOCATION pAllocation, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId)
584{
585 if (pSource->pAllocation == pAllocation)
586 return;
587
588 if (pSource->pAllocation)
589 {
590 PVBOXWDDM_ALLOCATION pOldAlloc = pSource->pAllocation;
591 PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pOldPrimaryInfo = VBOXWDDM_ALLOCATION_BODY(pOldAlloc, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);
592 /* clear the visibility info fo the current primary */
593 pOldPrimaryInfo->bVisible = FALSE;
594 Assert(pOldPrimaryInfo->VidPnSourceId == srcId);
595 pOldPrimaryInfo->VidPnSourceId = ~0;
596 }
597
598 if (pAllocation)
599 {
600 PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimaryInfo = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);
601 pPrimaryInfo->bVisible = FALSE;
602 pPrimaryInfo->VidPnSourceId = srcId;
603 }
604
605 pSource->pAllocation = pAllocation;
606}
607
608#endif
609
610void* vboxHGSMIBufferAlloc(PDEVICE_EXTENSION PrimaryExtension,
611 HGSMISIZE cbData,
612 uint8_t u8Ch,
613 uint16_t u16Op);
614void vboxHGSMIBufferFree (PDEVICE_EXTENSION PrimaryExtension, void *pvBuffer);
615int vboxHGSMIBufferSubmit (PDEVICE_EXTENSION PrimaryExtension, void *pvBuffer);
616
617BOOLEAN FASTCALL VBoxVideoSetCurrentModePerform(PDEVICE_EXTENSION DeviceExtension,
618 USHORT width, USHORT height, USHORT bpp);
619
620BOOLEAN FASTCALL VBoxVideoSetCurrentMode(
621 PDEVICE_EXTENSION DeviceExtension,
622 PVIDEO_MODE RequestedMode,
623 PSTATUS_BLOCK StatusBlock);
624
625BOOLEAN FASTCALL VBoxVideoResetDevice(
626 PDEVICE_EXTENSION DeviceExtension,
627 PSTATUS_BLOCK StatusBlock);
628
629BOOLEAN FASTCALL VBoxVideoMapVideoMemory(
630 PDEVICE_EXTENSION DeviceExtension,
631 PVIDEO_MEMORY RequestedAddress,
632 PVIDEO_MEMORY_INFORMATION MapInformation,
633 PSTATUS_BLOCK StatusBlock);
634
635BOOLEAN FASTCALL VBoxVideoUnmapVideoMemory(
636 PDEVICE_EXTENSION DeviceExtension,
637 PVIDEO_MEMORY VideoMemory,
638 PSTATUS_BLOCK StatusBlock);
639
640BOOLEAN FASTCALL VBoxVideoQueryNumAvailModes(
641 PDEVICE_EXTENSION DeviceExtension,
642 PVIDEO_NUM_MODES Modes,
643 PSTATUS_BLOCK StatusBlock);
644
645BOOLEAN FASTCALL VBoxVideoQueryAvailModes(
646 PDEVICE_EXTENSION DeviceExtension,
647 PVIDEO_MODE_INFORMATION ReturnedModes,
648 PSTATUS_BLOCK StatusBlock);
649
650BOOLEAN FASTCALL VBoxVideoQueryCurrentMode(
651 PDEVICE_EXTENSION DeviceExtension,
652 PVIDEO_MODE_INFORMATION VideoModeInfo,
653 PSTATUS_BLOCK StatusBlock);
654
655BOOLEAN FASTCALL VBoxVideoSetColorRegisters(
656 PDEVICE_EXTENSION DeviceExtension,
657 PVIDEO_CLUT ColorLookUpTable,
658 PSTATUS_BLOCK StatusBlock);
659
660int VBoxMapAdapterMemory (PDEVICE_EXTENSION PrimaryExtension,
661 void **ppv,
662 ULONG ulOffset,
663 ULONG ulSize);
664
665void VBoxUnmapAdapterMemory (PDEVICE_EXTENSION PrimaryExtension,
666 void **ppv, ULONG ulSize);
667
668void VBoxComputeFrameBufferSizes (PDEVICE_EXTENSION PrimaryExtension);
669
670#ifdef VBOX_WITH_HGSMI
671
672/*
673 * Host and Guest port IO helpers.
674 */
675DECLINLINE(void) VBoxHGSMIHostWrite(PDEVICE_EXTENSION PrimaryExtension, ULONG data)
676{
677#ifndef VBOXWDDM
678 VBoxVideoCmnPortWriteUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortHost, data);
679#else
680 VBoxVideoCmnPortWriteUlong((PULONG)PrimaryExtension->u.primary.IOPortHost, data);
681#endif
682}
683
684DECLINLINE(ULONG) VBoxHGSMIHostRead(PDEVICE_EXTENSION PrimaryExtension)
685{
686#ifndef VBOXWDDM
687 return VBoxVideoCmnPortReadUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortHost);
688#else
689 return VBoxVideoCmnPortReadUlong((PULONG)PrimaryExtension->u.primary.IOPortHost);
690#endif
691}
692
693DECLINLINE(void) VBoxHGSMIGuestWrite(PDEVICE_EXTENSION PrimaryExtension, ULONG data)
694{
695#ifndef VBOXWDDM
696 VBoxVideoCmnPortWriteUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortGuest, data);
697#else
698 VBoxVideoCmnPortWriteUlong((PULONG)PrimaryExtension->u.primary.IOPortGuest, data);
699#endif
700}
701
702DECLINLINE(ULONG) VBoxHGSMIGuestRead(PDEVICE_EXTENSION PrimaryExtension)
703{
704#ifndef VBOXWDDM
705 return VBoxVideoCmnPortReadUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortGuest);
706#else
707 return VBoxVideoCmnPortReadUlong((PULONG)PrimaryExtension->u.primary.IOPortGuest);
708#endif
709}
710
711BOOLEAN VBoxHGSMIIsSupported (PDEVICE_EXTENSION PrimaryExtension);
712
713VOID VBoxSetupDisplaysHGSMI (PDEVICE_EXTENSION PrimaryExtension,
714#ifndef VBOXWDDM
715 PVIDEO_PORT_CONFIG_INFO pConfigInfo,
716#endif
717 ULONG AdapterMemorySize);
718BOOLEAN vboxUpdatePointerShape (PDEVICE_EXTENSION DeviceExtension,
719 PVIDEO_POINTER_ATTRIBUTES pointerAttr,
720 uint32_t cbLength);
721#ifndef VBOXWDDM
722DECLCALLBACK(void) hgsmiHostCmdComplete (HVBOXVIDEOHGSMI hHGSMI, struct _VBVAHOSTCMD * pCmd);
723DECLCALLBACK(int) hgsmiHostCmdRequest (HVBOXVIDEOHGSMI hHGSMI, uint8_t u8Channel, struct _VBVAHOSTCMD ** ppCmd);
724#endif
725
726
727int vboxVBVAChannelDisplayEnable(PDEVICE_EXTENSION PrimaryExtension,
728 int iDisplay, /* negative would mean this is a miniport handler */
729 uint8_t u8Channel);
730
731VOID VBoxVideoHGSMIDpc(
732 IN PVOID HwDeviceExtension,
733 IN PVOID Context
734 );
735
736void HGSMIClearIrq (PDEVICE_EXTENSION PrimaryExtension);
737
738#endif /* VBOX_WITH_HGSMI */
739} /* extern "C" */
740
741#endif /* VBOXVIDEO_H */
Note: See TracBrowser for help on using the repository browser.

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