1 | /* $Id: IOMInternal.h 56287 2015-06-09 11:15:22Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IOM - Internal header file.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2015 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 ___IOMInternal_h
|
---|
19 | #define ___IOMInternal_h
|
---|
20 |
|
---|
21 | #define IOM_WITH_CRIT_SECT_RW
|
---|
22 |
|
---|
23 | #include <VBox/cdefs.h>
|
---|
24 | #include <VBox/types.h>
|
---|
25 | #include <VBox/vmm/iom.h>
|
---|
26 | #include <VBox/vmm/stam.h>
|
---|
27 | #include <VBox/vmm/pgm.h>
|
---|
28 | #include <VBox/vmm/pdmcritsect.h>
|
---|
29 | #ifdef IOM_WITH_CRIT_SECT_RW
|
---|
30 | # include <VBox/vmm/pdmcritsectrw.h>
|
---|
31 | #endif
|
---|
32 | #include <VBox/param.h>
|
---|
33 | #include <iprt/assert.h>
|
---|
34 | #include <iprt/avl.h>
|
---|
35 |
|
---|
36 |
|
---|
37 |
|
---|
38 | /** @defgroup grp_iom_int Internals
|
---|
39 | * @ingroup grp_iom
|
---|
40 | * @internal
|
---|
41 | * @{
|
---|
42 | */
|
---|
43 |
|
---|
44 | /**
|
---|
45 | * MMIO range descriptor.
|
---|
46 | */
|
---|
47 | typedef struct IOMMMIORANGE
|
---|
48 | {
|
---|
49 | /** Avl node core with GCPhys as Key and GCPhys + cbSize - 1 as KeyLast. */
|
---|
50 | AVLROGCPHYSNODECORE Core;
|
---|
51 | /** Start physical address. */
|
---|
52 | RTGCPHYS GCPhys;
|
---|
53 | /** Size of the range. */
|
---|
54 | uint32_t cb;
|
---|
55 | /** The reference counter. */
|
---|
56 | uint32_t volatile cRefs;
|
---|
57 |
|
---|
58 | /** Pointer to user argument - R0. */
|
---|
59 | RTR0PTR pvUserR0;
|
---|
60 | /** Pointer to device instance - R0. */
|
---|
61 | PPDMDEVINSR0 pDevInsR0;
|
---|
62 | /** Pointer to write callback function - R0. */
|
---|
63 | R0PTRTYPE(PFNIOMMMIOWRITE) pfnWriteCallbackR0;
|
---|
64 | /** Pointer to read callback function - R0. */
|
---|
65 | R0PTRTYPE(PFNIOMMMIOREAD) pfnReadCallbackR0;
|
---|
66 | /** Pointer to fill (memset) callback function - R0. */
|
---|
67 | R0PTRTYPE(PFNIOMMMIOFILL) pfnFillCallbackR0;
|
---|
68 |
|
---|
69 | /** Flags, see IOMMMIO_FLAGS_XXX. */ /* (Placed here for alignment reasons.) */
|
---|
70 | uint32_t fFlags;
|
---|
71 |
|
---|
72 | /** Pointer to user argument - RC. */
|
---|
73 | RTRCPTR pvUserRC;
|
---|
74 | /** Pointer to device instance - RC. */
|
---|
75 | PPDMDEVINSRC pDevInsRC;
|
---|
76 | /** Pointer to write callback function - RC. */
|
---|
77 | RCPTRTYPE(PFNIOMMMIOWRITE) pfnWriteCallbackRC;
|
---|
78 | /** Pointer to read callback function - RC. */
|
---|
79 | RCPTRTYPE(PFNIOMMMIOREAD) pfnReadCallbackRC;
|
---|
80 | /** Pointer to fill (memset) callback function - RC. */
|
---|
81 | RCPTRTYPE(PFNIOMMMIOFILL) pfnFillCallbackRC;
|
---|
82 |
|
---|
83 | /** Pointer to user argument - R3. */
|
---|
84 | RTR3PTR pvUserR3;
|
---|
85 | /** Pointer to device instance - R3. */
|
---|
86 | PPDMDEVINSR3 pDevInsR3;
|
---|
87 | /** Pointer to write callback function - R3. */
|
---|
88 | R3PTRTYPE(PFNIOMMMIOWRITE) pfnWriteCallbackR3;
|
---|
89 | /** Pointer to read callback function - R3. */
|
---|
90 | R3PTRTYPE(PFNIOMMMIOREAD) pfnReadCallbackR3;
|
---|
91 | /** Pointer to fill (memset) callback function - R3. */
|
---|
92 | R3PTRTYPE(PFNIOMMMIOFILL) pfnFillCallbackR3;
|
---|
93 |
|
---|
94 | /** Description / Name. For easing debugging. */
|
---|
95 | R3PTRTYPE(const char *) pszDesc;
|
---|
96 | } IOMMMIORANGE;
|
---|
97 | /** Pointer to a MMIO range descriptor, R3 version. */
|
---|
98 | typedef struct IOMMMIORANGE *PIOMMMIORANGE;
|
---|
99 |
|
---|
100 |
|
---|
101 | /**
|
---|
102 | * MMIO address statistics. (one address)
|
---|
103 | *
|
---|
104 | * This is a simple way of making on demand statistics, however it's a
|
---|
105 | * bit free with the hypervisor heap memory.
|
---|
106 | */
|
---|
107 | typedef struct IOMMMIOSTATS
|
---|
108 | {
|
---|
109 | /** Avl node core with the address as Key. */
|
---|
110 | AVLOGCPHYSNODECORE Core;
|
---|
111 |
|
---|
112 | /** Number of accesses (subtract ReadRZToR3 and WriteRZToR3 to get the right
|
---|
113 | * number). */
|
---|
114 | STAMCOUNTER Accesses;
|
---|
115 |
|
---|
116 | /** Profiling read handler overhead in R3. */
|
---|
117 | STAMPROFILE ProfReadR3;
|
---|
118 | /** Profiling write handler overhead in R3. */
|
---|
119 | STAMPROFILE ProfWriteR3;
|
---|
120 | /** Counting and profiling reads in R0/RC. */
|
---|
121 | STAMPROFILE ProfReadRZ;
|
---|
122 | /** Counting and profiling writes in R0/RC. */
|
---|
123 | STAMPROFILE ProfWriteRZ;
|
---|
124 |
|
---|
125 | /** Number of reads to this address from R0/RC which was serviced in R3. */
|
---|
126 | STAMCOUNTER ReadRZToR3;
|
---|
127 | /** Number of writes to this address from R0/RC which was serviced in R3. */
|
---|
128 | STAMCOUNTER WriteRZToR3;
|
---|
129 | } IOMMMIOSTATS;
|
---|
130 | AssertCompileMemberAlignment(IOMMMIOSTATS, Accesses, 8);
|
---|
131 | /** Pointer to I/O port statistics. */
|
---|
132 | typedef IOMMMIOSTATS *PIOMMMIOSTATS;
|
---|
133 |
|
---|
134 |
|
---|
135 | /**
|
---|
136 | * I/O port range descriptor, R3 version.
|
---|
137 | */
|
---|
138 | typedef struct IOMIOPORTRANGER3
|
---|
139 | {
|
---|
140 | /** Avl node core with Port as Key and Port + cPorts - 1 as KeyLast. */
|
---|
141 | AVLROIOPORTNODECORE Core;
|
---|
142 | #if HC_ARCH_BITS == 64 && !defined(RT_OS_WINDOWS)
|
---|
143 | uint32_t u32Alignment; /**< The sizeof(Core) differs. */
|
---|
144 | #endif
|
---|
145 | /** Start I/O port address. */
|
---|
146 | RTIOPORT Port;
|
---|
147 | /** Size of the range. */
|
---|
148 | uint16_t cPorts;
|
---|
149 | /** Pointer to user argument. */
|
---|
150 | RTR3PTR pvUser;
|
---|
151 | /** Pointer to the associated device instance. */
|
---|
152 | R3PTRTYPE(PPDMDEVINS) pDevIns;
|
---|
153 | /** Pointer to OUT callback function. */
|
---|
154 | R3PTRTYPE(PFNIOMIOPORTOUT) pfnOutCallback;
|
---|
155 | /** Pointer to IN callback function. */
|
---|
156 | R3PTRTYPE(PFNIOMIOPORTIN) pfnInCallback;
|
---|
157 | /** Pointer to string OUT callback function. */
|
---|
158 | R3PTRTYPE(PFNIOMIOPORTOUTSTRING) pfnOutStrCallback;
|
---|
159 | /** Pointer to string IN callback function. */
|
---|
160 | R3PTRTYPE(PFNIOMIOPORTINSTRING) pfnInStrCallback;
|
---|
161 | /** Description / Name. For easing debugging. */
|
---|
162 | R3PTRTYPE(const char *) pszDesc;
|
---|
163 | } IOMIOPORTRANGER3;
|
---|
164 | /** Pointer to I/O port range descriptor, R3 version. */
|
---|
165 | typedef IOMIOPORTRANGER3 *PIOMIOPORTRANGER3;
|
---|
166 |
|
---|
167 | /**
|
---|
168 | * I/O port range descriptor, R0 version.
|
---|
169 | */
|
---|
170 | typedef struct IOMIOPORTRANGER0
|
---|
171 | {
|
---|
172 | /** Avl node core with Port as Key and Port + cPorts - 1 as KeyLast. */
|
---|
173 | AVLROIOPORTNODECORE Core;
|
---|
174 | #if HC_ARCH_BITS == 64 && !defined(RT_OS_WINDOWS)
|
---|
175 | uint32_t u32Alignment; /**< The sizeof(Core) differs. */
|
---|
176 | #endif
|
---|
177 | /** Start I/O port address. */
|
---|
178 | RTIOPORT Port;
|
---|
179 | /** Size of the range. */
|
---|
180 | uint16_t cPorts;
|
---|
181 | /** Pointer to user argument. */
|
---|
182 | RTR0PTR pvUser;
|
---|
183 | /** Pointer to the associated device instance. */
|
---|
184 | R0PTRTYPE(PPDMDEVINS) pDevIns;
|
---|
185 | /** Pointer to OUT callback function. */
|
---|
186 | R0PTRTYPE(PFNIOMIOPORTOUT) pfnOutCallback;
|
---|
187 | /** Pointer to IN callback function. */
|
---|
188 | R0PTRTYPE(PFNIOMIOPORTIN) pfnInCallback;
|
---|
189 | /** Pointer to string OUT callback function. */
|
---|
190 | R0PTRTYPE(PFNIOMIOPORTOUTSTRING) pfnOutStrCallback;
|
---|
191 | /** Pointer to string IN callback function. */
|
---|
192 | R0PTRTYPE(PFNIOMIOPORTINSTRING) pfnInStrCallback;
|
---|
193 | /** Description / Name. For easing debugging. */
|
---|
194 | R3PTRTYPE(const char *) pszDesc;
|
---|
195 | } IOMIOPORTRANGER0;
|
---|
196 | /** Pointer to I/O port range descriptor, R0 version. */
|
---|
197 | typedef IOMIOPORTRANGER0 *PIOMIOPORTRANGER0;
|
---|
198 |
|
---|
199 | /**
|
---|
200 | * I/O port range descriptor, RC version.
|
---|
201 | */
|
---|
202 | typedef struct IOMIOPORTRANGERC
|
---|
203 | {
|
---|
204 | /** Avl node core with Port as Key and Port + cPorts - 1 as KeyLast. */
|
---|
205 | AVLROIOPORTNODECORE Core;
|
---|
206 | /** Start I/O port address. */
|
---|
207 | RTIOPORT Port;
|
---|
208 | /** Size of the range. */
|
---|
209 | uint16_t cPorts;
|
---|
210 | /** Pointer to user argument. */
|
---|
211 | RTRCPTR pvUser;
|
---|
212 | /** Pointer to the associated device instance. */
|
---|
213 | RCPTRTYPE(PPDMDEVINS) pDevIns;
|
---|
214 | /** Pointer to OUT callback function. */
|
---|
215 | RCPTRTYPE(PFNIOMIOPORTOUT) pfnOutCallback;
|
---|
216 | /** Pointer to IN callback function. */
|
---|
217 | RCPTRTYPE(PFNIOMIOPORTIN) pfnInCallback;
|
---|
218 | /** Pointer to string OUT callback function. */
|
---|
219 | RCPTRTYPE(PFNIOMIOPORTOUTSTRING) pfnOutStrCallback;
|
---|
220 | /** Pointer to string IN callback function. */
|
---|
221 | RCPTRTYPE(PFNIOMIOPORTINSTRING) pfnInStrCallback;
|
---|
222 | #if HC_ARCH_BITS == 64
|
---|
223 | RTRCPTR RCPtrAlignment; /**< pszDesc is 8 byte aligned. */
|
---|
224 | #endif
|
---|
225 | /** Description / Name. For easing debugging. */
|
---|
226 | R3PTRTYPE(const char *) pszDesc;
|
---|
227 | } IOMIOPORTRANGERC;
|
---|
228 | /** Pointer to I/O port range descriptor, RC version. */
|
---|
229 | typedef IOMIOPORTRANGERC *PIOMIOPORTRANGERC;
|
---|
230 |
|
---|
231 |
|
---|
232 | /**
|
---|
233 | * I/O port statistics. (one I/O port)
|
---|
234 | *
|
---|
235 | * This is a simple way of making on demand statistics, however it's a
|
---|
236 | * bit free with the hypervisor heap memory.
|
---|
237 | */
|
---|
238 | typedef struct IOMIOPORTSTATS
|
---|
239 | {
|
---|
240 | /** Avl node core with the port as Key. */
|
---|
241 | AVLOIOPORTNODECORE Core;
|
---|
242 | #if HC_ARCH_BITS != 64 || !defined(RT_OS_WINDOWS)
|
---|
243 | uint32_t u32Alignment; /**< The sizeof(Core) differs. */
|
---|
244 | #endif
|
---|
245 | /** Number of INs to this port from R3. */
|
---|
246 | STAMCOUNTER InR3;
|
---|
247 | /** Profiling IN handler overhead in R3. */
|
---|
248 | STAMPROFILE ProfInR3;
|
---|
249 | /** Number of OUTs to this port from R3. */
|
---|
250 | STAMCOUNTER OutR3;
|
---|
251 | /** Profiling OUT handler overhead in R3. */
|
---|
252 | STAMPROFILE ProfOutR3;
|
---|
253 |
|
---|
254 | /** Number of INs to this port from R0/RC. */
|
---|
255 | STAMCOUNTER InRZ;
|
---|
256 | /** Profiling IN handler overhead in R0/RC. */
|
---|
257 | STAMPROFILE ProfInRZ;
|
---|
258 | /** Number of INs to this port from R0/RC which was serviced in R3. */
|
---|
259 | STAMCOUNTER InRZToR3;
|
---|
260 |
|
---|
261 | /** Number of OUTs to this port from R0/RC. */
|
---|
262 | STAMCOUNTER OutRZ;
|
---|
263 | /** Profiling OUT handler overhead in R0/RC. */
|
---|
264 | STAMPROFILE ProfOutRZ;
|
---|
265 | /** Number of OUTs to this port from R0/RC which was serviced in R3. */
|
---|
266 | STAMCOUNTER OutRZToR3;
|
---|
267 | } IOMIOPORTSTATS;
|
---|
268 | AssertCompileMemberAlignment(IOMIOPORTSTATS, InR3, 8);
|
---|
269 | /** Pointer to I/O port statistics. */
|
---|
270 | typedef IOMIOPORTSTATS *PIOMIOPORTSTATS;
|
---|
271 |
|
---|
272 |
|
---|
273 | /**
|
---|
274 | * The IOM trees.
|
---|
275 | * These are offset based the nodes and root must be in the same
|
---|
276 | * memory block in HC. The locations of IOM structure and the hypervisor heap
|
---|
277 | * are quite different in R3, R0 and RC.
|
---|
278 | */
|
---|
279 | typedef struct IOMTREES
|
---|
280 | {
|
---|
281 | /** Tree containing I/O port range descriptors registered for HC (IOMIOPORTRANGEHC). */
|
---|
282 | AVLROIOPORTTREE IOPortTreeR3;
|
---|
283 | /** Tree containing I/O port range descriptors registered for R0 (IOMIOPORTRANGER0). */
|
---|
284 | AVLROIOPORTTREE IOPortTreeR0;
|
---|
285 | /** Tree containing I/O port range descriptors registered for RC (IOMIOPORTRANGERC). */
|
---|
286 | AVLROIOPORTTREE IOPortTreeRC;
|
---|
287 |
|
---|
288 | /** Tree containing the MMIO range descriptors (IOMMMIORANGE). */
|
---|
289 | AVLROGCPHYSTREE MMIOTree;
|
---|
290 |
|
---|
291 | /** Tree containing I/O port statistics (IOMIOPORTSTATS). */
|
---|
292 | AVLOIOPORTTREE IOPortStatTree;
|
---|
293 | /** Tree containing MMIO statistics (IOMMMIOSTATS). */
|
---|
294 | AVLOGCPHYSTREE MmioStatTree;
|
---|
295 | } IOMTREES;
|
---|
296 | /** Pointer to the IOM trees. */
|
---|
297 | typedef IOMTREES *PIOMTREES;
|
---|
298 |
|
---|
299 |
|
---|
300 | /**
|
---|
301 | * Converts an IOM pointer into a VM pointer.
|
---|
302 | * @returns Pointer to the VM structure the PGM is part of.
|
---|
303 | * @param pIOM Pointer to IOM instance data.
|
---|
304 | */
|
---|
305 | #define IOM2VM(pIOM) ( (PVM)((char*)pIOM - pIOM->offVM) )
|
---|
306 |
|
---|
307 | /**
|
---|
308 | * IOM Data (part of VM)
|
---|
309 | */
|
---|
310 | typedef struct IOM
|
---|
311 | {
|
---|
312 | /** Offset to the VM structure. */
|
---|
313 | RTINT offVM;
|
---|
314 |
|
---|
315 | /** Pointer to the trees - RC ptr. */
|
---|
316 | RCPTRTYPE(PIOMTREES) pTreesRC;
|
---|
317 | /** Pointer to the trees - R3 ptr. */
|
---|
318 | R3PTRTYPE(PIOMTREES) pTreesR3;
|
---|
319 | /** Pointer to the trees - R0 ptr. */
|
---|
320 | R0PTRTYPE(PIOMTREES) pTreesR0;
|
---|
321 |
|
---|
322 | /** MMIO physical access handler type. */
|
---|
323 | PGMPHYSHANDLERTYPE hMmioHandlerType;
|
---|
324 | uint32_t u32Padding;
|
---|
325 |
|
---|
326 | /** Lock serializing EMT access to IOM. */
|
---|
327 | #ifdef IOM_WITH_CRIT_SECT_RW
|
---|
328 | PDMCRITSECTRW CritSect;
|
---|
329 | #else
|
---|
330 | PDMCRITSECT CritSect;
|
---|
331 | #endif
|
---|
332 |
|
---|
333 | /** @name I/O Port statistics.
|
---|
334 | * @{ */
|
---|
335 | STAMCOUNTER StatInstIn;
|
---|
336 | STAMCOUNTER StatInstOut;
|
---|
337 | STAMCOUNTER StatInstIns;
|
---|
338 | STAMCOUNTER StatInstOuts;
|
---|
339 | /** @} */
|
---|
340 |
|
---|
341 | /** @name MMIO statistics.
|
---|
342 | * @{ */
|
---|
343 | STAMPROFILE StatRZMMIOHandler;
|
---|
344 | STAMCOUNTER StatRZMMIOFailures;
|
---|
345 |
|
---|
346 | STAMPROFILE StatRZInstMov;
|
---|
347 | STAMPROFILE StatRZInstCmp;
|
---|
348 | STAMPROFILE StatRZInstAnd;
|
---|
349 | STAMPROFILE StatRZInstOr;
|
---|
350 | STAMPROFILE StatRZInstXor;
|
---|
351 | STAMPROFILE StatRZInstBt;
|
---|
352 | STAMPROFILE StatRZInstTest;
|
---|
353 | STAMPROFILE StatRZInstXchg;
|
---|
354 | STAMPROFILE StatRZInstStos;
|
---|
355 | STAMPROFILE StatRZInstLods;
|
---|
356 | #ifdef IOM_WITH_MOVS_SUPPORT
|
---|
357 | STAMPROFILEADV StatRZInstMovs;
|
---|
358 | STAMPROFILE StatRZInstMovsToMMIO;
|
---|
359 | STAMPROFILE StatRZInstMovsFromMMIO;
|
---|
360 | STAMPROFILE StatRZInstMovsMMIO;
|
---|
361 | #endif
|
---|
362 | STAMCOUNTER StatRZInstOther;
|
---|
363 |
|
---|
364 | STAMCOUNTER StatRZMMIO1Byte;
|
---|
365 | STAMCOUNTER StatRZMMIO2Bytes;
|
---|
366 | STAMCOUNTER StatRZMMIO4Bytes;
|
---|
367 | STAMCOUNTER StatRZMMIO8Bytes;
|
---|
368 |
|
---|
369 | STAMCOUNTER StatR3MMIOHandler;
|
---|
370 |
|
---|
371 | RTUINT cMovsMaxBytes;
|
---|
372 | RTUINT cStosMaxBytes;
|
---|
373 | /** @} */
|
---|
374 | } IOM;
|
---|
375 | /** Pointer to IOM instance data. */
|
---|
376 | typedef IOM *PIOM;
|
---|
377 |
|
---|
378 |
|
---|
379 | /**
|
---|
380 | * IOM per virtual CPU instance data.
|
---|
381 | */
|
---|
382 | typedef struct IOMCPU
|
---|
383 | {
|
---|
384 | /** For saving stack space, the disassembler state is allocated here instead of
|
---|
385 | * on the stack. */
|
---|
386 | DISCPUSTATE DisState;
|
---|
387 |
|
---|
388 | /** @name Caching of I/O Port and MMIO ranges and statistics.
|
---|
389 | * (Saves quite some time in rep outs/ins instruction emulation.)
|
---|
390 | * @{ */
|
---|
391 | R3PTRTYPE(PIOMIOPORTRANGER3) pRangeLastReadR3;
|
---|
392 | R3PTRTYPE(PIOMIOPORTRANGER3) pRangeLastWriteR3;
|
---|
393 | R3PTRTYPE(PIOMIOPORTSTATS) pStatsLastReadR3;
|
---|
394 | R3PTRTYPE(PIOMIOPORTSTATS) pStatsLastWriteR3;
|
---|
395 | R3PTRTYPE(PIOMMMIORANGE) pMMIORangeLastR3;
|
---|
396 | R3PTRTYPE(PIOMMMIOSTATS) pMMIOStatsLastR3;
|
---|
397 |
|
---|
398 | R0PTRTYPE(PIOMIOPORTRANGER0) pRangeLastReadR0;
|
---|
399 | R0PTRTYPE(PIOMIOPORTRANGER0) pRangeLastWriteR0;
|
---|
400 | R0PTRTYPE(PIOMIOPORTSTATS) pStatsLastReadR0;
|
---|
401 | R0PTRTYPE(PIOMIOPORTSTATS) pStatsLastWriteR0;
|
---|
402 | R0PTRTYPE(PIOMMMIORANGE) pMMIORangeLastR0;
|
---|
403 | R0PTRTYPE(PIOMMMIOSTATS) pMMIOStatsLastR0;
|
---|
404 |
|
---|
405 | RCPTRTYPE(PIOMIOPORTRANGERC) pRangeLastReadRC;
|
---|
406 | RCPTRTYPE(PIOMIOPORTRANGERC) pRangeLastWriteRC;
|
---|
407 | RCPTRTYPE(PIOMIOPORTSTATS) pStatsLastReadRC;
|
---|
408 | RCPTRTYPE(PIOMIOPORTSTATS) pStatsLastWriteRC;
|
---|
409 | RCPTRTYPE(PIOMMMIORANGE) pMMIORangeLastRC;
|
---|
410 | RCPTRTYPE(PIOMMMIOSTATS) pMMIOStatsLastRC;
|
---|
411 | /** @} */
|
---|
412 | } IOMCPU;
|
---|
413 | /** Pointer to IOM per virtual CPU instance data. */
|
---|
414 | typedef IOMCPU *PIOMCPU;
|
---|
415 |
|
---|
416 |
|
---|
417 | RT_C_DECLS_BEGIN
|
---|
418 |
|
---|
419 | void iomMmioFreeRange(PVM pVM, PIOMMMIORANGE pRange);
|
---|
420 | #ifdef IN_RING3
|
---|
421 | PIOMMMIOSTATS iomR3MMIOStatsCreate(PVM pVM, RTGCPHYS GCPhys, const char *pszDesc);
|
---|
422 | #endif /* IN_RING3 */
|
---|
423 |
|
---|
424 | #ifndef IN_RING3
|
---|
425 | DECLEXPORT(FNPGMRZPHYSPFHANDLER) iomMmioPfHandler;
|
---|
426 | #endif
|
---|
427 | PGM_ALL_CB2_DECL(FNPGMPHYSHANDLER) iomMmioHandler;
|
---|
428 |
|
---|
429 | /* IOM locking helpers. */
|
---|
430 | #ifdef IOM_WITH_CRIT_SECT_RW
|
---|
431 | # define IOM_LOCK_EXCL(a_pVM) PDMCritSectRwEnterExcl(&(a_pVM)->iom.s.CritSect, VERR_SEM_BUSY)
|
---|
432 | # define IOM_UNLOCK_EXCL(a_pVM) do { PDMCritSectRwLeaveExcl(&(a_pVM)->iom.s.CritSect); } while (0)
|
---|
433 | # if 0 /* (in case needed for debugging) */
|
---|
434 | # define IOM_LOCK_SHARED_EX(a_pVM, a_rcBusy) PDMCritSectRwEnterExcl(&(a_pVM)->iom.s.CritSect, (a_rcBusy))
|
---|
435 | # define IOM_UNLOCK_SHARED(a_pVM) do { PDMCritSectRwLeaveExcl(&(a_pVM)->iom.s.CritSect); } while (0)
|
---|
436 | # define IOM_IS_SHARED_LOCK_OWNER(a_pVM) PDMCritSectRwIsWriteOwner(&(a_pVM)->iom.s.CritSect)
|
---|
437 | # else
|
---|
438 | # define IOM_LOCK_SHARED_EX(a_pVM, a_rcBusy) PDMCritSectRwEnterShared(&(a_pVM)->iom.s.CritSect, (a_rcBusy))
|
---|
439 | # define IOM_UNLOCK_SHARED(a_pVM) do { PDMCritSectRwLeaveShared(&(a_pVM)->iom.s.CritSect); } while (0)
|
---|
440 | # define IOM_IS_SHARED_LOCK_OWNER(a_pVM) PDMCritSectRwIsReadOwner(&(a_pVM)->iom.s.CritSect, true)
|
---|
441 | # endif
|
---|
442 | # define IOM_IS_EXCL_LOCK_OWNER(a_pVM) PDMCritSectRwIsWriteOwner(&(a_pVM)->iom.s.CritSect)
|
---|
443 | #else
|
---|
444 | # define IOM_LOCK_EXCL(a_pVM) PDMCritSectEnter(&(a_pVM)->iom.s.CritSect, VERR_SEM_BUSY)
|
---|
445 | # define IOM_UNLOCK_EXCL(a_pVM) do { PDMCritSectLeave(&(a_pVM)->iom.s.CritSect); } while (0)
|
---|
446 | # define IOM_LOCK_SHARED_EX(a_pVM, a_rcBusy) PDMCritSectEnter(&(a_pVM)->iom.s.CritSect, (a_rcBusy))
|
---|
447 | # define IOM_UNLOCK_SHARED(a_pVM) do { PDMCritSectLeave(&(a_pVM)->iom.s.CritSect); } while (0)
|
---|
448 | # define IOM_IS_SHARED_LOCK_OWNER(a_pVM) PDMCritSectIsOwner(&(a_pVM)->iom.s.CritSect)
|
---|
449 | # define IOM_IS_EXCL_LOCK_OWNER(a_pVM) PDMCritSectIsOwner(&(a_pVM)->iom.s.CritSect)
|
---|
450 | #endif
|
---|
451 | #define IOM_LOCK_SHARED(a_pVM) IOM_LOCK_SHARED_EX(a_pVM, VERR_SEM_BUSY)
|
---|
452 |
|
---|
453 |
|
---|
454 | /* Disassembly helpers used in IOMAll.cpp & IOMAllMMIO.cpp */
|
---|
455 | bool iomGetRegImmData(PDISCPUSTATE pCpu, PCDISOPPARAM pParam, PCPUMCTXCORE pRegFrame, uint64_t *pu64Data, unsigned *pcbSize);
|
---|
456 | bool iomSaveDataToReg(PDISCPUSTATE pCpu, PCDISOPPARAM pParam, PCPUMCTXCORE pRegFrame, uint64_t u64Data);
|
---|
457 |
|
---|
458 | RT_C_DECLS_END
|
---|
459 |
|
---|
460 |
|
---|
461 | #ifdef IN_RING3
|
---|
462 |
|
---|
463 | #endif
|
---|
464 |
|
---|
465 | /** @} */
|
---|
466 |
|
---|
467 | #endif /* !___IOMInternal_h */
|
---|
468 |
|
---|