VirtualBox

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

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

VBoxGuest/Windows: Added bugcheck detection + details (not enabled by default yet).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.4 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
127typedef struct
128{
129 KBUGCHECK_CALLBACK_RECORD bugcheckRecord;
130} VBOXBUGCHECKCONTEXT, *PVBOXBUGCHECKCONTEXT;
131
132/**
133 * Device extension.
134 */
135typedef struct VBOXGUESTDEVEXT
136{
137//// legacy stuff
138 // bus number where the device is located
139 ULONG busNumber;
140 // slot number where the device is located
141 ULONG slotNumber;
142 // device interrupt level
143 ULONG interruptLevel;
144 // device interrupt vector
145 ULONG interruptVector;
146 // affinity mask
147 KAFFINITY interruptAffinity;
148 // LevelSensitive or Latched
149 KINTERRUPT_MODE interruptMode;
150
151 // PCI base address information
152 ULONG addressCount;
153 BASE_ADDRESS baseAddress[PCI_TYPE0_ADDRESSES];
154
155 // adapter object pointer, returned by HalGetAdapter
156 PADAPTER_OBJECT adapterObject;
157
158 // interrupt object pointer
159 PKINTERRUPT interruptObject;
160/////
161
162 // the driver name
163 UCHAR szDriverName[32];
164 // our functional driver object
165 PDEVICE_OBJECT deviceObject;
166 // the top of the stack
167 PDEVICE_OBJECT nextLowerDriver;
168 // currently active Irp
169 IRP *currentIrp;
170 PKTHREAD workerThread;
171 PKTHREAD idleThread;
172 KEVENT workerThreadRequest;
173 BOOLEAN stopThread;
174 // device state
175 DEVSTATE devState;
176 // start port address
177 ULONG startPortAddress;
178 // start of hypervisor mapping
179 PVOID hypervisorMapping;
180 // size in bytes of the hypervisor mapping
181 ULONG hypervisorMappingSize;
182
183 /* Physical address and length of VMMDev memory */
184 PHYSICAL_ADDRESS memoryAddress;
185 ULONG memoryLength;
186
187 /* Virtual address of VMMDev memory */
188 VMMDevMemory *pVMMDevMemory;
189
190 /* Pending event flags signalled by host */
191 ULONG u32Events;
192
193 /* Notification semaphore */
194 KEVENT keventNotification;
195
196 LARGE_INTEGER HGCMWaitTimeout;
197
198 /* Old Windows session id */
199 ULONG ulOldActiveConsoleId;
200
201 /* VRDP hook state */
202 BOOLEAN fVRDPEnabled;
203
204 /* Preallocated VMMDevEvents for IRQ handler */
205 VMMDevEvents *irqAckEvents;
206
207#ifdef VBOX_WITH_HGCM
208 /** Spinlock various items in the VBOXGUESTSESSION. */
209 RTSPINLOCK SessionSpinlock;
210#endif
211
212 struct
213 {
214 uint32_t cBalloons;
215 uint32_t cMaxBalloons;
216 PMDL *paMdlMemBalloon;
217 } MemBalloon;
218
219 /* Preallocated generic request for shutdown. */
220 VMMDevPowerStateRequest *powerStateRequest;
221
222 /* Bugcheck context. */
223 BOOLEAN bBugcheckCallbackRegistered;
224 PVBOXBUGCHECKCONTEXT bugcheckContext;
225
226} VBOXGUESTDEVEXT, *PVBOXGUESTDEVEXT;
227
228// Windows version identifier
229typedef enum
230{
231 WINNT4 = 1,
232 WIN2K = 2,
233 WINXP = 3,
234 WIN2K3 = 4,
235 WINVISTA = 5
236} winVersion_t;
237extern winVersion_t winVersion;
238
239#ifdef VBOX_WITH_HGCM
240/**
241 * The VBoxGuest per session data.
242 *
243 * @remark Just to store hgcm ID's, perhaps could combine with one from common/VBoxGuest/vboxguestinternal.h?
244 */
245typedef struct VBOXGUESTSESSION
246{
247 /** Array containing HGCM client IDs associated with this session.
248 * This will be automatically disconnected when the session is closed.
249 * Note that array size also affects/is maximum number of supported opengl threads per guest process.
250 */
251 uint32_t volatile aHGCMClientIds[8];
252} VBOXGUESTSESSION, *PVBOXGUESTSESSION;
253#endif
254
255extern "C"
256{
257VOID VBoxGuestDpcHandler(PKDPC dpc, PDEVICE_OBJECT pDevObj,
258 PIRP irp, PVOID context);
259BOOLEAN VBoxGuestIsrHandler(PKINTERRUPT interrupt, PVOID serviceContext);
260NTSTATUS createThreads(PVBOXGUESTDEVEXT pDevExt);
261VOID unreserveHypervisorMemory(PVBOXGUESTDEVEXT pDevExt);
262void VBoxInitMemBalloon(PVBOXGUESTDEVEXT pDevExt);
263void VBoxCleanupMemBalloon(PVBOXGUESTDEVEXT pDevExt);
264}
265
266#endif
267
268#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