VirtualBox

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

Last change on this file since 36669 was 36060, checked in by vboxsync, 14 years ago

VBoxGuest-win: PNP cleanup: process only required PNP IRPs according to MSDN.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.1 KB
Line 
1/** @file
2 *
3 * VBoxGuest - Windows specifics.
4 *
5 * Copyright (C) 2010 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 ___VBoxGuest_win_h
17#define ___VBoxGuest_win_h
18
19/*******************************************************************************
20* Header Files *
21*******************************************************************************/
22
23#include <iprt/cdefs.h>
24
25RT_C_DECLS_BEGIN
26#include <ntddk.h>
27RT_C_DECLS_END
28
29#include <iprt/spinlock.h>
30#include <iprt/memobj.h>
31
32#include <VBox/VMMDev.h>
33#include <VBox/VBoxGuest.h>
34
35
36/*******************************************************************************
37* Structures and Typedefs *
38*******************************************************************************/
39
40/** Pointer to the VBoxGuest per session data. */
41typedef struct VBOXGUESTSESSION *PVBOXGUESTSESSION;
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 /** Our functional driver object. */
75 PDEVICE_OBJECT pDeviceObject;
76 /** Top of the stack. */
77 PDEVICE_OBJECT pNextLowerDriver;
78 /** Currently active Irp. */
79 IRP *pCurrentIrp;
80 /** Interrupt object pointer. */
81 PKINTERRUPT pInterruptObject;
82
83 /** Bus number where the device is located. */
84 ULONG busNumber;
85 /** Slot number where the device is located. */
86 ULONG slotNumber;
87 /** Device interrupt level. */
88 ULONG interruptLevel;
89 /** Device interrupt vector. */
90 ULONG interruptVector;
91 /** Affinity mask. */
92 KAFFINITY interruptAffinity;
93 /** LevelSensitive or Latched. */
94 KINTERRUPT_MODE interruptMode;
95
96 /** PCI base address information. */
97 ULONG pciAddressCount;
98 VBOXGUESTWINBASEADDRESS pciBaseAddress[PCI_TYPE0_ADDRESSES];
99
100 /** Physical address and length of VMMDev memory. */
101 PHYSICAL_ADDRESS vmmDevPhysMemoryAddress;
102 ULONG vmmDevPhysMemoryLength;
103
104 /** Device state. */
105 DEVSTATE devState;
106 DEVSTATE prevDevState;
107
108 /** Last system power action set (see VBoxGuestPower). */
109 POWER_ACTION LastSystemPowerAction;
110 /** Preallocated generic request for shutdown. */
111 VMMDevPowerStateRequest *pPowerStateRequest;
112 /** Preallocated VMMDevEvents for IRQ handler. */
113 VMMDevEvents *pIrqAckEvents;
114
115 /** Pre-allocated kernel session data. This is needed
116 * for handling kernel IOCtls. */
117 PVBOXGUESTSESSION pKernelSession;
118} VBOXGUESTDEVEXTWIN, *PVBOXGUESTDEVEXTWIN;
119
120#define VBOXGUEST_UPDATE_DEVSTATE(_pDevExt, _newDevState) do { \
121 (_pDevExt)->win.s.prevDevState = (_pDevExt)->win.s.devState; \
122 (_pDevExt)->win.s.devState = (_newDevState); \
123} while (0)
124
125
126/*******************************************************************************
127* Defined Constants And Macros *
128*******************************************************************************/
129
130/** CM_RESOURCE_MEMORY_* flags which were used on XP or earlier. */
131#define VBOX_CM_PRE_VISTA_MASK (0x3f)
132
133/** Windows version identifier. */
134typedef enum
135{
136 WINNT4 = 1,
137 WIN2K = 2,
138 WINXP = 3,
139 WIN2K3 = 4,
140 WINVISTA = 5,
141 WIN7 = 6
142} winVersion_t;
143extern winVersion_t winVersion;
144
145
146/*******************************************************************************
147* Declared prototypes for helper routines used in both (PnP and legacy) *
148* driver versions. *
149*******************************************************************************/
150#include "VBoxGuestInternal.h"
151
152RT_C_DECLS_BEGIN
153#ifdef TARGET_NT4
154NTSTATUS vboxguestwinnt4CreateDevice(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath);
155NTSTATUS vboxguestwinInit(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath);
156#else
157NTSTATUS vboxguestwinInit(PDEVICE_OBJECT pDevObj, PIRP pIrp);
158#endif
159NTSTATUS vboxguestwinCleanup(PDEVICE_OBJECT pDevObj);
160NTSTATUS vboxguestwinPnP(PDEVICE_OBJECT pDevObj, PIRP pIrp);
161VOID vboxguestwinDpcHandler(PKDPC pDPC, PDEVICE_OBJECT pDevObj, PIRP pIrp, PVOID pContext);
162BOOLEAN vboxguestwinIsrHandler(PKINTERRUPT interrupt, PVOID serviceContext);
163NTSTATUS vboxguestwinScanPCIResourceList(PCM_RESOURCE_LIST pResList, PVBOXGUESTDEVEXT pDevExt);
164NTSTATUS vboxguestwinMapVMMDevMemory(PVBOXGUESTDEVEXT pDevExt, PHYSICAL_ADDRESS physicalAdr, ULONG ulLength,
165 void **ppvMMIOBase, uint32_t *pcbMMIO);
166void vboxguestwinUnmapVMMDevMemory(PVBOXGUESTDEVEXT pDevExt);
167VBOXOSTYPE vboxguestwinVersionToOSType(winVersion_t winVer);
168NTSTATUS vboxguestwinPower(PDEVICE_OBJECT pDevObj, PIRP pIrp);
169RT_C_DECLS_END
170
171#ifdef TARGET_NT4
172/*
173 * XP DDK #defines ExFreePool to ExFreePoolWithTag. The latter does not exist
174 * on NT4, so... The same for ExAllocatePool.
175 */
176#undef ExAllocatePool
177#undef ExFreePool
178#endif
179
180#endif /* ___VBoxGuest_win_h */
181
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