1 | /* $Id: PDMInternal.h 1447 2007-03-13 15:52:59Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * PDM - Internal header file.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006 InnoTek Systemberatung GmbH
|
---|
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 as published by the Free Software Foundation,
|
---|
13 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
14 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
15 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * If you received this file as part of a commercial VirtualBox
|
---|
18 | * distribution, then only the terms of your commercial VirtualBox
|
---|
19 | * license agreement apply instead of the previous paragraph.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #ifndef __PDMInternal_h__
|
---|
23 | #define __PDMInternal_h__
|
---|
24 |
|
---|
25 | #include <VBox/cdefs.h>
|
---|
26 | #include <VBox/types.h>
|
---|
27 | #include <VBox/param.h>
|
---|
28 | #include <VBox/cfgm.h>
|
---|
29 | #include <VBox/stam.h>
|
---|
30 | #include <iprt/critsect.h>
|
---|
31 |
|
---|
32 | __BEGIN_DECLS
|
---|
33 |
|
---|
34 |
|
---|
35 | /** @defgroup grp_pdm_int Internal
|
---|
36 | * @ingroup grp_pdm
|
---|
37 | * @internal
|
---|
38 | * @{
|
---|
39 | */
|
---|
40 |
|
---|
41 | /** Pointer to a PDM Device. */
|
---|
42 | typedef struct PDMDEV *PPDMDEV;
|
---|
43 | /** Pointer to a pointer to a PDM Device. */
|
---|
44 | typedef PPDMDEV *PPPDMDEV;
|
---|
45 |
|
---|
46 | /** Pointer to a PDM Driver. */
|
---|
47 | typedef struct PDMDRV *PPDMDRV;
|
---|
48 | /** Pointer to a pointer to a PDM Driver. */
|
---|
49 | typedef PPDMDRV *PPPDMDRV;
|
---|
50 |
|
---|
51 | /** Pointer to a PDM Logical Unit. */
|
---|
52 | typedef struct PDMLUN *PPDMLUN;
|
---|
53 | /** Pointer to a pointer to a PDM Logical Unit. */
|
---|
54 | typedef PPDMLUN *PPPDMLUN;
|
---|
55 |
|
---|
56 | /** Pointer to a PDM PCI Bus instance. */
|
---|
57 | typedef struct PDMPCIBUS *PPDMPCIBUS;
|
---|
58 | /** Pointer to a DMAC instance. */
|
---|
59 | typedef struct PDMDMAC *PPDMDMAC;
|
---|
60 | /** Pointer to a RTC instance. */
|
---|
61 | typedef struct PDMRTC *PPDMRTC;
|
---|
62 |
|
---|
63 |
|
---|
64 | /**
|
---|
65 | * Private instance data.
|
---|
66 | */
|
---|
67 | typedef struct PDMDEVINSINT
|
---|
68 | {
|
---|
69 | /** Pointer to the next instance (HC Ptr).
|
---|
70 | * (Head is pointed to by PDM::pDevInstances.) */
|
---|
71 | HCPTRTYPE(PPDMDEVINS) pNextHC;
|
---|
72 | /** Pointer to the next per device instance (HC Ptr).
|
---|
73 | * (Head is pointed to by PDMDEV::pInstances.) */
|
---|
74 | HCPTRTYPE(PPDMDEVINS) pPerDeviceNextHC;
|
---|
75 |
|
---|
76 | /** Pointer to device structure - HC Ptr. */
|
---|
77 | HCPTRTYPE(PPDMDEV) pDevHC;
|
---|
78 |
|
---|
79 | /** Pointer to the VM this instance was created for - HC Ptr. */
|
---|
80 | HCPTRTYPE(PVM) pVMHC;
|
---|
81 | /** Pointer to the list of logical units associated with the device. (FIFO) */
|
---|
82 | HCPTRTYPE(PPDMLUN) pLunsHC;
|
---|
83 | /** Configuration handle to the instance node. */
|
---|
84 | HCPTRTYPE(PCFGMNODE) pCfgHandle;
|
---|
85 | /** HC pointer to associated PCI device structure. */
|
---|
86 | HCPTRTYPE(struct PCIDevice *) pPciDeviceHC;
|
---|
87 | /** HC pointer to associated PCI bus structure. */
|
---|
88 | HCPTRTYPE(PPDMPCIBUS) pPciBusHC;
|
---|
89 |
|
---|
90 | /** GC pointer to associated PCI device structure. */
|
---|
91 | GCPTRTYPE(struct PCIDevice *) pPciDeviceGC;
|
---|
92 | /** Pointer to the VM this instance was created for - GC Ptr. */
|
---|
93 | GCPTRTYPE(PVM) pVMGC;
|
---|
94 | /** GC pointer to associated PCI bus structure. */
|
---|
95 | GCPTRTYPE(PPDMPCIBUS) pPciBusGC;
|
---|
96 | #if GC_ARCH_BITS == 32
|
---|
97 | uint32_t Alignment0;
|
---|
98 | #endif
|
---|
99 | } PDMDEVINSINT;
|
---|
100 |
|
---|
101 |
|
---|
102 | /**
|
---|
103 | * Private instance data.
|
---|
104 | */
|
---|
105 | typedef struct PDMDRVINSINT
|
---|
106 | {
|
---|
107 | /** Pointer to the driver instance above.
|
---|
108 | * This is NULL for the topmost drive. */
|
---|
109 | PPDMDRVINS pUp;
|
---|
110 | /** Pointer to the driver instance below.
|
---|
111 | * This is NULL for the bottommost driver. */
|
---|
112 | PPDMDRVINS pDown;
|
---|
113 | /** Pointer to the logical unit this driver chained on. */
|
---|
114 | PPDMLUN pLun;
|
---|
115 | /** Pointer to driver structure from which this was instantiated. */
|
---|
116 | PPDMDRV pDrv;
|
---|
117 | /** Pointer to the VM this instance was created for. */
|
---|
118 | PVM pVM;
|
---|
119 | /** Flag indicating that the driver is being detached and destroyed.
|
---|
120 | * (Helps detect potential recursive detaching.) */
|
---|
121 | bool fDetaching;
|
---|
122 | /** Configuration handle to the instance node. */
|
---|
123 | PCFGMNODE pCfgHandle;
|
---|
124 |
|
---|
125 | } PDMDRVINSINT;
|
---|
126 |
|
---|
127 |
|
---|
128 | /**
|
---|
129 | * Private critical section data.
|
---|
130 | */
|
---|
131 | typedef struct PDMCRITSECTINT
|
---|
132 | {
|
---|
133 | /** The critical section core which is shared with IPRT. */
|
---|
134 | RTCRITSECT Core;
|
---|
135 | /** Pointer to the next critical section.
|
---|
136 | * This chain is used for relocating pVMGC and device cleanup. */
|
---|
137 | R3PTRTYPE(struct PDMCRITSECTINT *) pNext;
|
---|
138 | /** Owner identifier.
|
---|
139 | * This is pDevIns if the owner is a device. Similarily for a driver or service.
|
---|
140 | * PDMR3CritSectInit() sets this to point to the critsect itself. */
|
---|
141 | RTR3PTR pvKey;
|
---|
142 | /** Pointer to the VM - R3Ptr. */
|
---|
143 | R3PTRTYPE(PVM) pVMR3;
|
---|
144 | /** Pointer to the VM - R0Ptr. */
|
---|
145 | R0PTRTYPE(PVM) pVMR0;
|
---|
146 | /** Pointer to the VM - GCPtr. */
|
---|
147 | GCPTRTYPE(PVM) pVMGC;
|
---|
148 | #if GC_ARCH_BITS == 32
|
---|
149 | uint32_t u32Padding;
|
---|
150 | #endif
|
---|
151 | /** R0/GC lock contention. */
|
---|
152 | STAMCOUNTER StatContentionR0GCLock;
|
---|
153 | /** R0/GC unlock contention. */
|
---|
154 | STAMCOUNTER StatContentionR0GCUnlock;
|
---|
155 | /** R3 lock contention. */
|
---|
156 | STAMCOUNTER StatContentionR3;
|
---|
157 | /** Profiling the time the section is locked. */
|
---|
158 | STAMPROFILEADV StatLocked;
|
---|
159 | } PDMCRITSECTINT, *PPDMCRITSECTINT;
|
---|
160 |
|
---|
161 |
|
---|
162 | /* Must be included after PDMDEVINSINT is defined. */
|
---|
163 | #define PDMDEVINSINT_DECLARED
|
---|
164 | #define PDMDRVINSINT_DECLARED
|
---|
165 | #define PDMCRITSECTINT_DECLARED
|
---|
166 | #ifdef __VBox_pdm_h__
|
---|
167 | # error "Invalid header PDM order. Include PDMInternal.h before VBox/pdm.h!"
|
---|
168 | #endif
|
---|
169 | #include <VBox/pdm.h>
|
---|
170 |
|
---|
171 |
|
---|
172 |
|
---|
173 | /**
|
---|
174 | * PDM Logical Unit.
|
---|
175 | *
|
---|
176 | * This typically the representation of a physical port on a
|
---|
177 | * device, like for instance the PS/2 keyboard port on the
|
---|
178 | * keyboard controller device. The LUNs are chained on the
|
---|
179 | * device the belong to (PDMDEVINSINT::pLunsHC).
|
---|
180 | */
|
---|
181 | typedef struct PDMLUN
|
---|
182 | {
|
---|
183 | /** The LUN - The Logical Unit Number. */
|
---|
184 | RTUINT iLun;
|
---|
185 | /** Pointer to the next LUN. */
|
---|
186 | PPDMLUN pNext;
|
---|
187 | /** Pointer to the top driver in the driver chain. */
|
---|
188 | PPDMDRVINS pTop;
|
---|
189 | /** Pointer to the device instance which the LUN belongs to. */
|
---|
190 | PPDMDEVINS pDevIns;
|
---|
191 | /** Pointer to the device base interface. */
|
---|
192 | PPDMIBASE pBase;
|
---|
193 | /** Description of this LUN. */
|
---|
194 | const char *pszDesc;
|
---|
195 | } PDMLUN;
|
---|
196 |
|
---|
197 |
|
---|
198 | /**
|
---|
199 | * PDM Device.
|
---|
200 | */
|
---|
201 | typedef struct PDMDEV
|
---|
202 | {
|
---|
203 | /** Pointer to the next device (HC Ptr). */
|
---|
204 | HCPTRTYPE(PPDMDEV) pNext;
|
---|
205 | /** Device name length. (search optimization) */
|
---|
206 | RTUINT cchName;
|
---|
207 | /** Registration structure. */
|
---|
208 | HCPTRTYPE(const struct PDMDEVREG *) pDevReg;
|
---|
209 | /** Number of instances. */
|
---|
210 | RTUINT cInstances;
|
---|
211 | /** Pointer to chain of instances (HC Ptr). */
|
---|
212 | HCPTRTYPE(PPDMDEVINS) pInstances;
|
---|
213 |
|
---|
214 | } PDMDEV;
|
---|
215 |
|
---|
216 |
|
---|
217 | /**
|
---|
218 | * PDM Driver.
|
---|
219 | */
|
---|
220 | typedef struct PDMDRV
|
---|
221 | {
|
---|
222 | /** Pointer to the next device. */
|
---|
223 | PPDMDRV pNext;
|
---|
224 | /** Registration structure. */
|
---|
225 | const struct PDMDRVREG *pDrvReg;
|
---|
226 | /** Number of instances. */
|
---|
227 | RTUINT cInstances;
|
---|
228 |
|
---|
229 | } PDMDRV;
|
---|
230 |
|
---|
231 |
|
---|
232 | /**
|
---|
233 | * PDM registered PIC device.
|
---|
234 | */
|
---|
235 | typedef struct PDMPIC
|
---|
236 | {
|
---|
237 | /** Pointer to the PIC device instance - HC. */
|
---|
238 | HCPTRTYPE(PPDMDEVINS) pDevInsR3;
|
---|
239 | /** @copydoc PDMPICREG::pfnSetIrqHC */
|
---|
240 | DECLR3CALLBACKMEMBER(void, pfnSetIrqR3,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
|
---|
241 | /** @copydoc PDMPICREG::pfnGetInterruptHC */
|
---|
242 | DECLR3CALLBACKMEMBER(int, pfnGetInterruptR3,(PPDMDEVINS pDevIns));
|
---|
243 |
|
---|
244 | /** Pointer to the PIC device instance - R0. */
|
---|
245 | R0PTRTYPE(PPDMDEVINS) pDevInsR0;
|
---|
246 | /** @copydoc PDMPICREG::pfnSetIrqHC */
|
---|
247 | DECLR0CALLBACKMEMBER(void, pfnSetIrqR0,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
|
---|
248 | /** @copydoc PDMPICREG::pfnGetInterruptHC */
|
---|
249 | DECLR0CALLBACKMEMBER(int, pfnGetInterruptR0,(PPDMDEVINS pDevIns));
|
---|
250 |
|
---|
251 | /** Pointer to the PIC device instance - GC. */
|
---|
252 | GCPTRTYPE(PPDMDEVINS) pDevInsGC;
|
---|
253 | /** @copydoc PDMPICREG::pfnSetIrqHC */
|
---|
254 | DECLGCCALLBACKMEMBER(void, pfnSetIrqGC,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
|
---|
255 | /** @copydoc PDMPICREG::pfnGetInterruptHC */
|
---|
256 | DECLGCCALLBACKMEMBER(int, pfnGetInterruptGC,(PPDMDEVINS pDevIns));
|
---|
257 | #if GC_ARCH_BITS == 32
|
---|
258 | RTGCPTR GCPtrPadding; /**< Alignment padding. */
|
---|
259 | #endif
|
---|
260 | } PDMPIC;
|
---|
261 |
|
---|
262 |
|
---|
263 | /**
|
---|
264 | * PDM registered APIC device.
|
---|
265 | */
|
---|
266 | typedef struct PDMAPIC
|
---|
267 | {
|
---|
268 | /** Pointer to the APIC device instance - HC Ptr. */
|
---|
269 | PPDMDEVINSHC pDevInsR3;
|
---|
270 | /** @copydoc PDMAPICREG::pfnGetInterruptHC */
|
---|
271 | DECLR3CALLBACKMEMBER(int, pfnGetInterruptR3,(PPDMDEVINS pDevIns));
|
---|
272 | /** @copydoc PDMAPICREG::pfnSetBaseHC */
|
---|
273 | DECLR3CALLBACKMEMBER(void, pfnSetBaseR3,(PPDMDEVINS pDevIns, uint64_t u64Base));
|
---|
274 | /** @copydoc PDMAPICREG::pfnGetBaseHC */
|
---|
275 | DECLR3CALLBACKMEMBER(uint64_t, pfnGetBaseR3,(PPDMDEVINS pDevIns));
|
---|
276 | /** @copydoc PDMAPICREG::pfnSetTPRHC */
|
---|
277 | DECLR3CALLBACKMEMBER(void, pfnSetTPRR3,(PPDMDEVINS pDevIns, uint8_t u8TPR));
|
---|
278 | /** @copydoc PDMAPICREG::pfnGetTPRHC */
|
---|
279 | DECLR3CALLBACKMEMBER(uint8_t, pfnGetTPRR3,(PPDMDEVINS pDevIns));
|
---|
280 | /** @copydoc PDMAPICREG::pfnBusDeliverHC */
|
---|
281 | DECLR3CALLBACKMEMBER(void, pfnBusDeliverR3,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
|
---|
282 | uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode));
|
---|
283 |
|
---|
284 | /** Pointer to the PIC device instance - R0. */
|
---|
285 | R0PTRTYPE(PPDMDEVINS) pDevInsR0;
|
---|
286 | /** @copydoc PDMAPICREG::pfnGetInterruptHC */
|
---|
287 | DECLR0CALLBACKMEMBER(int, pfnGetInterruptR0,(PPDMDEVINS pDevIns));
|
---|
288 | /** @copydoc PDMAPICREG::pfnSetBaseHC */
|
---|
289 | DECLR0CALLBACKMEMBER(void, pfnSetBaseR0,(PPDMDEVINS pDevIns, uint64_t u64Base));
|
---|
290 | /** @copydoc PDMAPICREG::pfnGetBaseHC */
|
---|
291 | DECLR0CALLBACKMEMBER(uint64_t, pfnGetBaseR0,(PPDMDEVINS pDevIns));
|
---|
292 | /** @copydoc PDMAPICREG::pfnSetTPRHC */
|
---|
293 | DECLR0CALLBACKMEMBER(void, pfnSetTPRR0,(PPDMDEVINS pDevIns, uint8_t u8TPR));
|
---|
294 | /** @copydoc PDMAPICREG::pfnGetTPRHC */
|
---|
295 | DECLR0CALLBACKMEMBER(uint8_t, pfnGetTPRR0,(PPDMDEVINS pDevIns));
|
---|
296 | /** @copydoc PDMAPICREG::pfnBusDeliverHC */
|
---|
297 | DECLR0CALLBACKMEMBER(void, pfnBusDeliverR0,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
|
---|
298 | uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode));
|
---|
299 |
|
---|
300 | /** Pointer to the APIC device instance - GC Ptr. */
|
---|
301 | PPDMDEVINSGC pDevInsGC;
|
---|
302 | /** @copydoc PDMAPICREG::pfnGetInterruptHC */
|
---|
303 | DECLGCCALLBACKMEMBER(int, pfnGetInterruptGC,(PPDMDEVINS pDevIns));
|
---|
304 | /** @copydoc PDMAPICREG::pfnSetBaseHC */
|
---|
305 | DECLGCCALLBACKMEMBER(void, pfnSetBaseGC,(PPDMDEVINS pDevIns, uint64_t u64Base));
|
---|
306 | /** @copydoc PDMAPICREG::pfnGetBaseHC */
|
---|
307 | DECLGCCALLBACKMEMBER(uint64_t, pfnGetBaseGC,(PPDMDEVINS pDevIns));
|
---|
308 | /** @copydoc PDMAPICREG::pfnSetTPRHC */
|
---|
309 | DECLGCCALLBACKMEMBER(void, pfnSetTPRGC,(PPDMDEVINS pDevIns, uint8_t u8TPR));
|
---|
310 | /** @copydoc PDMAPICREG::pfnGetTPRHC */
|
---|
311 | DECLGCCALLBACKMEMBER(uint8_t, pfnGetTPRGC,(PPDMDEVINS pDevIns));
|
---|
312 | /** @copydoc PDMAPICREG::pfnBusDeliverHC */
|
---|
313 | DECLGCCALLBACKMEMBER(void, pfnBusDeliverGC,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode,
|
---|
314 | uint8_t iVector, uint8_t u8Polarity, uint8_t u8TriggerMode));
|
---|
315 | #if GC_ARCH_BITS == 32
|
---|
316 | RTGCPTR GCPtrPadding; /**< Alignment padding. */
|
---|
317 | #endif
|
---|
318 | } PDMAPIC;
|
---|
319 |
|
---|
320 |
|
---|
321 | /**
|
---|
322 | * PDM registered I/O APIC device.
|
---|
323 | */
|
---|
324 | typedef struct PDMIOAPIC
|
---|
325 | {
|
---|
326 | /** Pointer to the APIC device instance - HC Ptr. */
|
---|
327 | PPDMDEVINSHC pDevInsR3;
|
---|
328 | /** @copydoc PDMIOAPICREG::pfnSetIrqHC */
|
---|
329 | DECLR3CALLBACKMEMBER(void, pfnSetIrqR3,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
|
---|
330 |
|
---|
331 | /** Pointer to the PIC device instance - R0. */
|
---|
332 | R0PTRTYPE(PPDMDEVINS) pDevInsR0;
|
---|
333 | /** @copydoc PDMIOAPICREG::pfnSetIrqHC */
|
---|
334 | DECLR0CALLBACKMEMBER(void, pfnSetIrqR0,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
|
---|
335 |
|
---|
336 | /** Pointer to the APIC device instance - GC Ptr. */
|
---|
337 | PPDMDEVINSGC pDevInsGC;
|
---|
338 | /** @copydoc PDMIOAPICREG::pfnSetIrqHC */
|
---|
339 | DECLGCCALLBACKMEMBER(void, pfnSetIrqGC,(PPDMDEVINS pDevIns, int iIrq, int iLevel));
|
---|
340 | } PDMIOAPIC;
|
---|
341 |
|
---|
342 |
|
---|
343 | /**
|
---|
344 | * PDM PCI Bus instance.
|
---|
345 | */
|
---|
346 | typedef struct PDMPCIBUS
|
---|
347 | {
|
---|
348 | /** PCI bus number. */
|
---|
349 | RTUINT iBus;
|
---|
350 | RTUINT uPadding0; /**< Alignment padding.*/
|
---|
351 |
|
---|
352 | /** Pointer to PCI Bus device instance. */
|
---|
353 | PPDMDEVINSHC pDevInsR3;
|
---|
354 | /** @copydoc PDMPCIBUSREG::pfnSetIrqHC */
|
---|
355 | DECLR3CALLBACKMEMBER(void, pfnSetIrqR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, int iIrq, int iLevel));
|
---|
356 | /** @copydoc PDMPCIBUSREG::pfnRegisterHC */
|
---|
357 | DECLR3CALLBACKMEMBER(int, pfnRegisterR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, const char *pszName, int iDev));
|
---|
358 | /** @copydoc PDMPCIBUSREG::pfnIORegionRegisterHC */
|
---|
359 | DECLR3CALLBACKMEMBER(int, pfnIORegionRegisterR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, int iRegion, uint32_t cbRegion,
|
---|
360 | PCIADDRESSSPACE enmType, PFNPCIIOREGIONMAP pfnCallback));
|
---|
361 | /** @copydoc PDMPCIBUSREG::pfnSaveExecHC */
|
---|
362 | DECLR3CALLBACKMEMBER(int, pfnSaveExecR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PSSMHANDLE pSSMHandle));
|
---|
363 | /** @copydoc PDMPCIBUSREG::pfnLoadExecHC */
|
---|
364 | DECLR3CALLBACKMEMBER(int, pfnLoadExecR3,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, PSSMHANDLE pSSMHandle));
|
---|
365 | /** @copydoc PDMPCIBUSREG::pfnFakePCIBIOSHC */
|
---|
366 | DECLR3CALLBACKMEMBER(int, pfnFakePCIBIOSR3,(PPDMDEVINS pDevIns));
|
---|
367 |
|
---|
368 | /** Pointer to the PIC device instance - R0. */
|
---|
369 | R0PTRTYPE(PPDMDEVINS) pDevInsR0;
|
---|
370 | /** @copydoc PDMPCIBUSREG::pfnSetIrqHC */
|
---|
371 | DECLR0CALLBACKMEMBER(void, pfnSetIrqR0,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, int iIrq, int iLevel));
|
---|
372 |
|
---|
373 | /** Pointer to PCI Bus device instance. */
|
---|
374 | PPDMDEVINSGC pDevInsGC;
|
---|
375 | /** @copydoc PDMPCIBUSREG::pfnSetIrqHC */
|
---|
376 | DECLGCCALLBACKMEMBER(void, pfnSetIrqGC,(PPDMDEVINS pDevIns, PPCIDEVICE pPciDev, int iIrq, int iLevel));
|
---|
377 | } PDMPCIBUS;
|
---|
378 |
|
---|
379 |
|
---|
380 | #ifdef IN_RING3
|
---|
381 | /**
|
---|
382 | * PDM registered DMAC (DMA Controller) device.
|
---|
383 | */
|
---|
384 | typedef struct PDMDMAC
|
---|
385 | {
|
---|
386 | /** Pointer to the DMAC device instance. */
|
---|
387 | PPDMDEVINS pDevIns;
|
---|
388 | /** Copy of the registration structure. */
|
---|
389 | PDMDMACREG Reg;
|
---|
390 | } PDMDMAC;
|
---|
391 |
|
---|
392 |
|
---|
393 | /**
|
---|
394 | * PDM registered RTC (Real Time Clock) device.
|
---|
395 | */
|
---|
396 | typedef struct PDMRTC
|
---|
397 | {
|
---|
398 | /** Pointer to the RTC device instance. */
|
---|
399 | PPDMDEVINS pDevIns;
|
---|
400 | /** Copy of the registration structure. */
|
---|
401 | PDMRTCREG Reg;
|
---|
402 | } PDMRTC;
|
---|
403 |
|
---|
404 | #endif /* IN_RING3 */
|
---|
405 |
|
---|
406 | /**
|
---|
407 | * Module type.
|
---|
408 | */
|
---|
409 | typedef enum PDMMODTYPE
|
---|
410 | {
|
---|
411 | /** Guest context module. */
|
---|
412 | PDMMOD_TYPE_GC,
|
---|
413 | /** Ring-0 (host) context module. */
|
---|
414 | PDMMOD_TYPE_R0,
|
---|
415 | /** Ring-3 (host) context module. */
|
---|
416 | PDMMOD_TYPE_R3
|
---|
417 | } PDMMODTYPE, *PPDMMODTYPE;
|
---|
418 |
|
---|
419 |
|
---|
420 | /** The module name length including the terminator. */
|
---|
421 | #define PDMMOD_NAME_LEN 32
|
---|
422 |
|
---|
423 | /**
|
---|
424 | * Loaded module instance.
|
---|
425 | */
|
---|
426 | typedef struct PDMMOD
|
---|
427 | {
|
---|
428 | /** Module name. This is used for refering to
|
---|
429 | * the module internally, sort of like a handle. */
|
---|
430 | char szName[PDMMOD_NAME_LEN];
|
---|
431 | /** Module type. */
|
---|
432 | PDMMODTYPE eType;
|
---|
433 | /** Loader module handle. Not used for R0 modules. */
|
---|
434 | RTLDRMOD hLdrMod;
|
---|
435 | /** Loaded address.
|
---|
436 | * This is the 'handle' for R0 modules. */
|
---|
437 | RTUINTPTR ImageBase;
|
---|
438 | /** Old loaded address.
|
---|
439 | * This is used during relocation of GC modules. Not used for R0 modules. */
|
---|
440 | RTUINTPTR OldImageBase;
|
---|
441 | /** Where the R3 HC bits are stored.
|
---|
442 | * This can be equal to ImageBase but doesn't have to. Not used for R0 modules. */
|
---|
443 | void *pvBits;
|
---|
444 |
|
---|
445 | /** Pointer to next module. */
|
---|
446 | struct PDMMOD *pNext;
|
---|
447 | /** Module filename. */
|
---|
448 | char szFilename[1];
|
---|
449 | } PDMMOD;
|
---|
450 | /** Pointer to loaded module instance. */
|
---|
451 | typedef PDMMOD *PPDMMOD;
|
---|
452 |
|
---|
453 |
|
---|
454 |
|
---|
455 | /** Extra space in the free array. */
|
---|
456 | #define PDMQUEUE_FREE_SLACK 16
|
---|
457 |
|
---|
458 | /**
|
---|
459 | * Queue type.
|
---|
460 | */
|
---|
461 | typedef enum PDMQUEUETYPE
|
---|
462 | {
|
---|
463 | /** Device consumer. */
|
---|
464 | PDMQUEUETYPE_DEV = 1,
|
---|
465 | /** Driver consumer. */
|
---|
466 | PDMQUEUETYPE_DRV,
|
---|
467 | /** Internal consumer. */
|
---|
468 | PDMQUEUETYPE_INTERNAL,
|
---|
469 | /** External consumer. */
|
---|
470 | PDMQUEUETYPE_EXTERNAL
|
---|
471 | } PDMQUEUETYPE;
|
---|
472 |
|
---|
473 | /** Pointer to a PDM Queue. */
|
---|
474 | typedef struct PDMQUEUE *PPDMQUEUE;
|
---|
475 |
|
---|
476 | /**
|
---|
477 | * PDM Queue.
|
---|
478 | */
|
---|
479 | typedef struct PDMQUEUE
|
---|
480 | {
|
---|
481 | /** Pointer to the next queue in the list. */
|
---|
482 | HCPTRTYPE(PPDMQUEUE) pNext;
|
---|
483 | /** Type specific data. */
|
---|
484 | union
|
---|
485 | {
|
---|
486 | /** PDMQUEUETYPE_DEV */
|
---|
487 | struct
|
---|
488 | {
|
---|
489 | /** Pointer to consumer function. */
|
---|
490 | HCPTRTYPE(PFNPDMQUEUEDEV) pfnCallback;
|
---|
491 | /** Pointer to the device instance owning the queue. */
|
---|
492 | HCPTRTYPE(PPDMDEVINS) pDevIns;
|
---|
493 | } Dev;
|
---|
494 | /** PDMQUEUETYPE_DRV */
|
---|
495 | struct
|
---|
496 | {
|
---|
497 | /** Pointer to consumer function. */
|
---|
498 | HCPTRTYPE(PFNPDMQUEUEDRV) pfnCallback;
|
---|
499 | /** Pointer to the driver instance owning the queue. */
|
---|
500 | HCPTRTYPE(PPDMDRVINS) pDrvIns;
|
---|
501 | } Drv;
|
---|
502 | /** PDMQUEUETYPE_INTERNAL */
|
---|
503 | struct
|
---|
504 | {
|
---|
505 | /** Pointer to consumer function. */
|
---|
506 | HCPTRTYPE(PFNPDMQUEUEINT) pfnCallback;
|
---|
507 | } Int;
|
---|
508 | /** PDMQUEUETYPE_EXTERNAL */
|
---|
509 | struct
|
---|
510 | {
|
---|
511 | /** Pointer to consumer function. */
|
---|
512 | HCPTRTYPE(PFNPDMQUEUEEXT) pfnCallback;
|
---|
513 | /** Pointer to user argument. */
|
---|
514 | HCPTRTYPE(void *) pvUser;
|
---|
515 | } Ext;
|
---|
516 | } u;
|
---|
517 | /** Queue type. */
|
---|
518 | PDMQUEUETYPE enmType;
|
---|
519 | /** The interval between checking the queue for events.
|
---|
520 | * The realtime timer below is used to do the waiting.
|
---|
521 | * If 0, the queue will use the VM_FF_PDM_QUEUE forced action. */
|
---|
522 | uint32_t cMilliesInterval;
|
---|
523 | /** Interval timer. Only used if cMilliesInterval is non-zero. */
|
---|
524 | PTMTIMERHC pTimer;
|
---|
525 | /** Pointer to the VM. */
|
---|
526 | HCPTRTYPE(PVM) pVMHC;
|
---|
527 | /** LIFO of pending items - HC. */
|
---|
528 | HCPTRTYPE(PPDMQUEUEITEMCORE) volatile pPendingHC;
|
---|
529 | /** Pointer to the GC VM and indicator for GC enabled queue.
|
---|
530 | * If this is NULL, the queue cannot be used in GC.
|
---|
531 | */
|
---|
532 | GCPTRTYPE(PVM) pVMGC;
|
---|
533 | /** LIFO of pending items - GC. */
|
---|
534 | GCPTRTYPE(PPDMQUEUEITEMCORE) pPendingGC;
|
---|
535 | /** Item size (bytes). */
|
---|
536 | RTUINT cbItem;
|
---|
537 | /** Number of items in the queue. */
|
---|
538 | RTUINT cItems;
|
---|
539 | /** Index to the free head (where we insert). */
|
---|
540 | uint32_t volatile iFreeHead;
|
---|
541 | /** Index to the free tail (where we remove). */
|
---|
542 | uint32_t volatile iFreeTail;
|
---|
543 | /** Array of pointers to free items. Variable size. */
|
---|
544 | struct PDMQUEUEFREEITEM
|
---|
545 | {
|
---|
546 | /** Pointer to the free item - HC Ptr. */
|
---|
547 | HCPTRTYPE(PPDMQUEUEITEMCORE) volatile pItemHC;
|
---|
548 | /** Pointer to the free item - GC Ptr. */
|
---|
549 | GCPTRTYPE(PPDMQUEUEITEMCORE) volatile pItemGC;
|
---|
550 | #if HC_ARCH_BITS == 64 && GC_ARCH_BITS == 32
|
---|
551 | uint32_t Alignment0;
|
---|
552 | #endif
|
---|
553 | } aFreeItems[1];
|
---|
554 | } PDMQUEUE;
|
---|
555 |
|
---|
556 |
|
---|
557 | /**
|
---|
558 | * Queue device helper task operation.
|
---|
559 | */
|
---|
560 | typedef enum PDMDEVHLPTASKOP
|
---|
561 | {
|
---|
562 | /** The usual invalid 0 entry. */
|
---|
563 | PDMDEVHLPTASKOP_INVALID = 0,
|
---|
564 | /** ISASetIrq */
|
---|
565 | PDMDEVHLPTASKOP_ISA_SET_IRQ,
|
---|
566 | /** PCISetIrq */
|
---|
567 | PDMDEVHLPTASKOP_PCI_SET_IRQ,
|
---|
568 | /** PCISetIrq */
|
---|
569 | PDMDEVHLPTASKOP_IOAPIC_SET_IRQ,
|
---|
570 | /** The usual 32-bit hack. */
|
---|
571 | PDMDEVHLPTASKOP_32BIT_HACK = 0x7fffffff
|
---|
572 | } PDMDEVHLPTASKOP;
|
---|
573 |
|
---|
574 | /**
|
---|
575 | * Queued Device Helper Task.
|
---|
576 | */
|
---|
577 | typedef struct PDMDEVHLPTASK
|
---|
578 | {
|
---|
579 | /** The queue item core (don't touch). */
|
---|
580 | PDMQUEUEITEMCORE Core;
|
---|
581 | /** Pointer to the device instance (HC Ptr). */
|
---|
582 | HCPTRTYPE(PPDMDEVINS) pDevInsHC;
|
---|
583 | /** This operation to perform. */
|
---|
584 | PDMDEVHLPTASKOP enmOp;
|
---|
585 | #if HC_ARCH_BITS == 64
|
---|
586 | uint32_t Alignment0;
|
---|
587 | #endif
|
---|
588 | /** Parameters to the operation. */
|
---|
589 | union PDMDEVHLPTASKPARAMS
|
---|
590 | {
|
---|
591 | /**
|
---|
592 | * PDMDEVHLPTASKOP_ISA_SET_IRQ and PDMDEVHLPTASKOP_PCI_SET_IRQ.
|
---|
593 | */
|
---|
594 | struct PDMDEVHLPTASKSETIRQ
|
---|
595 | {
|
---|
596 | /** The IRQ */
|
---|
597 | int iIrq;
|
---|
598 | /** The new level. */
|
---|
599 | int iLevel;
|
---|
600 | } SetIRQ;
|
---|
601 | } u;
|
---|
602 | } PDMDEVHLPTASK;
|
---|
603 | /** Pointer to a queued Device Helper Task. */
|
---|
604 | typedef PDMDEVHLPTASK *PPDMDEVHLPTASK;
|
---|
605 | /** Pointer to a const queued Device Helper Task. */
|
---|
606 | typedef const PDMDEVHLPTASK *PCPDMDEVHLPTASK;
|
---|
607 |
|
---|
608 |
|
---|
609 |
|
---|
610 | /**
|
---|
611 | * Converts a PDM pointer into a VM pointer.
|
---|
612 | * @returns Pointer to the VM structure the PDM is part of.
|
---|
613 | * @param pPDM Pointer to PDM instance data.
|
---|
614 | */
|
---|
615 | #define PDM2VM(pPDM) ( (PVM)((char*)pPDM - pPDM->offVM) )
|
---|
616 |
|
---|
617 |
|
---|
618 | /**
|
---|
619 | * PDM VM Instance data.
|
---|
620 | * Changes to this must checked against the padding of the cfgm union in VM!
|
---|
621 | */
|
---|
622 | typedef struct PDM
|
---|
623 | {
|
---|
624 | /** Offset to the VM structure.
|
---|
625 | * See PDM2VM(). */
|
---|
626 | RTUINT offVM;
|
---|
627 | RTUINT uPadding0; /**< Alignment padding.*/
|
---|
628 |
|
---|
629 | /** Pointer to list of loaded modules. This is HC only! */
|
---|
630 | HCPTRTYPE(PPDMMOD) pModules;
|
---|
631 |
|
---|
632 | /** List of registered devices. (FIFO) */
|
---|
633 | HCPTRTYPE(PPDMDEV) pDevs;
|
---|
634 | /** List of devices instances. (FIFO) */
|
---|
635 | HCPTRTYPE(PPDMDEVINS) pDevInstances;
|
---|
636 | /** List of registered drivers. (FIFO) */
|
---|
637 | HCPTRTYPE(PPDMDRV) pDrvs;
|
---|
638 | /** List of initialized critical sections. (LIFO) */
|
---|
639 | HCPTRTYPE(PPDMCRITSECTINT) pCritSects;
|
---|
640 | /** PCI Buses. */
|
---|
641 | PDMPCIBUS aPciBuses[1];
|
---|
642 | /** The register PIC device. */
|
---|
643 | PDMPIC Pic;
|
---|
644 | /** The registerd APIC device. */
|
---|
645 | PDMAPIC Apic;
|
---|
646 | /** The registerd I/O APIC device. */
|
---|
647 | PDMIOAPIC IoApic;
|
---|
648 | /** The registered DMAC device. */
|
---|
649 | HCPTRTYPE(PPDMDMAC) pDmac;
|
---|
650 | /** The registered RTC device. */
|
---|
651 | HCPTRTYPE(PPDMRTC) pRtc;
|
---|
652 |
|
---|
653 | /** Queue in which devhlp tasks are queued for R3 execution - HC Ptr. */
|
---|
654 | HCPTRTYPE(PPDMQUEUE) pDevHlpQueueHC;
|
---|
655 | /** Queue in which devhlp tasks are queued for R3 execution - GC Ptr. */
|
---|
656 | GCPTRTYPE(PPDMQUEUE) pDevHlpQueueGC;
|
---|
657 |
|
---|
658 | /** The number of entries in the apQueuedCritSectsLeaves table that's currnetly in use. */
|
---|
659 | RTUINT cQueuedCritSectLeaves;
|
---|
660 | /** Critical sections queued in GC/R0 because of contention preventing leave to complete. (R3 Ptrs)
|
---|
661 | * We will return to Ring-3 ASAP, so this queue doesn't has to be very long. */
|
---|
662 | R3PTRTYPE(PPDMCRITSECT) apQueuedCritSectsLeaves[8];
|
---|
663 |
|
---|
664 | /** Linked list of timer driven PDM queues. */
|
---|
665 | HCPTRTYPE(struct PDMQUEUE *) pQueuesTimer;
|
---|
666 | /** Linked list of force action driven PDM queues. */
|
---|
667 | HCPTRTYPE(struct PDMQUEUE *) pQueuesForced;
|
---|
668 | /** Pointer to the queue which should be manually flushed - HCPtr.
|
---|
669 | * Only touched by EMT. */
|
---|
670 | HCPTRTYPE(struct PDMQUEUE *) pQueueFlushHC;
|
---|
671 | /** Pointer to the queue which should be manually flushed - GCPtr. */
|
---|
672 | GCPTRTYPE(struct PDMQUEUE *) pQueueFlushGC;
|
---|
673 |
|
---|
674 | /** TEMPORARY HACKS FOR NETWORK POLLING.
|
---|
675 | * @todo fix NAT and kill this!
|
---|
676 | * @{ */
|
---|
677 | RTUINT cPollers;
|
---|
678 | HCPTRTYPE(PFNPDMDRVPOLLER) apfnPollers[16];
|
---|
679 | HCPTRTYPE(PPDMDRVINS) aDrvInsPollers[16];
|
---|
680 | PTMTIMERHC pTimerPollers;
|
---|
681 | /** @} */
|
---|
682 |
|
---|
683 | #ifdef VBOX_WITH_PDM_LOCK
|
---|
684 | /** The PDM lock.
|
---|
685 | * This is used to protect everything that deals with interrupts, i.e.
|
---|
686 | * the PIC, APIC, IOAPIC and PCI devices pluss some PDM functions. */
|
---|
687 | PDMCRITSECT CritSect;
|
---|
688 | #endif
|
---|
689 |
|
---|
690 |
|
---|
691 | /** Number of times a critical section leave requesed needed to be queued for ring-3 execution. */
|
---|
692 | STAMCOUNTER StatQueuedCritSectLeaves;
|
---|
693 | } PDM;
|
---|
694 | /** Pointer to PDM VM instance data. */
|
---|
695 | typedef PDM *PPDM;
|
---|
696 |
|
---|
697 |
|
---|
698 |
|
---|
699 | /*******************************************************************************
|
---|
700 | * Global Variables *
|
---|
701 | *******************************************************************************/
|
---|
702 | #ifdef IN_RING3
|
---|
703 | extern const PDMDRVHLP g_pdmR3DrvHlp;
|
---|
704 | #endif
|
---|
705 |
|
---|
706 |
|
---|
707 | /*******************************************************************************
|
---|
708 | * Internal Functions *
|
---|
709 | *******************************************************************************/
|
---|
710 | int pdmR3CritSectInit(PVM pVM);
|
---|
711 | int pdmR3CritSectTerm(PVM pVM);
|
---|
712 | void pdmR3CritSectRelocate(PVM pVM);
|
---|
713 | int pdmR3CritSectInitDevice(PVM pVM, PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, const char *pszName);
|
---|
714 | int pdmR3CritSectDeleteDevice(PVM pVM, PPDMDEVINS pDevIns);
|
---|
715 |
|
---|
716 | int pdmR3DevInit(PVM pVM);
|
---|
717 | PPDMDEV pdmR3DevLookup(PVM pVM, const char *pszName);
|
---|
718 | int pdmR3DevFindLun(PVM pVM, const char *pszDevice, unsigned iInstance, unsigned iLun, PPDMLUN *ppLun);
|
---|
719 |
|
---|
720 | int pdmR3DrvInit(PVM pVM);
|
---|
721 | int pdmR3DrvDetach(PPDMDRVINS pDrvIns);
|
---|
722 | PPDMDRV pdmR3DrvLookup(PVM pVM, const char *pszName);
|
---|
723 |
|
---|
724 | int pdmR3LdrInit(PVM pVM);
|
---|
725 | void pdmR3LdrTerm(PVM pVM);
|
---|
726 | char * pdmR3FileR3(const char *pszFile, bool fShared = false);
|
---|
727 | int pdmR3LoadR3(PVM pVM, const char *pszFilename, const char *pszName);
|
---|
728 |
|
---|
729 | void pdmR3QueueRelocate(PVM pVM, RTGCINTPTR offDelta);
|
---|
730 |
|
---|
731 | #ifdef VBOX_WITH_PDM_LOCK
|
---|
732 | void pdmLock(PVM pVM);
|
---|
733 | int pdmLockEx(PVM pVM, int rc);
|
---|
734 | void pdmUnlock(PVM pVM);
|
---|
735 | #else
|
---|
736 | # define pdmLock(pVM) do {} while (0)
|
---|
737 | # define pdmLockEx(pVM, rc) (VINF_SUCCESS)
|
---|
738 | # define pdmUnlock(pVM) do {} while (0)
|
---|
739 | #endif
|
---|
740 |
|
---|
741 | /** @} */
|
---|
742 |
|
---|
743 | __END_DECLS
|
---|
744 |
|
---|
745 | #endif
|
---|