VirtualBox

source: vbox/trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win.h@ 44983

Last change on this file since 44983 was 44983, checked in by vboxsync, 12 years ago

VBoxGuest-win*: cleanups.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.6 KB
Line 
1/* $Id: VBoxGuest-win.h 44983 2013-03-11 13:34:31Z vboxsync $ */
2/** @file
3 * VBoxGuest - Windows specifics.
4 */
5
6/*
7 * Copyright (C) 2010-2013 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef ___VBoxGuest_win_h
19#define ___VBoxGuest_win_h
20
21
22#include <iprt/cdefs.h>
23
24RT_C_DECLS_BEGIN
25#ifdef RT_ARCH_X86
26# define _InterlockedAddLargeStatistic _InterlockedAddLargeStatistic_StupidDDKVsCompilerCrap
27#endif
28#include <ntddk.h>
29#ifdef RT_ARCH_X86
30# undef _InterlockedAddLargeStatistic
31#endif
32RT_C_DECLS_END
33
34#include <iprt/spinlock.h>
35#include <iprt/memobj.h>
36
37#include <VBox/VMMDev.h>
38#include <VBox/VBoxGuest.h>
39
40
41
42/** Possible device states for our state machine. */
43enum DEVSTATE
44{
45 STOPPED,
46 WORKING,
47 PENDINGSTOP,
48 PENDINGREMOVE,
49 SURPRISEREMOVED,
50 REMOVED
51};
52
53typedef struct VBOXGUESTWINBASEADDRESS
54{
55 /** Original device physical address. */
56 PHYSICAL_ADDRESS RangeStart;
57 /** Length of I/O or memory range. */
58 ULONG RangeLength;
59 /** Flag: Unmapped range is I/O or memory range. */
60 BOOLEAN RangeInMemory;
61 /** Mapped I/O or memory range. */
62 PVOID MappedRangeStart;
63 /** Flag: mapped range is I/O or memory range. */
64 BOOLEAN MappedRangeInMemory;
65 /** Flag: resource is mapped (i.e. MmMapIoSpace called). */
66 BOOLEAN ResourceMapped;
67} VBOXGUESTWINBASEADDRESS, *PVBOXGUESTWINBASEADDRESS;
68
69
70/** Windows-specific device extension bits. */
71typedef struct VBOXGUESTDEVEXTWIN
72{
73 /** Our functional driver object. */
74 PDEVICE_OBJECT pDeviceObject;
75 /** Top of the stack. */
76 PDEVICE_OBJECT pNextLowerDriver;
77 /** Currently active Irp. */
78 IRP *pCurrentIrp;
79 /** Interrupt object pointer. */
80 PKINTERRUPT pInterruptObject;
81
82 /** Bus number where the device is located. */
83 ULONG busNumber;
84 /** Slot number where the device is located. */
85 ULONG slotNumber;
86 /** Device interrupt level. */
87 ULONG interruptLevel;
88 /** Device interrupt vector. */
89 ULONG interruptVector;
90 /** Affinity mask. */
91 KAFFINITY interruptAffinity;
92 /** LevelSensitive or Latched. */
93 KINTERRUPT_MODE interruptMode;
94
95 /** PCI base address information. */
96 ULONG pciAddressCount;
97 VBOXGUESTWINBASEADDRESS pciBaseAddress[PCI_TYPE0_ADDRESSES];
98
99 /** Physical address and length of VMMDev memory. */
100 PHYSICAL_ADDRESS vmmDevPhysMemoryAddress;
101 ULONG vmmDevPhysMemoryLength;
102
103 /** Device state. */
104 DEVSTATE devState;
105 DEVSTATE prevDevState;
106
107 /** Last system power action set (see VBoxGuestPower). */
108 POWER_ACTION LastSystemPowerAction;
109 /** Preallocated generic request for shutdown. */
110 VMMDevPowerStateRequest *pPowerStateRequest;
111 /** Preallocated VMMDevEvents for IRQ handler. */
112 VMMDevEvents *pIrqAckEvents;
113
114 /** Pre-allocated kernel session data. This is needed
115 * for handling kernel IOCtls. */
116 struct VBOXGUESTSESSION *pKernelSession;
117
118 /** Spinlock protecting MouseNotifyCallback. Required since the consumer is
119 * in a DPC callback and not the ISR. */
120 KSPIN_LOCK MouseEventAccessLock;
121} VBOXGUESTDEVEXTWIN, *PVBOXGUESTDEVEXTWIN;
122
123
124/** NT (windows) version identifier. */
125typedef enum VBGDNTVER
126{
127 VBGDNTVER_INVALID = 0,
128 VBGDNTVER_WINNT4,
129 VBGDNTVER_WIN2K,
130 VBGDNTVER_WINXP,
131 VBGDNTVER_WIN2K3,
132 VBGDNTVER_WINVISTA,
133 VBGDNTVER_WIN7,
134 VBGDNTVER_WIN8
135} VBGDNTVER;
136extern VBGDNTVER g_enmVbgdNtVer;
137
138
139#define VBOXGUEST_UPDATE_DEVSTATE(a_pDevExt, a_newDevState) \
140 do { \
141 (a_pDevExt)->win.s.prevDevState = (a_pDevExt)->win.s.devState; \
142 (a_pDevExt)->win.s.devState = (a_newDevState); \
143 } while (0)
144
145/** CM_RESOURCE_MEMORY_* flags which were used on XP or earlier. */
146#define VBOX_CM_PRE_VISTA_MASK (0x3f)
147
148
149/* Include the internal header now as we've declared the internal
150 structure and stuff. */
151#include "VBoxGuestInternal.h"
152
153
154RT_C_DECLS_BEGIN
155
156#ifdef TARGET_NT4
157NTSTATUS vbgdNt4CreateDevice(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath);
158#else
159NTSTATUS vbgdNtInit(PDEVICE_OBJECT pDevObj, PIRP pIrp);
160NTSTATUS vbgdNtPnP(PDEVICE_OBJECT pDevObj, PIRP pIrp);
161NTSTATUS vbgdNtPower(PDEVICE_OBJECT pDevObj, PIRP pIrp);
162#endif
163
164/** @name Common routines used in both (PnP and legacy) driver versions.
165 * @{
166 */
167#ifdef TARGET_NT4
168NTSTATUS vbgdNtInit(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath);
169#else
170NTSTATUS vbgdNtInit(PDEVICE_OBJECT pDevObj, PIRP pIrp);
171#endif
172NTSTATUS vbgdNtCleanup(PDEVICE_OBJECT pDevObj);
173VOID vbgdNtDpcHandler(PKDPC pDPC, PDEVICE_OBJECT pDevObj, PIRP pIrp, PVOID pContext);
174BOOLEAN vbgdNtIsrHandler(PKINTERRUPT interrupt, PVOID serviceContext);
175NTSTATUS vbgdNtScanPCIResourceList(PCM_RESOURCE_LIST pResList, PVBOXGUESTDEVEXT pDevExt);
176NTSTATUS vbgdNtMapVMMDevMemory(PVBOXGUESTDEVEXT pDevExt, PHYSICAL_ADDRESS physicalAdr, ULONG ulLength,
177 void **ppvMMIOBase, uint32_t *pcbMMIO);
178void vbgdNtUnmapVMMDevMemory(PVBOXGUESTDEVEXT pDevExt);
179VBOXOSTYPE vbgdNtVersionToOSType(VBGDNTVER enmNtVer);
180/** @} */
181
182RT_C_DECLS_END
183
184#ifdef TARGET_NT4
185/*
186 * XP DDK #defines ExFreePool to ExFreePoolWithTag. The latter does not exist
187 * on NT4, so... The same for ExAllocatePool.
188 */
189# undef ExAllocatePool
190# undef ExFreePool
191#endif
192
193#endif /* !___VBoxGuest_win_h */
194
195
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