VirtualBox

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

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

VBoxGuest-win*: More review + cleanup.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.5 KB
Line 
1/* $Id: VBoxGuest-win.h 44991 2013-03-11 14:55:10Z 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#include "VBoxGuestInternal.h"
40
41
42
43/** Possible device states for our state machine. */
44enum DEVSTATE
45{
46 STOPPED,
47 WORKING,
48 PENDINGSTOP,
49 PENDINGREMOVE,
50 SURPRISEREMOVED,
51 REMOVED
52};
53
54typedef struct VBOXGUESTWINBASEADDRESS
55{
56 /** Original device physical address. */
57 PHYSICAL_ADDRESS RangeStart;
58 /** Length of I/O or memory range. */
59 ULONG RangeLength;
60 /** Flag: Unmapped range is I/O or memory range. */
61 BOOLEAN RangeInMemory;
62 /** Mapped I/O or memory range. */
63 PVOID MappedRangeStart;
64 /** Flag: mapped range is I/O or memory range. */
65 BOOLEAN MappedRangeInMemory;
66 /** Flag: resource is mapped (i.e. MmMapIoSpace called). */
67 BOOLEAN ResourceMapped;
68} VBOXGUESTWINBASEADDRESS, *PVBOXGUESTWINBASEADDRESS;
69
70
71/** Windows-specific device extension bits. */
72typedef struct VBOXGUESTDEVEXTWIN
73{
74 VBOXGUESTDEVEXT Core;
75
76 /** Our functional driver object. */
77 PDEVICE_OBJECT pDeviceObject;
78 /** Top of the stack. */
79 PDEVICE_OBJECT pNextLowerDriver;
80 /** Currently active Irp. */
81 IRP *pCurrentIrp;
82 /** Interrupt object pointer. */
83 PKINTERRUPT pInterruptObject;
84
85 /** Bus number where the device is located. */
86 ULONG busNumber;
87 /** Slot number where the device is located. */
88 ULONG slotNumber;
89 /** Device interrupt level. */
90 ULONG interruptLevel;
91 /** Device interrupt vector. */
92 ULONG interruptVector;
93 /** Affinity mask. */
94 KAFFINITY interruptAffinity;
95 /** LevelSensitive or Latched. */
96 KINTERRUPT_MODE interruptMode;
97
98 /** PCI base address information. */
99 ULONG pciAddressCount;
100 VBOXGUESTWINBASEADDRESS pciBaseAddress[PCI_TYPE0_ADDRESSES];
101
102 /** Physical address and length of VMMDev memory. */
103 PHYSICAL_ADDRESS vmmDevPhysMemoryAddress;
104 ULONG vmmDevPhysMemoryLength;
105
106 /** Device state. */
107 DEVSTATE devState;
108 DEVSTATE prevDevState;
109
110 /** Last system power action set (see VBoxGuestPower). */
111 POWER_ACTION LastSystemPowerAction;
112 /** Preallocated generic request for shutdown. */
113 VMMDevPowerStateRequest *pPowerStateRequest;
114 /** Preallocated VMMDevEvents for IRQ handler. */
115 VMMDevEvents *pIrqAckEvents;
116
117 /** Pre-allocated kernel session data. This is needed
118 * for handling kernel IOCtls. */
119 struct VBOXGUESTSESSION *pKernelSession;
120
121 /** Spinlock protecting MouseNotifyCallback. Required since the consumer is
122 * in a DPC callback and not the ISR. */
123 KSPIN_LOCK MouseEventAccessLock;
124} VBOXGUESTDEVEXTWIN, *PVBOXGUESTDEVEXTWIN;
125
126
127/** NT (windows) version identifier. */
128typedef enum VBGDNTVER
129{
130 VBGDNTVER_INVALID = 0,
131 VBGDNTVER_WINNT4,
132 VBGDNTVER_WIN2K,
133 VBGDNTVER_WINXP,
134 VBGDNTVER_WIN2K3,
135 VBGDNTVER_WINVISTA,
136 VBGDNTVER_WIN7,
137 VBGDNTVER_WIN8
138} VBGDNTVER;
139extern VBGDNTVER g_enmVbgdNtVer;
140
141
142#define VBOXGUEST_UPDATE_DEVSTATE(a_pDevExt, a_newDevState) \
143 do { \
144 (a_pDevExt)->prevDevState = (a_pDevExt)->devState; \
145 (a_pDevExt)->devState = (a_newDevState); \
146 } while (0)
147
148/** CM_RESOURCE_MEMORY_* flags which were used on XP or earlier. */
149#define VBOX_CM_PRE_VISTA_MASK (0x3f)
150
151
152RT_C_DECLS_BEGIN
153
154#ifdef TARGET_NT4
155NTSTATUS vbgdNt4CreateDevice(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath);
156#else
157NTSTATUS vbgdNtInit(PDEVICE_OBJECT pDevObj, PIRP pIrp);
158NTSTATUS vbgdNtPnP(PDEVICE_OBJECT pDevObj, PIRP pIrp);
159NTSTATUS vbgdNtPower(PDEVICE_OBJECT pDevObj, PIRP pIrp);
160#endif
161
162/** @name Common routines used in both (PnP and legacy) driver versions.
163 * @{
164 */
165#ifdef TARGET_NT4
166NTSTATUS vbgdNtInit(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath);
167#else
168NTSTATUS vbgdNtInit(PDEVICE_OBJECT pDevObj, PIRP pIrp);
169#endif
170NTSTATUS vbgdNtCleanup(PDEVICE_OBJECT pDevObj);
171VOID vbgdNtDpcHandler(PKDPC pDPC, PDEVICE_OBJECT pDevObj, PIRP pIrp, PVOID pContext);
172BOOLEAN vbgdNtIsrHandler(PKINTERRUPT interrupt, PVOID serviceContext);
173NTSTATUS vbgdNtScanPCIResourceList(PCM_RESOURCE_LIST pResList, PVBOXGUESTDEVEXTWIN pDevExt);
174NTSTATUS vbgdNtMapVMMDevMemory(PVBOXGUESTDEVEXTWIN pDevExt, PHYSICAL_ADDRESS PhysAddr, ULONG cbToMap,
175 void **ppvMMIOBase, uint32_t *pcbMMIO);
176void vbgdNtUnmapVMMDevMemory(PVBOXGUESTDEVEXTWIN pDevExt);
177VBOXOSTYPE vbgdNtVersionToOSType(VBGDNTVER enmNtVer);
178/** @} */
179
180RT_C_DECLS_END
181
182#ifdef TARGET_NT4
183/*
184 * XP DDK #defines ExFreePool to ExFreePoolWithTag. The latter does not exist
185 * on NT4, so... The same for ExAllocatePool.
186 */
187# undef ExAllocatePool
188# undef ExFreePool
189#endif
190
191#endif /* !___VBoxGuest_win_h */
192
193
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