VirtualBox

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

Last change on this file since 3254 was 2981, checked in by vboxsync, 17 years ago

InnoTek -> innotek: all the headers and comments.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.0 KB
Line 
1/** @file
2 *
3 * VBoxGuest -- VirtualBox Win32 guest support driver
4 *
5 * Copyright (C) 2006-2007 innotek GmbH
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 as published by the Free Software Foundation,
11 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
12 * distribution. VirtualBox OSE is distributed in the hope that it will
13 * be useful, but WITHOUT ANY WARRANTY of any kind.
14 *
15 * If you received this file as part of a commercial VirtualBox
16 * distribution, then only the terms of your commercial VirtualBox
17 * license agreement apply instead of the previous paragraph.
18 *
19 */
20
21#ifndef __VBOXGUESTINTERNAL_h__
22#define __VBOXGUESTINTERNAL_h__
23
24
25/*******************************************************************************
26* Header Files *
27*******************************************************************************/
28
29#include <iprt/cdefs.h>
30
31#ifdef IN_RING0
32# if (_MSC_VER >= 1400) && !defined(VBOX_WITH_PATCHED_DDK)
33# include <iprt/asm.h>
34# define _InterlockedExchange _InterlockedExchange_StupidDDKVsCompilerCrap
35# define _InterlockedExchangeAdd _InterlockedExchangeAdd_StupidDDKVsCompilerCrap
36# define _InterlockedCompareExchange _InterlockedCompareExchange_StupidDDKVsCompilerCrap
37# define _InterlockedAddLargeStatistic _InterlockedAddLargeStatistic_StupidDDKVsCompilerCrap
38__BEGIN_DECLS
39# include <ntddk.h>
40__END_DECLS
41# undef _InterlockedExchange
42# undef _InterlockedExchangeAdd
43# undef _InterlockedCompareExchange
44# undef _InterlockedAddLargeStatistic
45# else
46__BEGIN_DECLS
47# include <ntddk.h>
48__END_DECLS
49# endif
50#endif
51
52#include <VBox/VBoxGuest.h>
53
54/*******************************************************************************
55* Defined Constants And Macros *
56*******************************************************************************/
57
58
59/* debug printf */
60# define OSDBGPRINT(a) DbgPrint a
61
62/* dprintf */
63#if (defined(DEBUG) && !defined(NO_LOGGING)) || defined(LOG_ENABLED)
64# ifdef LOG_TO_BACKDOOR
65# include <VBox/log.h>
66# define dprintf(a) RTLogBackdoorPrintf a
67# else
68# define dprintf(a) OSDBGPRINT(a)
69# endif
70#else
71# define dprintf(a) do {} while (0)
72#endif
73
74/* dprintf2 - extended logging. */
75#if 0
76# define dprintf2 dprintf
77#else
78# define dprintf2(a) do { } while (0)
79#endif
80
81// the maximum scatter/gather transfer length
82#define MAXIMUM_TRANSFER_LENGTH 64*1024
83
84#define PCI_MAX_BUSES 256
85
86/*
87 * Error codes.
88 */
89
90
91/*******************************************************************************
92* Structures and Typedefs *
93*******************************************************************************/
94
95// possible device states for our state machine
96enum DEVSTATE
97{
98 STOPPED,
99 WORKING,
100 PENDINGSTOP,
101 PENDINGREMOVE,
102 SURPRISEREMOVED,
103 REMOVED
104};
105
106// undocumented API to set the system time
107extern "C"
108{
109NTSYSAPI NTSTATUS NTAPI ZwSetSystemTime(IN PLARGE_INTEGER NewTime, OUT PLARGE_INTEGER OldTime OPTIONAL);
110}
111
112#ifdef IN_RING0
113typedef struct _BASE_ADDRESS {
114
115 PHYSICAL_ADDRESS RangeStart; // Original device physical address
116 ULONG RangeLength; // Length of I/O or memory range
117 BOOLEAN RangeInMemory; // Flag: unmapped range is I/O or memory range
118
119 PVOID MappedRangeStart; // Mapped I/O or memory range
120 BOOLEAN MappedRangeInMemory; // Flag: mapped range is I/O or memory range
121
122 BOOLEAN ResourceMapped; // Flag: resource is mapped (i.e. MmMapIoSpace called)
123
124} BASE_ADDRESS, *PBASE_ADDRESS;
125
126
127/**
128 * Device extension.
129 */
130typedef struct VBOXGUESTDEVEXT
131{
132//// legacy stuff
133 // bus number where the device is located
134 ULONG busNumber;
135 // slot number where the device is located
136 ULONG slotNumber;
137 // device interrupt level
138 ULONG interruptLevel;
139 // device interrupt vector
140 ULONG interruptVector;
141 // affinity mask
142 KAFFINITY interruptAffinity;
143 // LevelSensitive or Latched
144 KINTERRUPT_MODE interruptMode;
145
146 // PCI base address information
147 ULONG addressCount;
148 BASE_ADDRESS baseAddress[PCI_TYPE0_ADDRESSES];
149
150 // adapter object pointer, returned by HalGetAdapter
151 PADAPTER_OBJECT adapterObject;
152
153 // interrupt object pointer
154 PKINTERRUPT interruptObject;
155/////
156
157
158 // our functional driver object
159 PDEVICE_OBJECT deviceObject;
160 // the top of the stack
161 PDEVICE_OBJECT nextLowerDriver;
162 // currently active Irp
163 IRP *currentIrp;
164 PKTHREAD workerThread;
165 PKTHREAD idleThread;
166 KEVENT workerThreadRequest;
167 BOOLEAN stopThread;
168 // device state
169 DEVSTATE devState;
170 // start port address
171 ULONG startPortAddress;
172 // start of hypervisor mapping
173 PVOID hypervisorMapping;
174 // size in bytes of the hypervisor mapping
175 ULONG hypervisorMappingSize;
176
177 /* Physical address and length of VMMDev memory */
178 PHYSICAL_ADDRESS memoryAddress;
179 ULONG memoryLength;
180
181 /* Virtual address of VMMDev memory */
182 VMMDevMemory *pVMMDevMemory;
183
184 /* Pending event flags signalled by host */
185 ULONG u32Events;
186
187 /* Notification semaphore */
188 KEVENT keventNotification;
189
190 /* Preallocated VMMDevEvents for IRQ handler */
191 VMMDevEvents *irqAckEvents;
192
193} VBOXGUESTDEVEXT, *PVBOXGUESTDEVEXT;
194
195// Windows version identifier
196typedef enum
197{
198 WINNT4 = 1,
199 WIN2K = 2,
200 WINXP = 3,
201 WIN2K3 = 4,
202 WINVISTA = 5
203} winVersion_t;
204extern winVersion_t winVersion;
205
206extern "C"
207{
208VOID VBoxGuestDpcHandler(PKDPC dpc, PDEVICE_OBJECT pDevObj,
209 PIRP irp, PVOID context);
210BOOLEAN VBoxGuestIsrHandler(PKINTERRUPT interrupt, PVOID serviceContext);
211NTSTATUS createThreads(PVBOXGUESTDEVEXT pDevExt);
212VOID unreserveHypervisorMemory(PVBOXGUESTDEVEXT pDevExt);
213}
214
215#endif
216
217#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