VirtualBox

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

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

hgsmi/guest video driver: backwards compatibility with < WinXP: make newer videoport functions picked up at runtime

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 13.6 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#include "dderror.h"
36#include "devioctl.h"
37#include "miniport.h"
38#include "ntddvdeo.h"
39#include "video.h"
40RT_C_DECLS_END
41
42#define VBE_DISPI_IOPORT_INDEX 0x01CE
43#define VBE_DISPI_IOPORT_DATA 0x01CF
44#define VBE_DISPI_INDEX_ID 0x0
45#define VBE_DISPI_INDEX_XRES 0x1
46#define VBE_DISPI_INDEX_YRES 0x2
47#define VBE_DISPI_INDEX_BPP 0x3
48#define VBE_DISPI_INDEX_ENABLE 0x4
49#define VBE_DISPI_INDEX_VIRT_WIDTH 0x6
50#define VBE_DISPI_INDEX_VIRT_HEIGHT 0x7
51#define VBE_DISPI_INDEX_VBOX_VIDEO 0xa
52
53#define VBE_DISPI_ID2 0xB0C2
54/* The VBOX interface id. Indicates support for VBE_DISPI_INDEX_VBOX_VIDEO. */
55#define VBE_DISPI_ID_VBOX_VIDEO 0xBE00
56#ifdef VBOX_WITH_HGSMI
57#define VBE_DISPI_ID_HGSMI 0xBE01
58#endif /* VBOX_WITH_HGSMI */
59#define VBE_DISPI_DISABLED 0x00
60#define VBE_DISPI_ENABLED 0x01
61#define VBE_DISPI_LFB_ENABLED 0x40
62#define VBE_DISPI_LFB_PHYSICAL_ADDRESS 0xE0000000
63#define VBE_DISPI_TOTAL_VIDEO_MEMORY_MB 4
64#define VBE_DISPI_TOTAL_VIDEO_MEMORY_KB (VBE_DISPI_TOTAL_VIDEO_MEMORY_MB * 1024)
65#define VBE_DISPI_TOTAL_VIDEO_MEMORY_BYTES (VBE_DISPI_TOTAL_VIDEO_MEMORY_KB * 1024)
66
67#ifdef VBOX_WITH_HGSMI
68#define VGA_PORT_OFF_HGSMI_HOST 0
69#define VGA_PORT_OFF_HGSMI_GUEST 4
70#endif /* VBOX_WITH_HGSMI */
71
72typedef struct _DEVICE_EXTENSION
73{
74 struct _DEVICE_EXTENSION *pNext; /* Next extension in the DualView extension list.
75 * The primary extension is the first one.
76 */
77
78 struct _DEVICE_EXTENSION *pPrimary; /* Pointer to the primary device extension. */
79
80 ULONG iDevice; /* Device index: 0 for primary, otherwise a secondary device. */
81
82
83 ULONG CurrentMode; /* Saved information about video modes */
84 ULONG CurrentModeWidth;
85 ULONG CurrentModeHeight;
86 ULONG CurrentModeBPP;
87
88 ULONG ulFrameBufferOffset; /* The framebuffer position in the VRAM. */
89 ULONG ulFrameBufferSize; /* The size of the current framebuffer. */
90
91 union {
92 /* Information that is only relevant to the primary device or is the same for all devices. */
93 struct {
94
95 void *pvReqFlush; /* Pointer to preallocated generic request structure for
96 * VMMDevReq_VideoAccelFlush. Allocated when VBVA status
97 * is changed. Deallocated on HwReset.
98 */
99
100
101 ULONG ulVbvaEnabled; /* Indicates that VBVA mode is enabled. */
102
103 BOOLEAN bVBoxVideoSupported; /* TRUE if VBoxVideo extensions, including DualView, are supported by the host. */
104
105 int cDisplays; /* Number of displays. */
106
107 ULONG cbVRAM; /* The VRAM size. */
108
109 ULONG cbMiniportHeap; /* The size of reserved VRAM for miniport driver heap.
110 * It is at offset:
111 * cbAdapterMemorySize - VBOX_VIDEO_ADAPTER_INFORMATION_SIZE - cbMiniportHeap
112 */
113 PVOID pvMiniportHeap; /* The pointer to the miniport heap VRAM.
114 * This is mapped by miniport separately.
115 */
116#ifdef VBOX_WITH_HGSMI
117 volatile HGSMIHOSTFLAGS * pHostFlags; /* HGSMI host flags */
118 volatile bool bHostCmdProcessing;
119 PSPIN_LOCK pSynchLock;
120#endif
121
122 PVOID pvAdapterInformation; /* The pointer to the last 4K of VRAM.
123 * This is mapped by miniport separately.
124 */
125
126 ULONG ulMaxFrameBufferSize; /* The size of the VRAM allocated for the a single framebuffer. */
127
128 BOOLEAN fMouseHidden; /* Has the mouse cursor been hidden by the guest? */
129
130#ifndef VBOX_WITH_HGSMI
131 ULONG ulDisplayInformationSize; /* The size of the Display information, which is at offset:
132 * ulFrameBufferOffset + ulMaxFrameBufferSize.
133 */
134#endif /* !VBOX_WITH_HGSMI */
135
136#ifdef VBOX_WITH_HGSMI
137 BOOLEAN bHGSMI; /* Whether HGSMI is enabled. */
138
139 HGSMIAREA areaHostHeap; /* Host heap VRAM area. */
140
141 HGSMICHANNELINFO channels;
142
143 HGSMIHEAP hgsmiAdapterHeap;
144
145 PSPIN_LOCK pGHRWLock; /* lock for making guest->host read/writes atomic */
146
147 /* The IO Port Number for host commands. */
148 RTIOPORT IOPortHost;
149
150 /* The IO Port Number for guest commands. */
151 RTIOPORT IOPortGuest;
152
153 /* Video Port API dynamically picked up at runtime for binary backwards compatibility with older NT versions */
154 VBOXVIDEOPORTPROCS VideoPortProcs;
155#endif /* VBOX_WITH_HGSMI */
156 } primary;
157
158 /* Secondary device information. */
159 struct {
160 BOOLEAN bEnabled; /* Device enabled flag */
161 } secondary;
162 } u;
163
164#ifdef VBOX_WITH_HGSMI
165 HGSMIAREA areaDisplay; /* Entire VRAM chunk for this display device. */
166#endif /* VBOX_WITH_HGSMI */
167} DEVICE_EXTENSION, *PDEVICE_EXTENSION;
168
169#define DEV_MOUSE_HIDDEN(dev) ((dev)->pPrimary->u.primary.fMouseHidden)
170#define DEV_SET_MOUSE_HIDDEN(dev) \
171do { \
172 (dev)->pPrimary->u.primary.fMouseHidden = TRUE; \
173} while (0)
174#define DEV_SET_MOUSE_SHOWN(dev) \
175do { \
176 (dev)->pPrimary->u.primary.fMouseHidden = FALSE; \
177} while (0)
178
179extern "C"
180{
181
182RT_C_DECLS_BEGIN
183ULONG DriverEntry(IN PVOID Context1, IN PVOID Context2);
184RT_C_DECLS_END
185
186VP_STATUS VBoxVideoFindAdapter(
187 IN PVOID HwDeviceExtension,
188 IN PVOID HwContext,
189 IN PWSTR ArgumentString,
190 IN OUT PVIDEO_PORT_CONFIG_INFO ConfigInfo,
191 OUT PUCHAR Again);
192
193BOOLEAN VBoxVideoInitialize(PVOID HwDeviceExtension);
194
195BOOLEAN VBoxVideoStartIO(
196 PVOID HwDeviceExtension,
197 PVIDEO_REQUEST_PACKET RequestPacket);
198
199#if defined(VBOX_WITH_HGSMI) && defined(VBOX_WITH_VIDEOHWACCEL)
200BOOLEAN VBoxVideoInterrupt(PVOID HwDeviceExtension);
201#endif
202
203
204BOOLEAN VBoxVideoResetHW(
205 PVOID HwDeviceExtension,
206 ULONG Columns,
207 ULONG Rows);
208
209VP_STATUS VBoxVideoGetPowerState(
210 PVOID HwDeviceExtension,
211 ULONG HwId,
212 PVIDEO_POWER_MANAGEMENT VideoPowerControl);
213
214VP_STATUS VBoxVideoSetPowerState(
215 PVOID HwDeviceExtension,
216 ULONG HwId,
217 PVIDEO_POWER_MANAGEMENT VideoPowerControl);
218
219BOOLEAN FASTCALL VBoxVideoSetCurrentMode(
220 PDEVICE_EXTENSION DeviceExtension,
221 PVIDEO_MODE RequestedMode,
222 PSTATUS_BLOCK StatusBlock);
223
224BOOLEAN FASTCALL VBoxVideoResetDevice(
225 PDEVICE_EXTENSION DeviceExtension,
226 PSTATUS_BLOCK StatusBlock);
227
228BOOLEAN FASTCALL VBoxVideoMapVideoMemory(
229 PDEVICE_EXTENSION DeviceExtension,
230 PVIDEO_MEMORY RequestedAddress,
231 PVIDEO_MEMORY_INFORMATION MapInformation,
232 PSTATUS_BLOCK StatusBlock);
233
234BOOLEAN FASTCALL VBoxVideoUnmapVideoMemory(
235 PDEVICE_EXTENSION DeviceExtension,
236 PVIDEO_MEMORY VideoMemory,
237 PSTATUS_BLOCK StatusBlock);
238
239BOOLEAN FASTCALL VBoxVideoQueryNumAvailModes(
240 PDEVICE_EXTENSION DeviceExtension,
241 PVIDEO_NUM_MODES Modes,
242 PSTATUS_BLOCK StatusBlock);
243
244BOOLEAN FASTCALL VBoxVideoQueryAvailModes(
245 PDEVICE_EXTENSION DeviceExtension,
246 PVIDEO_MODE_INFORMATION ReturnedModes,
247 PSTATUS_BLOCK StatusBlock);
248
249BOOLEAN FASTCALL VBoxVideoQueryCurrentMode(
250 PDEVICE_EXTENSION DeviceExtension,
251 PVIDEO_MODE_INFORMATION VideoModeInfo,
252 PSTATUS_BLOCK StatusBlock);
253
254BOOLEAN FASTCALL VBoxVideoSetColorRegisters(
255 PDEVICE_EXTENSION DeviceExtension,
256 PVIDEO_CLUT ColorLookUpTable,
257 PSTATUS_BLOCK StatusBlock);
258
259VP_STATUS VBoxVideoGetChildDescriptor(
260 PVOID HwDeviceExtension,
261 PVIDEO_CHILD_ENUM_INFO ChildEnumInfo,
262 PVIDEO_CHILD_TYPE VideoChildType,
263 PUCHAR pChildDescriptor,
264 PULONG pUId,
265 PULONG pUnused);
266
267int VBoxMapAdapterMemory (PDEVICE_EXTENSION PrimaryExtension,
268 void **ppv,
269 ULONG ulOffset,
270 ULONG ulSize);
271
272void VBoxUnmapAdapterMemory (PDEVICE_EXTENSION PrimaryExtension,
273 void **ppv);
274
275void VBoxComputeFrameBufferSizes (PDEVICE_EXTENSION PrimaryExtension);
276
277#ifdef VBOX_WITH_HGSMI
278
279DECLINLINE(void) VBoxVideoVBEWriteUlongLocked(USHORT dataType, ULONG data)
280{
281 VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, dataType);
282 VideoPortWritePortUlong((PULONG)VBE_DISPI_IOPORT_DATA, data);
283}
284
285DECLINLINE(void) VBoxVideoVBEWriteUshortLocked(USHORT dataType, USHORT data)
286{
287 VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, dataType);
288 VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_DATA, data);
289}
290
291DECLINLINE(ULONG) VBoxVideoVBEReadUlongLocked (USHORT dataType)
292{
293 VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, dataType);
294 return VideoPortReadPortUlong((PULONG)VBE_DISPI_IOPORT_DATA);
295}
296
297DECLINLINE(void) VBoxVideoVBEWriteUlong(PDEVICE_EXTENSION PrimaryExtension, USHORT dataType, ULONG data)
298{
299 UCHAR oldIrql;
300 PrimaryExtension->u.primary.VideoPortProcs.pfnAcquireSpinLock(PrimaryExtension,
301 PrimaryExtension->u.primary.pGHRWLock,
302 &oldIrql);
303 VBoxVideoVBEWriteUlongLocked(dataType, data);
304 PrimaryExtension->u.primary.VideoPortProcs.pfnReleaseSpinLock(PrimaryExtension,
305 PrimaryExtension->u.primary.pGHRWLock,
306 oldIrql);
307}
308
309DECLINLINE(void) VBoxVideoVBEWriteUshort(PDEVICE_EXTENSION PrimaryExtension, USHORT dataType, USHORT data)
310{
311 UCHAR oldIrql;
312 PrimaryExtension->u.primary.VideoPortProcs.pfnAcquireSpinLock(PrimaryExtension,
313 PrimaryExtension->u.primary.pGHRWLock,
314 &oldIrql);
315 VBoxVideoVBEWriteUshortLocked(dataType, data);
316 PrimaryExtension->u.primary.VideoPortProcs.pfnReleaseSpinLock(PrimaryExtension,
317 PrimaryExtension->u.primary.pGHRWLock,
318 oldIrql);
319}
320
321DECLINLINE(ULONG) VBoxVideoVBEReadUlong(PDEVICE_EXTENSION PrimaryExtension, USHORT dataType)
322{
323 ULONG data;
324 UCHAR oldIrql;
325 PrimaryExtension->u.primary.VideoPortProcs.pfnAcquireSpinLock(PrimaryExtension,
326 PrimaryExtension->u.primary.pGHRWLock,
327 &oldIrql);
328 data = VBoxVideoVBEReadUlongLocked(dataType);
329 PrimaryExtension->u.primary.VideoPortProcs.pfnReleaseSpinLock(PrimaryExtension,
330 PrimaryExtension->u.primary.pGHRWLock,
331 oldIrql);
332 return data;
333}
334
335/*
336 * Host and Guest port IO helpers.
337 */
338DECLINLINE(void) VBoxHGSMIHostWrite(PDEVICE_EXTENSION PrimaryExtension, ULONG data)
339{
340 VideoPortWritePortUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortHost, data);
341}
342
343DECLINLINE(ULONG) VBoxHGSMIHostRead(PDEVICE_EXTENSION PrimaryExtension)
344{
345 return VideoPortReadPortUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortHost);
346}
347
348DECLINLINE(void) VBoxHGSMIGuestWrite(PDEVICE_EXTENSION PrimaryExtension, ULONG data)
349{
350 VideoPortWritePortUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortGuest, data);
351}
352
353DECLINLINE(ULONG) VBoxHGSMIGuestRead(PDEVICE_EXTENSION PrimaryExtension)
354{
355 return VideoPortReadPortUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortGuest);
356}
357
358BOOLEAN VBoxHGSMIIsSupported (PDEVICE_EXTENSION PrimaryExtension);
359
360void VBoxSetupVideoPortFunctions(PDEVICE_EXTENSION PrimaryExtension,
361 VBOXVIDEOPORTPROCS *pCallbacks,
362 PVIDEO_PORT_CONFIG_INFO pConfigInfo);
363
364VOID VBoxSetupDisplaysHGSMI (PDEVICE_EXTENSION PrimaryExtension,
365 PVIDEO_PORT_CONFIG_INFO pConfigInfo,
366 ULONG AdapterMemorySize);
367BOOLEAN vboxUpdatePointerShape (PDEVICE_EXTENSION PrimaryExtension,
368 PVIDEO_POINTER_ATTRIBUTES pointerAttr,
369 uint32_t cbLength);
370DECLCALLBACK(void) hgsmiGHCommandPost(HVBOXVIDEOHGSMI hHGSMI, HGSMIOFFSET offCmd);
371DECLCALLBACK(void) hgsmiHostCmdComplete (HVBOXVIDEOHGSMI hHGSMI, struct _VBVAHOSTCMD * pCmd);
372DECLCALLBACK(int) hgsmiHostCmdRequest (HVBOXVIDEOHGSMI hHGSMI, uint8_t u8Channel, struct _VBVAHOSTCMD ** ppCmd);
373
374
375int vboxVBVAChannelDisplayEnable(PDEVICE_EXTENSION PrimaryExtension,
376 int iDisplay, /* negative would mean this is a miniport handler */
377 uint8_t u8Channel);
378
379VOID VBoxVideoHGSMIDpc(
380 IN PVOID HwDeviceExtension,
381 IN PVOID Context
382 );
383
384void HGSMIClearIrq (PDEVICE_EXTENSION PrimaryExtension);
385
386#endif /* VBOX_WITH_HGSMI */
387} /* extern "C" */
388
389#endif /* VBOXVIDEO_H */
Note: See TracBrowser for help on using the repository browser.

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