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 |
|
---|
25 | RT_C_DECLS_BEGIN
|
---|
26 | #include <ntddk.h>
|
---|
27 | RT_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. */
|
---|
41 | typedef struct VBOXGUESTSESSION *PVBOXGUESTSESSION;
|
---|
42 |
|
---|
43 | /** Possible device states for our state machine. */
|
---|
44 | enum DEVSTATE
|
---|
45 | {
|
---|
46 | STOPPED,
|
---|
47 | WORKING,
|
---|
48 | PENDINGSTOP,
|
---|
49 | PENDINGREMOVE,
|
---|
50 | SURPRISEREMOVED,
|
---|
51 | REMOVED
|
---|
52 | };
|
---|
53 |
|
---|
54 | typedef 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 HGCM device extension bits. */
|
---|
72 | typedef struct VBOXGUESTDEVEXTWINHGCM
|
---|
73 | {
|
---|
74 | /** The callback wait timeout. */
|
---|
75 | LARGE_INTEGER WaitTimeout;
|
---|
76 | /** Notification semaphore. */
|
---|
77 | KEVENT keventNotification;
|
---|
78 | } VBOXGUESTDEVEXTWINHGCM, *PVBOXGUESTDEVEXTWINHGCM;
|
---|
79 |
|
---|
80 |
|
---|
81 | /** Windows-specific device extension bits. */
|
---|
82 | typedef struct VBOXGUESTDEVEXTWIN
|
---|
83 | {
|
---|
84 | /** Our functional driver object. */
|
---|
85 | PDEVICE_OBJECT pDeviceObject;
|
---|
86 | /** Top of the stack. */
|
---|
87 | PDEVICE_OBJECT pNextLowerDriver;
|
---|
88 | /** Currently active Irp. */
|
---|
89 | IRP *pCurrentIrp;
|
---|
90 | /** Interrupt object pointer. */
|
---|
91 | PKINTERRUPT pInterruptObject;
|
---|
92 |
|
---|
93 | /** Bus number where the device is located. */
|
---|
94 | ULONG busNumber;
|
---|
95 | /** Slot number where the device is located. */
|
---|
96 | ULONG slotNumber;
|
---|
97 | /** Device interrupt level. */
|
---|
98 | ULONG interruptLevel;
|
---|
99 | /** Device interrupt vector. */
|
---|
100 | ULONG interruptVector;
|
---|
101 | /** Affinity mask. */
|
---|
102 | KAFFINITY interruptAffinity;
|
---|
103 | /** LevelSensitive or Latched. */
|
---|
104 | KINTERRUPT_MODE interruptMode;
|
---|
105 |
|
---|
106 | /** PCI base address information. */
|
---|
107 | ULONG pciAddressCount;
|
---|
108 | VBOXGUESTWINBASEADDRESS pciBaseAddress[PCI_TYPE0_ADDRESSES];
|
---|
109 |
|
---|
110 | /** Physical address and length of VMMDev memory. */
|
---|
111 | PHYSICAL_ADDRESS vmmDevPhysMemoryAddress;
|
---|
112 | ULONG vmmDevPhysMemoryLength;
|
---|
113 |
|
---|
114 | /** Device state. */
|
---|
115 | DEVSTATE devState;
|
---|
116 |
|
---|
117 | /** Last system power action set (see VBoxGuestPower). */
|
---|
118 | POWER_ACTION LastSystemPowerAction;
|
---|
119 | /** Preallocated generic request for shutdown. */
|
---|
120 | VMMDevPowerStateRequest *pPowerStateRequest;
|
---|
121 | /** Preallocated VMMDevEvents for IRQ handler. */
|
---|
122 | VMMDevEvents *pIrqAckEvents;
|
---|
123 |
|
---|
124 | /** Pre-allocated kernel session data. This is needed
|
---|
125 | * for handling kernel IOCtls. */
|
---|
126 | PVBOXGUESTSESSION pKernelSession;
|
---|
127 |
|
---|
128 | /** Align the next bit on a 64-byte boundary and make sure it starts at the same
|
---|
129 | * offset in both 64-bit and 32-bit builds.
|
---|
130 | *
|
---|
131 | * @remarks The aligments of the members that are larger than 48 bytes should be
|
---|
132 | * 64-byte for cache line reasons. structs containing small amounts of
|
---|
133 | * data could be lumped together at the end with a < 64 byte padding
|
---|
134 | * following it (to grow into and align the struct size).
|
---|
135 | */
|
---|
136 | uint8_t abAlignment1[HC_ARCH_BITS == 32 ? 24 : 4];
|
---|
137 |
|
---|
138 | /** HGCM stuff. */
|
---|
139 | union
|
---|
140 | {
|
---|
141 | #ifdef VBOX_WITH_HGCM
|
---|
142 | VBOXGUESTDEVEXTWINHGCM s;
|
---|
143 | #endif
|
---|
144 | uint8_t padding[256]; /* Multiple of 64; fix me! */
|
---|
145 | } hgcm;
|
---|
146 | } VBOXGUESTDEVEXTWIN, *PVBOXGUESTDEVEXTWIN;
|
---|
147 |
|
---|
148 |
|
---|
149 | /*******************************************************************************
|
---|
150 | * Defined Constants And Macros *
|
---|
151 | *******************************************************************************/
|
---|
152 |
|
---|
153 | /** CM_RESOURCE_MEMORY_* flags which were used on XP or earlier. */
|
---|
154 | #define VBOX_CM_PRE_VISTA_MASK (0x3f)
|
---|
155 |
|
---|
156 | /** Windows version identifier. */
|
---|
157 | typedef enum
|
---|
158 | {
|
---|
159 | WINNT4 = 1,
|
---|
160 | WIN2K = 2,
|
---|
161 | WINXP = 3,
|
---|
162 | WIN2K3 = 4,
|
---|
163 | WINVISTA = 5,
|
---|
164 | WIN7 = 6
|
---|
165 | } winVersion_t;
|
---|
166 | extern winVersion_t winVersion;
|
---|
167 |
|
---|
168 |
|
---|
169 | /*******************************************************************************
|
---|
170 | * Declared prototypes for helper routines used in both (PnP and legacy) *
|
---|
171 | * driver versions. *
|
---|
172 | *******************************************************************************/
|
---|
173 | #include "VBoxGuestInternal.h"
|
---|
174 |
|
---|
175 | RT_C_DECLS_BEGIN
|
---|
176 | NTSTATUS vboxguestwinCleanup(PDEVICE_OBJECT pDevObj, PIRP pIrp);
|
---|
177 | NTSTATUS vboxguestwinPnP(PDEVICE_OBJECT pDevObj, PIRP pIrp);
|
---|
178 | VOID vboxguestwinDpcHandler(PKDPC pDPC, PDEVICE_OBJECT pDevObj, PIRP pIrp, PVOID pContext);
|
---|
179 | BOOLEAN vboxguestwinIsrHandler(PKINTERRUPT interrupt, PVOID serviceContext);
|
---|
180 | NTSTATUS vboxguestwinScanPCIResourceList(PCM_RESOURCE_LIST pResList, PVBOXGUESTDEVEXT pDevExt);
|
---|
181 | NTSTATUS vboxguestwinMapVMMDevMemory(PVBOXGUESTDEVEXT pDevExt, PHYSICAL_ADDRESS physicalAdr, ULONG ulLength,
|
---|
182 | void **ppvMMIOBase, uint32_t *pcbMMIO);
|
---|
183 | void vboxguestwinUnmapVMMDevMemory(PVBOXGUESTDEVEXT pDevExt);
|
---|
184 | VBOXOSTYPE vboxguestwinVersionToOSType(winVersion_t winVer);
|
---|
185 | NTSTATUS vboxguestwinPower(PDEVICE_OBJECT pDevObj, PIRP pIrp);
|
---|
186 | RT_C_DECLS_END
|
---|
187 |
|
---|
188 | #endif /* ___VBoxGuest_win_h */
|
---|
189 |
|
---|