VirtualBox

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

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

Automated rebranding to Oracle copyright/license strings via filemuncher

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.5 KB
Line 
1/** @file
2 *
3 * VBoxGuest -- VirtualBox Win32 guest support driver
4 *
5 * Copyright (C) 2006-2007 Oracle Corporation
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
16#ifndef __VBOXGUESTINTERNAL_h__
17#define __VBOXGUESTINTERNAL_h__
18
19
20/*******************************************************************************
21* Header Files *
22*******************************************************************************/
23
24#include <iprt/cdefs.h>
25
26/** @todo Use the-nt-kernel.h and keep the messy stuff all in one place? */
27#ifdef IN_RING0
28# if (_MSC_VER >= 1400) && !defined(VBOX_WITH_PATCHED_DDK)
29# include <iprt/asm.h>
30# define _InterlockedExchange _InterlockedExchange_StupidDDKVsCompilerCrap
31# define _InterlockedExchangeAdd _InterlockedExchangeAdd_StupidDDKVsCompilerCrap
32# define _InterlockedCompareExchange _InterlockedCompareExchange_StupidDDKVsCompilerCrap
33# define _InterlockedAddLargeStatistic _InterlockedAddLargeStatistic_StupidDDKVsCompilerCrap
34# pragma warning(disable : 4163)
35RT_C_DECLS_BEGIN
36# include <ntddk.h>
37RT_C_DECLS_END
38# pragma warning(default : 4163)
39# undef _InterlockedExchange
40# undef _InterlockedExchangeAdd
41# undef _InterlockedCompareExchange
42# undef _InterlockedAddLargeStatistic
43# else
44RT_C_DECLS_BEGIN
45# include <ntddk.h>
46RT_C_DECLS_END
47# endif
48#endif
49
50#include <iprt/spinlock.h>
51#include <iprt/memobj.h>
52
53#include <VBox/VMMDev.h>
54#include <VBox/VBoxGuest.h>
55
56
57/*******************************************************************************
58* Defined Constants And Macros *
59*******************************************************************************/
60
61/* debug printf */
62# define OSDBGPRINT(a) DbgPrint a
63
64/* dprintf */
65#if (defined(DEBUG) && !defined(NO_LOGGING)) || defined(LOG_ENABLED)
66# ifdef LOG_TO_BACKDOOR
67# include <VBox/log.h>
68# define dprintf(a) RTLogBackdoorPrintf a
69# else
70# define dprintf(a) OSDBGPRINT(a)
71# endif
72#else
73# define dprintf(a) do {} while (0)
74#endif
75
76/* dprintf2 - extended logging. */
77#if 0
78# define dprintf2 dprintf
79#else
80# define dprintf2(a) do { } while (0)
81#endif
82
83// the maximum scatter/gather transfer length
84#define MAXIMUM_TRANSFER_LENGTH 64*1024
85
86#define PCI_MAX_BUSES 256
87
88/*
89 * Error codes.
90 */
91
92
93/*******************************************************************************
94* Structures and Typedefs *
95*******************************************************************************/
96
97// possible device states for our state machine
98enum DEVSTATE
99{
100 STOPPED,
101 WORKING,
102 PENDINGSTOP,
103 PENDINGREMOVE,
104 SURPRISEREMOVED,
105 REMOVED
106};
107
108// undocumented API to set the system time
109extern "C"
110{
111NTSYSAPI NTSTATUS NTAPI ZwSetSystemTime(IN PLARGE_INTEGER NewTime, OUT PLARGE_INTEGER OldTime OPTIONAL);
112}
113
114#ifdef IN_RING0
115typedef struct _BASE_ADDRESS {
116
117 PHYSICAL_ADDRESS RangeStart; // Original device physical address
118 ULONG RangeLength; // Length of I/O or memory range
119 BOOLEAN RangeInMemory; // Flag: unmapped range is I/O or memory range
120
121 PVOID MappedRangeStart; // Mapped I/O or memory range
122 BOOLEAN MappedRangeInMemory; // Flag: mapped range is I/O or memory range
123
124 BOOLEAN ResourceMapped; // Flag: resource is mapped (i.e. MmMapIoSpace called)
125
126} BASE_ADDRESS, *PBASE_ADDRESS;
127
128
129/**
130 * Device extension.
131 */
132typedef struct VBOXGUESTDEVEXT
133{
134//// legacy stuff
135 // bus number where the device is located
136 ULONG busNumber;
137 // slot number where the device is located
138 ULONG slotNumber;
139 // device interrupt level
140 ULONG interruptLevel;
141 // device interrupt vector
142 ULONG interruptVector;
143 // affinity mask
144 KAFFINITY interruptAffinity;
145 // LevelSensitive or Latched
146 KINTERRUPT_MODE interruptMode;
147
148 // PCI base address information
149 ULONG addressCount;
150 BASE_ADDRESS baseAddress[PCI_TYPE0_ADDRESSES];
151
152 // adapter object pointer, returned by HalGetAdapter
153 PADAPTER_OBJECT adapterObject;
154
155 // interrupt object pointer
156 PKINTERRUPT interruptObject;
157/////
158
159 // the driver name
160 UCHAR szDriverName[32];
161 // our functional driver object
162 PDEVICE_OBJECT deviceObject;
163 // the top of the stack
164 PDEVICE_OBJECT nextLowerDriver;
165 // currently active Irp
166 IRP *currentIrp;
167 PKTHREAD workerThread;
168 PKTHREAD idleThread;
169 KEVENT workerThreadRequest;
170 BOOLEAN stopThread;
171 // device state
172 DEVSTATE devState;
173 // start port address
174 ULONG startPortAddress;
175 // start of hypervisor mapping
176 PVOID hypervisorMapping;
177 // size in bytes of the hypervisor mapping
178 ULONG hypervisorMappingSize;
179
180 /* Patch memory object. */
181 RTR0MEMOBJ PatchMemObj;
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 cBalloonChunks;
215 uint32_t cMaxBalloonChunks;
216 PMDL *paMdlMemBalloon;
217 } MemBalloon;
218
219 /* Preallocated generic request for shutdown. */
220 VMMDevPowerStateRequest *powerStateRequest;
221
222 /** Is the bugcheck callback registered? */
223 BOOLEAN bBugcheckCallbackRegistered;
224 /** The bugcheck registration record. */
225 KBUGCHECK_CALLBACK_RECORD bugcheckRecord;
226
227} VBOXGUESTDEVEXT, *PVBOXGUESTDEVEXT;
228
229// Windows version identifier
230typedef enum
231{
232 WINNT4 = 1,
233 WIN2K = 2,
234 WINXP = 3,
235 WIN2K3 = 4,
236 WINVISTA = 5,
237 WIN7 = 6
238} winVersion_t;
239extern winVersion_t winVersion;
240
241#ifdef VBOX_WITH_HGCM
242/**
243 * The VBoxGuest per session data.
244 *
245 * @remark Just to store hgcm ID's, perhaps could combine with one from common/VBoxGuest/vboxguestinternal.h?
246 */
247typedef struct VBOXGUESTSESSION
248{
249 /** Array containing HGCM client IDs associated with this session.
250 * This will be automatically disconnected when the session is closed.
251 * Note that array size also affects/is maximum number of supported opengl threads per guest process.
252 */
253 uint32_t volatile aHGCMClientIds[8];
254} VBOXGUESTSESSION, *PVBOXGUESTSESSION;
255#endif
256
257extern "C"
258{
259VOID VBoxGuestDpcHandler(PKDPC dpc, PDEVICE_OBJECT pDevObj,
260 PIRP irp, PVOID context);
261BOOLEAN VBoxGuestIsrHandler(PKINTERRUPT interrupt, PVOID serviceContext);
262NTSTATUS createThreads(PVBOXGUESTDEVEXT pDevExt);
263VOID unreserveHypervisorMemory(PVBOXGUESTDEVEXT pDevExt);
264void VBoxInitMemBalloon(PVBOXGUESTDEVEXT pDevExt);
265void VBoxCleanupMemBalloon(PVBOXGUESTDEVEXT pDevExt);
266}
267
268#endif
269
270#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