VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/VBoxGuest/VBoxGuest_Internal.h@ 17163

Last change on this file since 17163 was 17163, checked in by vboxsync, 16 years ago

crOpenGL: disconnect hgcm clients when process owning file handle is terminated (public bug #3243)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.0 KB
Line 
1/** @file
2 *
3 * VBoxGuest -- VirtualBox Win32 guest support driver
4 *
5 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
6 *
7 * This file is part of VirtualBox Open Source Edition (OSE), as
8 * available from http://www.virtualbox.org. This file is free software;
9 * you can redistribute it and/or modify it under the terms of the GNU
10 * General Public License (GPL) as published by the Free Software
11 * Foundation, in version 2 as it comes in the "COPYING" file of the
12 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
13 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
14 *
15 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
16 * Clara, CA 95054 USA or visit http://www.sun.com if you need
17 * additional information or have any questions.
18 */
19
20#ifndef __VBOXGUESTINTERNAL_h__
21#define __VBOXGUESTINTERNAL_h__
22
23
24/*******************************************************************************
25* Header Files *
26*******************************************************************************/
27
28#include <iprt/cdefs.h>
29
30#ifdef IN_RING0
31# if (_MSC_VER >= 1400) && !defined(VBOX_WITH_PATCHED_DDK)
32# include <iprt/asm.h>
33# define _InterlockedExchange _InterlockedExchange_StupidDDKVsCompilerCrap
34# define _InterlockedExchangeAdd _InterlockedExchangeAdd_StupidDDKVsCompilerCrap
35# define _InterlockedCompareExchange _InterlockedCompareExchange_StupidDDKVsCompilerCrap
36# define _InterlockedAddLargeStatistic _InterlockedAddLargeStatistic_StupidDDKVsCompilerCrap
37__BEGIN_DECLS
38# include <ntddk.h>
39__END_DECLS
40# undef _InterlockedExchange
41# undef _InterlockedExchangeAdd
42# undef _InterlockedCompareExchange
43# undef _InterlockedAddLargeStatistic
44# else
45__BEGIN_DECLS
46# include <ntddk.h>
47__END_DECLS
48# endif
49#endif
50
51#include <iprt/spinlock.h>
52
53#include <VBox/VBoxGuest.h>
54
55/*******************************************************************************
56* Defined Constants And Macros *
57*******************************************************************************/
58
59
60/* debug printf */
61# define OSDBGPRINT(a) DbgPrint a
62
63/* dprintf */
64#if (defined(DEBUG) && !defined(NO_LOGGING)) || defined(LOG_ENABLED)
65# ifdef LOG_TO_BACKDOOR
66# include <VBox/log.h>
67# define dprintf(a) RTLogBackdoorPrintf a
68# else
69# define dprintf(a) OSDBGPRINT(a)
70# endif
71#else
72# define dprintf(a) do {} while (0)
73#endif
74
75/* dprintf2 - extended logging. */
76#if 0
77# define dprintf2 dprintf
78#else
79# define dprintf2(a) do { } while (0)
80#endif
81
82// the maximum scatter/gather transfer length
83#define MAXIMUM_TRANSFER_LENGTH 64*1024
84
85#define PCI_MAX_BUSES 256
86
87/*
88 * Error codes.
89 */
90
91
92/*******************************************************************************
93* Structures and Typedefs *
94*******************************************************************************/
95
96// possible device states for our state machine
97enum DEVSTATE
98{
99 STOPPED,
100 WORKING,
101 PENDINGSTOP,
102 PENDINGREMOVE,
103 SURPRISEREMOVED,
104 REMOVED
105};
106
107// undocumented API to set the system time
108extern "C"
109{
110NTSYSAPI NTSTATUS NTAPI ZwSetSystemTime(IN PLARGE_INTEGER NewTime, OUT PLARGE_INTEGER OldTime OPTIONAL);
111}
112
113#ifdef IN_RING0
114typedef struct _BASE_ADDRESS {
115
116 PHYSICAL_ADDRESS RangeStart; // Original device physical address
117 ULONG RangeLength; // Length of I/O or memory range
118 BOOLEAN RangeInMemory; // Flag: unmapped range is I/O or memory range
119
120 PVOID MappedRangeStart; // Mapped I/O or memory range
121 BOOLEAN MappedRangeInMemory; // Flag: mapped range is I/O or memory range
122
123 BOOLEAN ResourceMapped; // Flag: resource is mapped (i.e. MmMapIoSpace called)
124
125} BASE_ADDRESS, *PBASE_ADDRESS;
126
127
128/**
129 * Device extension.
130 */
131typedef struct VBOXGUESTDEVEXT
132{
133//// legacy stuff
134 // bus number where the device is located
135 ULONG busNumber;
136 // slot number where the device is located
137 ULONG slotNumber;
138 // device interrupt level
139 ULONG interruptLevel;
140 // device interrupt vector
141 ULONG interruptVector;
142 // affinity mask
143 KAFFINITY interruptAffinity;
144 // LevelSensitive or Latched
145 KINTERRUPT_MODE interruptMode;
146
147 // PCI base address information
148 ULONG addressCount;
149 BASE_ADDRESS baseAddress[PCI_TYPE0_ADDRESSES];
150
151 // adapter object pointer, returned by HalGetAdapter
152 PADAPTER_OBJECT adapterObject;
153
154 // interrupt object pointer
155 PKINTERRUPT interruptObject;
156/////
157
158
159 // our functional driver object
160 PDEVICE_OBJECT deviceObject;
161 // the top of the stack
162 PDEVICE_OBJECT nextLowerDriver;
163 // currently active Irp
164 IRP *currentIrp;
165 PKTHREAD workerThread;
166 PKTHREAD idleThread;
167 KEVENT workerThreadRequest;
168 BOOLEAN stopThread;
169 // device state
170 DEVSTATE devState;
171 // start port address
172 ULONG startPortAddress;
173 // start of hypervisor mapping
174 PVOID hypervisorMapping;
175 // size in bytes of the hypervisor mapping
176 ULONG hypervisorMappingSize;
177
178 /* Physical address and length of VMMDev memory */
179 PHYSICAL_ADDRESS memoryAddress;
180 ULONG memoryLength;
181
182 /* Virtual address of VMMDev memory */
183 VMMDevMemory *pVMMDevMemory;
184
185 /* Pending event flags signalled by host */
186 ULONG u32Events;
187
188 /* Notification semaphore */
189 KEVENT keventNotification;
190
191 LARGE_INTEGER HGCMWaitTimeout;
192
193 /* Old Windows session id */
194 ULONG ulOldActiveConsoleId;
195
196 /* VRDP hook state */
197 BOOLEAN fVRDPEnabled;
198
199 /* Preallocated VMMDevEvents for IRQ handler */
200 VMMDevEvents *irqAckEvents;
201
202#ifdef VBOX_WITH_HGCM
203 /** Spinlock various items in the VBOXGUESTSESSION. */
204 RTSPINLOCK SessionSpinlock;
205#endif
206
207 struct
208 {
209 uint32_t cBalloons;
210 uint32_t cMaxBalloons;
211 PMDL *paMdlMemBalloon;
212 } MemBalloon;
213
214 /* Preallocated generic request for shutdown. */
215 VMMDevPowerStateRequest *powerStateRequest;
216
217} VBOXGUESTDEVEXT, *PVBOXGUESTDEVEXT;
218
219// Windows version identifier
220typedef enum
221{
222 WINNT4 = 1,
223 WIN2K = 2,
224 WINXP = 3,
225 WIN2K3 = 4,
226 WINVISTA = 5
227} winVersion_t;
228extern winVersion_t winVersion;
229
230#ifdef VBOX_WITH_HGCM
231/**
232 * The VBoxGuest per session data.
233 *
234 * @remark Just to store hgcm ID's, perhaps could combine with one from common/VBoxGuest/vboxguestinternal.h?
235 */
236typedef struct VBOXGUESTSESSION
237{
238 /** Array containing HGCM client IDs associated with this session.
239 * This will be automatically disconnected when the session is closed. */
240 uint32_t volatile aHGCMClientIds[8];
241} VBOXGUESTSESSION, *PVBOXGUESTSESSION;
242#endif
243
244extern "C"
245{
246VOID VBoxGuestDpcHandler(PKDPC dpc, PDEVICE_OBJECT pDevObj,
247 PIRP irp, PVOID context);
248BOOLEAN VBoxGuestIsrHandler(PKINTERRUPT interrupt, PVOID serviceContext);
249NTSTATUS createThreads(PVBOXGUESTDEVEXT pDevExt);
250VOID unreserveHypervisorMemory(PVBOXGUESTDEVEXT pDevExt);
251void VBoxInitMemBalloon(PVBOXGUESTDEVEXT pDevExt);
252void VBoxCleanupMemBalloon(PVBOXGUESTDEVEXT pDevExt);
253}
254
255#endif
256
257#endif // __H_VBOXGUESTINTERNAL
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