VirtualBox

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

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

Windows guest video driver: report mouse pointer shape only for primary screen (xTracker 4168)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.3 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_HGSMI_HOST 0x3b0
69#define VGA_PORT_HGSMI_GUEST 0x3d0
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 /* The IO Port Number for host commands. */
146 RTIOPORT IOPortHost;
147
148 /* The IO Port Number for guest commands. */
149 RTIOPORT IOPortGuest;
150
151 /* Video Port API dynamically picked up at runtime for binary backwards compatibility with older NT versions */
152 VBOXVIDEOPORTPROCS VideoPortProcs;
153#endif /* VBOX_WITH_HGSMI */
154 } primary;
155
156 /* Secondary device information. */
157 struct {
158 BOOLEAN bEnabled; /* Device enabled flag */
159 } secondary;
160 } u;
161
162#ifdef VBOX_WITH_HGSMI
163 HGSMIAREA areaDisplay; /* Entire VRAM chunk for this display device. */
164#endif /* VBOX_WITH_HGSMI */
165} DEVICE_EXTENSION, *PDEVICE_EXTENSION;
166
167#define DEV_MOUSE_HIDDEN(dev) ((dev)->pPrimary->u.primary.fMouseHidden)
168#define DEV_SET_MOUSE_HIDDEN(dev) \
169do { \
170 (dev)->pPrimary->u.primary.fMouseHidden = TRUE; \
171} while (0)
172#define DEV_SET_MOUSE_SHOWN(dev) \
173do { \
174 (dev)->pPrimary->u.primary.fMouseHidden = FALSE; \
175} while (0)
176
177extern "C"
178{
179
180RT_C_DECLS_BEGIN
181ULONG DriverEntry(IN PVOID Context1, IN PVOID Context2);
182RT_C_DECLS_END
183
184VP_STATUS VBoxVideoFindAdapter(
185 IN PVOID HwDeviceExtension,
186 IN PVOID HwContext,
187 IN PWSTR ArgumentString,
188 IN OUT PVIDEO_PORT_CONFIG_INFO ConfigInfo,
189 OUT PUCHAR Again);
190
191BOOLEAN VBoxVideoInitialize(PVOID HwDeviceExtension);
192
193BOOLEAN VBoxVideoStartIO(
194 PVOID HwDeviceExtension,
195 PVIDEO_REQUEST_PACKET RequestPacket);
196
197#if defined(VBOX_WITH_HGSMI) && defined(VBOX_WITH_VIDEOHWACCEL)
198BOOLEAN VBoxVideoInterrupt(PVOID HwDeviceExtension);
199#endif
200
201
202BOOLEAN VBoxVideoResetHW(
203 PVOID HwDeviceExtension,
204 ULONG Columns,
205 ULONG Rows);
206
207VP_STATUS VBoxVideoGetPowerState(
208 PVOID HwDeviceExtension,
209 ULONG HwId,
210 PVIDEO_POWER_MANAGEMENT VideoPowerControl);
211
212VP_STATUS VBoxVideoSetPowerState(
213 PVOID HwDeviceExtension,
214 ULONG HwId,
215 PVIDEO_POWER_MANAGEMENT VideoPowerControl);
216
217BOOLEAN FASTCALL VBoxVideoSetCurrentMode(
218 PDEVICE_EXTENSION DeviceExtension,
219 PVIDEO_MODE RequestedMode,
220 PSTATUS_BLOCK StatusBlock);
221
222BOOLEAN FASTCALL VBoxVideoResetDevice(
223 PDEVICE_EXTENSION DeviceExtension,
224 PSTATUS_BLOCK StatusBlock);
225
226BOOLEAN FASTCALL VBoxVideoMapVideoMemory(
227 PDEVICE_EXTENSION DeviceExtension,
228 PVIDEO_MEMORY RequestedAddress,
229 PVIDEO_MEMORY_INFORMATION MapInformation,
230 PSTATUS_BLOCK StatusBlock);
231
232BOOLEAN FASTCALL VBoxVideoUnmapVideoMemory(
233 PDEVICE_EXTENSION DeviceExtension,
234 PVIDEO_MEMORY VideoMemory,
235 PSTATUS_BLOCK StatusBlock);
236
237BOOLEAN FASTCALL VBoxVideoQueryNumAvailModes(
238 PDEVICE_EXTENSION DeviceExtension,
239 PVIDEO_NUM_MODES Modes,
240 PSTATUS_BLOCK StatusBlock);
241
242BOOLEAN FASTCALL VBoxVideoQueryAvailModes(
243 PDEVICE_EXTENSION DeviceExtension,
244 PVIDEO_MODE_INFORMATION ReturnedModes,
245 PSTATUS_BLOCK StatusBlock);
246
247BOOLEAN FASTCALL VBoxVideoQueryCurrentMode(
248 PDEVICE_EXTENSION DeviceExtension,
249 PVIDEO_MODE_INFORMATION VideoModeInfo,
250 PSTATUS_BLOCK StatusBlock);
251
252BOOLEAN FASTCALL VBoxVideoSetColorRegisters(
253 PDEVICE_EXTENSION DeviceExtension,
254 PVIDEO_CLUT ColorLookUpTable,
255 PSTATUS_BLOCK StatusBlock);
256
257VP_STATUS VBoxVideoGetChildDescriptor(
258 PVOID HwDeviceExtension,
259 PVIDEO_CHILD_ENUM_INFO ChildEnumInfo,
260 PVIDEO_CHILD_TYPE VideoChildType,
261 PUCHAR pChildDescriptor,
262 PULONG pUId,
263 PULONG pUnused);
264
265int VBoxMapAdapterMemory (PDEVICE_EXTENSION PrimaryExtension,
266 void **ppv,
267 ULONG ulOffset,
268 ULONG ulSize);
269
270void VBoxUnmapAdapterMemory (PDEVICE_EXTENSION PrimaryExtension,
271 void **ppv);
272
273void VBoxComputeFrameBufferSizes (PDEVICE_EXTENSION PrimaryExtension);
274
275#ifdef VBOX_WITH_HGSMI
276
277/*
278 * Host and Guest port IO helpers.
279 */
280DECLINLINE(void) VBoxHGSMIHostWrite(PDEVICE_EXTENSION PrimaryExtension, ULONG data)
281{
282 VideoPortWritePortUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortHost, data);
283}
284
285DECLINLINE(ULONG) VBoxHGSMIHostRead(PDEVICE_EXTENSION PrimaryExtension)
286{
287 return VideoPortReadPortUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortHost);
288}
289
290DECLINLINE(void) VBoxHGSMIGuestWrite(PDEVICE_EXTENSION PrimaryExtension, ULONG data)
291{
292 VideoPortWritePortUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortGuest, data);
293}
294
295DECLINLINE(ULONG) VBoxHGSMIGuestRead(PDEVICE_EXTENSION PrimaryExtension)
296{
297 return VideoPortReadPortUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortGuest);
298}
299
300BOOLEAN VBoxHGSMIIsSupported (PDEVICE_EXTENSION PrimaryExtension);
301
302void VBoxSetupVideoPortFunctions(PDEVICE_EXTENSION PrimaryExtension,
303 VBOXVIDEOPORTPROCS *pCallbacks,
304 PVIDEO_PORT_CONFIG_INFO pConfigInfo);
305
306VOID VBoxSetupDisplaysHGSMI (PDEVICE_EXTENSION PrimaryExtension,
307 PVIDEO_PORT_CONFIG_INFO pConfigInfo,
308 ULONG AdapterMemorySize);
309BOOLEAN vboxUpdatePointerShape (PDEVICE_EXTENSION DeviceExtension,
310 PVIDEO_POINTER_ATTRIBUTES pointerAttr,
311 uint32_t cbLength);
312DECLCALLBACK(void) hgsmiHostCmdComplete (HVBOXVIDEOHGSMI hHGSMI, struct _VBVAHOSTCMD * pCmd);
313DECLCALLBACK(int) hgsmiHostCmdRequest (HVBOXVIDEOHGSMI hHGSMI, uint8_t u8Channel, struct _VBVAHOSTCMD ** ppCmd);
314
315
316int vboxVBVAChannelDisplayEnable(PDEVICE_EXTENSION PrimaryExtension,
317 int iDisplay, /* negative would mean this is a miniport handler */
318 uint8_t u8Channel);
319
320VOID VBoxVideoHGSMIDpc(
321 IN PVOID HwDeviceExtension,
322 IN PVOID Context
323 );
324
325void HGSMIClearIrq (PDEVICE_EXTENSION PrimaryExtension);
326
327#endif /* VBOX_WITH_HGSMI */
328} /* extern "C" */
329
330#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