1 | /* $Id: IOMInternal.h 5375 2007-10-18 14:13:22Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IOM - Internal header file.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 innotek 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 |
|
---|
18 | #ifndef ___IOMInternal_h
|
---|
19 | #define ___IOMInternal_h
|
---|
20 |
|
---|
21 | #include <VBox/cdefs.h>
|
---|
22 | #include <VBox/types.h>
|
---|
23 | #include <VBox/iom.h>
|
---|
24 | #include <VBox/stam.h>
|
---|
25 | #include <iprt/avl.h>
|
---|
26 |
|
---|
27 | #if !defined(IN_IOM_R3) && !defined(IN_IOM_R0) && !defined(IN_IOM_GC)
|
---|
28 | # error "Not in IOM! This is an internal header!"
|
---|
29 | #endif
|
---|
30 |
|
---|
31 |
|
---|
32 | /** @defgroup grp_iom_int Internals
|
---|
33 | * @ingroup grp_iom
|
---|
34 | * @internal
|
---|
35 | * @{
|
---|
36 | */
|
---|
37 |
|
---|
38 | /**
|
---|
39 | * MMIO range descriptor, R3 version.
|
---|
40 | */
|
---|
41 | typedef struct IOMMMIORANGER3
|
---|
42 | {
|
---|
43 | /** Avl node core with GCPhys as Key and GCPhys + cbSize - 1 as KeyLast. */
|
---|
44 | AVLROGCPHYSNODECORE Core;
|
---|
45 | #if HC_ARCH_BITS == 64 && GC_ARCH_BITS == 32 && !defined(RT_OS_WINDOWS)
|
---|
46 | uint32_t u32Alignment; /**< The sizeof(Core) differs. */
|
---|
47 | #endif
|
---|
48 | /** Start physical address. */
|
---|
49 | RTGCPHYS GCPhys;
|
---|
50 | /** Size of the range. */
|
---|
51 | RTUINT cbSize;
|
---|
52 | /** Pointer to user argument. */
|
---|
53 | RTR3PTR pvUser;
|
---|
54 | /** Pointer to device instance. */
|
---|
55 | R3PTRTYPE(PPDMDEVINS) pDevIns;
|
---|
56 | /** Pointer to write callback function. */
|
---|
57 | R3PTRTYPE(PFNIOMMMIOWRITE) pfnWriteCallback;
|
---|
58 | /** Pointer to read callback function. */
|
---|
59 | R3PTRTYPE(PFNIOMMMIOREAD) pfnReadCallback;
|
---|
60 | /** Pointer to fill (memset) callback function. */
|
---|
61 | R3PTRTYPE(PFNIOMMMIOFILL) pfnFillCallback;
|
---|
62 | /** Description / Name. For easing debugging. */
|
---|
63 | R3PTRTYPE(const char *) pszDesc;
|
---|
64 | } IOMMMIORANGER3;
|
---|
65 | /** Pointer to a MMIO range descriptor, R3 version. */
|
---|
66 | typedef struct IOMMMIORANGER3 *PIOMMMIORANGER3;
|
---|
67 |
|
---|
68 | /**
|
---|
69 | * MMIO range descriptor, R0 version.
|
---|
70 | */
|
---|
71 | typedef struct IOMMMIORANGER0
|
---|
72 | {
|
---|
73 | /** Avl node core with GCPhys as Key and GCPhys + cbSize - 1 as KeyLast. */
|
---|
74 | AVLROGCPHYSNODECORE Core;
|
---|
75 | #if HC_ARCH_BITS == 64 && GC_ARCH_BITS == 32 && !defined(RT_OS_WINDOWS)
|
---|
76 | uint32_t u32Alignment; /**< The sizeof(Core) differs. */
|
---|
77 | #endif
|
---|
78 | /** Start physical address. */
|
---|
79 | RTGCPHYS GCPhys;
|
---|
80 | /** Size of the range. */
|
---|
81 | RTUINT cbSize;
|
---|
82 | /** Pointer to user argument. */
|
---|
83 | RTR0PTR pvUser;
|
---|
84 | /** Pointer to device instance. */
|
---|
85 | R0PTRTYPE(PPDMDEVINS) pDevIns;
|
---|
86 | /** Pointer to write callback function. */
|
---|
87 | R0PTRTYPE(PFNIOMMMIOWRITE) pfnWriteCallback;
|
---|
88 | /** Pointer to read callback function. */
|
---|
89 | R0PTRTYPE(PFNIOMMMIOREAD) pfnReadCallback;
|
---|
90 | /** Pointer to fill (memset) callback function. */
|
---|
91 | R0PTRTYPE(PFNIOMMMIOFILL) pfnFillCallback;
|
---|
92 | /** Description / Name. For easing debugging. */
|
---|
93 | R3PTRTYPE(const char *) pszDesc;
|
---|
94 | } IOMMMIORANGER0;
|
---|
95 | /** Pointer to a MMIO range descriptor, R0 version. */
|
---|
96 | typedef struct IOMMMIORANGER0 *PIOMMMIORANGER0;
|
---|
97 |
|
---|
98 | /**
|
---|
99 | * MMIO range descriptor, GC version.
|
---|
100 | */
|
---|
101 | typedef struct IOMMMIORANGEGC
|
---|
102 | {
|
---|
103 | /** Avl node core with GCPhys as Key and GCPhys + cbSize - 1 as KeyLast. */
|
---|
104 | AVLROGCPHYSNODECORE Core;
|
---|
105 | #if HC_ARCH_BITS == 64 && GC_ARCH_BITS == 32 && !defined(RT_OS_WINDOWS)
|
---|
106 | uint32_t u32Alignment; /**< The sizeof(Core) differs. */
|
---|
107 | #endif
|
---|
108 | /** Start physical address. */
|
---|
109 | RTGCPHYS GCPhys;
|
---|
110 | /** Size of the range. */
|
---|
111 | RTUINT cbSize;
|
---|
112 | /** Pointer to user argument. */
|
---|
113 | RTGCPTR pvUser;
|
---|
114 | /** Pointer to device instance. */
|
---|
115 | GCPTRTYPE(PPDMDEVINS) pDevIns;
|
---|
116 | /** Pointer to write callback function. */
|
---|
117 | GCPTRTYPE(PFNIOMMMIOWRITE) pfnWriteCallback;
|
---|
118 | /** Pointer to read callback function. */
|
---|
119 | GCPTRTYPE(PFNIOMMMIOREAD) pfnReadCallback;
|
---|
120 | /** Pointer to fill (memset) callback function. */
|
---|
121 | GCPTRTYPE(PFNIOMMMIOFILL) pfnFillCallback;
|
---|
122 | #if HC_ARCH_BITS == 64 && GC_ARCH_BITS == 32
|
---|
123 | RTGCPTR GCPtrAlignment; /**< pszDesc is 8 byte aligned. */
|
---|
124 | #endif
|
---|
125 | /** Description / Name. For easing debugging. */
|
---|
126 | R3PTRTYPE(const char *) pszDesc;
|
---|
127 | } IOMMMIORANGEGC;
|
---|
128 | /** Pointer to a MMIO range descriptor, GC version. */
|
---|
129 | typedef struct IOMMMIORANGEGC *PIOMMMIORANGEGC;
|
---|
130 |
|
---|
131 |
|
---|
132 | /**
|
---|
133 | * MMIO address statistics. (one address)
|
---|
134 | *
|
---|
135 | * This is a simple way of making on demand statistics, however it's a
|
---|
136 | * bit free with the hypervisor heap memory..
|
---|
137 | */
|
---|
138 | typedef struct IOMMMIOSTATS
|
---|
139 | {
|
---|
140 | /** Avl node core with the address as Key. */
|
---|
141 | AVLOGCPHYSNODECORE Core;
|
---|
142 | /** Number of reads to this address from R3. */
|
---|
143 | STAMCOUNTER ReadR3;
|
---|
144 | /** Number of writes to this address from R3. */
|
---|
145 | STAMCOUNTER WriteR3;
|
---|
146 | /** Number of reads to this address from R0. */
|
---|
147 | STAMCOUNTER ReadR0;
|
---|
148 | /** Number of writes to this address from R0. */
|
---|
149 | STAMCOUNTER WriteR0;
|
---|
150 | /** Number of reads to this address from GC. */
|
---|
151 | STAMCOUNTER ReadGC;
|
---|
152 | /** Number of writes to this address from GC. */
|
---|
153 | STAMCOUNTER WriteGC;
|
---|
154 | /** Profiling read handler overhead in R3. */
|
---|
155 | STAMPROFILEADV ProfReadR3;
|
---|
156 | /** Profiling write handler overhead in R3. */
|
---|
157 | STAMPROFILEADV ProfWriteR3;
|
---|
158 | /** Profiling read handler overhead in R0. */
|
---|
159 | STAMPROFILEADV ProfReadR0;
|
---|
160 | /** Profiling write handler overhead in R0. */
|
---|
161 | STAMPROFILEADV ProfWriteR0;
|
---|
162 | /** Profiling read handler overhead in GC. */
|
---|
163 | STAMPROFILEADV ProfReadGC;
|
---|
164 | /** Profiling write handler overhead in GC. */
|
---|
165 | STAMPROFILEADV ProfWriteGC;
|
---|
166 | /** Number of reads to this address from R0 which was serviced in R3. */
|
---|
167 | STAMCOUNTER ReadR0ToR3;
|
---|
168 | /** Number of writes to this address from R0 which was serviced in R3. */
|
---|
169 | STAMCOUNTER WriteR0ToR3;
|
---|
170 | /** Number of reads to this address from GC which was serviced in R3. */
|
---|
171 | STAMCOUNTER ReadGCToR3;
|
---|
172 | /** Number of writes to this address from GC which was serviced in R3. */
|
---|
173 | STAMCOUNTER WriteGCToR3;
|
---|
174 | } IOMMMIOSTATS;
|
---|
175 | /** Pointer to I/O port statistics. */
|
---|
176 | typedef IOMMMIOSTATS *PIOMMMIOSTATS;
|
---|
177 |
|
---|
178 |
|
---|
179 | /**
|
---|
180 | * I/O port range descriptor, R3 version.
|
---|
181 | */
|
---|
182 | typedef struct IOMIOPORTRANGER3
|
---|
183 | {
|
---|
184 | /** Avl node core with Port as Key and Port + cPorts - 1 as KeyLast. */
|
---|
185 | AVLROIOPORTNODECORE Core;
|
---|
186 | #if HC_ARCH_BITS == 64 && GC_ARCH_BITS == 32 && !defined(RT_OS_WINDOWS)
|
---|
187 | uint32_t u32Alignment; /**< The sizeof(Core) differs. */
|
---|
188 | #endif
|
---|
189 | /** Start I/O port address. */
|
---|
190 | RTIOPORT Port;
|
---|
191 | /** Size of the range. */
|
---|
192 | uint16_t cPorts;
|
---|
193 | /** Pointer to user argument. */
|
---|
194 | RTR3PTR pvUser;
|
---|
195 | /** Pointer to the associated device instance. */
|
---|
196 | R3PTRTYPE(PPDMDEVINS) pDevIns;
|
---|
197 | /** Pointer to OUT callback function. */
|
---|
198 | R3PTRTYPE(PFNIOMIOPORTOUT) pfnOutCallback;
|
---|
199 | /** Pointer to IN callback function. */
|
---|
200 | R3PTRTYPE(PFNIOMIOPORTIN) pfnInCallback;
|
---|
201 | /** Pointer to string OUT callback function. */
|
---|
202 | R3PTRTYPE(PFNIOMIOPORTOUTSTRING) pfnOutStrCallback;
|
---|
203 | /** Pointer to string IN callback function. */
|
---|
204 | R3PTRTYPE(PFNIOMIOPORTINSTRING) pfnInStrCallback;
|
---|
205 | /** Description / Name. For easing debugging. */
|
---|
206 | R3PTRTYPE(const char *) pszDesc;
|
---|
207 | } IOMIOPORTRANGER3;
|
---|
208 | /** Pointer to I/O port range descriptor, R3 version. */
|
---|
209 | typedef IOMIOPORTRANGER3 *PIOMIOPORTRANGER3;
|
---|
210 |
|
---|
211 | /**
|
---|
212 | * I/O port range descriptor, R0 version.
|
---|
213 | */
|
---|
214 | typedef struct IOMIOPORTRANGER0
|
---|
215 | {
|
---|
216 | /** Avl node core with Port as Key and Port + cPorts - 1 as KeyLast. */
|
---|
217 | AVLROIOPORTNODECORE Core;
|
---|
218 | #if HC_ARCH_BITS == 64 && GC_ARCH_BITS == 32 && !defined(RT_OS_WINDOWS)
|
---|
219 | uint32_t u32Alignment; /**< The sizeof(Core) differs. */
|
---|
220 | #endif
|
---|
221 | /** Start I/O port address. */
|
---|
222 | RTIOPORT Port;
|
---|
223 | /** Size of the range. */
|
---|
224 | uint16_t cPorts;
|
---|
225 | /** Pointer to user argument. */
|
---|
226 | RTR0PTR pvUser;
|
---|
227 | /** Pointer to the associated device instance. */
|
---|
228 | R0PTRTYPE(PPDMDEVINS) pDevIns;
|
---|
229 | /** Pointer to OUT callback function. */
|
---|
230 | R0PTRTYPE(PFNIOMIOPORTOUT) pfnOutCallback;
|
---|
231 | /** Pointer to IN callback function. */
|
---|
232 | R0PTRTYPE(PFNIOMIOPORTIN) pfnInCallback;
|
---|
233 | /** Pointer to string OUT callback function. */
|
---|
234 | R0PTRTYPE(PFNIOMIOPORTOUTSTRING) pfnOutStrCallback;
|
---|
235 | /** Pointer to string IN callback function. */
|
---|
236 | R0PTRTYPE(PFNIOMIOPORTINSTRING) pfnInStrCallback;
|
---|
237 | /** Description / Name. For easing debugging. */
|
---|
238 | R3PTRTYPE(const char *) pszDesc;
|
---|
239 | } IOMIOPORTRANGER0;
|
---|
240 | /** Pointer to I/O port range descriptor, R0 version. */
|
---|
241 | typedef IOMIOPORTRANGER0 *PIOMIOPORTRANGER0;
|
---|
242 |
|
---|
243 | /**
|
---|
244 | * I/O port range descriptor.
|
---|
245 | */
|
---|
246 | typedef struct IOMIOPORTRANGEGC
|
---|
247 | {
|
---|
248 | /** Avl node core with Port as Key and Port + cPorts - 1 as KeyLast. */
|
---|
249 | AVLROIOPORTNODECORE Core;
|
---|
250 | /** Start I/O port address. */
|
---|
251 | RTIOPORT Port;
|
---|
252 | /** Size of the range. */
|
---|
253 | uint16_t cPorts;
|
---|
254 | /** Pointer to user argument. */
|
---|
255 | RTGCPTR pvUser;
|
---|
256 | /** Pointer to the associated device instance. */
|
---|
257 | GCPTRTYPE(PPDMDEVINS) pDevIns;
|
---|
258 | /** Pointer to OUT callback function. */
|
---|
259 | GCPTRTYPE(PFNIOMIOPORTOUT) pfnOutCallback;
|
---|
260 | /** Pointer to IN callback function. */
|
---|
261 | GCPTRTYPE(PFNIOMIOPORTIN) pfnInCallback;
|
---|
262 | /** Pointer to string OUT callback function. */
|
---|
263 | GCPTRTYPE(PFNIOMIOPORTOUTSTRING) pfnOutStrCallback;
|
---|
264 | /** Pointer to string IN callback function. */
|
---|
265 | GCPTRTYPE(PFNIOMIOPORTINSTRING) pfnInStrCallback;
|
---|
266 | #if HC_ARCH_BITS == 64 && GC_ARCH_BITS == 32
|
---|
267 | RTGCPTR GCPtrAlignment; /**< pszDesc is 8 byte aligned. */
|
---|
268 | #endif
|
---|
269 | /** Description / Name. For easing debugging. */
|
---|
270 | R3PTRTYPE(const char *) pszDesc;
|
---|
271 | } IOMIOPORTRANGEGC;
|
---|
272 | /** Pointer to I/O port range descriptor, GC version. */
|
---|
273 | typedef IOMIOPORTRANGEGC *PIOMIOPORTRANGEGC;
|
---|
274 |
|
---|
275 |
|
---|
276 | /**
|
---|
277 | * I/O port statistics. (one I/O port)
|
---|
278 | *
|
---|
279 | * This is a simple way of making on demand statistics, however it's a
|
---|
280 | * bit free with the hypervisor heap memory..
|
---|
281 | */
|
---|
282 | typedef struct IOMIOPORTSTATS
|
---|
283 | {
|
---|
284 | /** Avl node core with the port as Key. */
|
---|
285 | AVLOIOPORTNODECORE Core;
|
---|
286 | #if HC_ARCH_BITS == 64 && GC_ARCH_BITS == 32 && !defined(RT_OS_WINDOWS)
|
---|
287 | uint32_t u32Alignment; /**< The sizeof(Core) differs. */
|
---|
288 | #endif
|
---|
289 | /** Number of INs to this port from R3. */
|
---|
290 | STAMCOUNTER InR3;
|
---|
291 | /** Number of OUTs to this port from R3. */
|
---|
292 | STAMCOUNTER OutR3;
|
---|
293 | /** Number of INs to this port from R0. */
|
---|
294 | STAMCOUNTER InR0;
|
---|
295 | /** Number of OUTs to this port from R0. */
|
---|
296 | STAMCOUNTER OutR0;
|
---|
297 | /** Number of INs to this port from GC. */
|
---|
298 | STAMCOUNTER InGC;
|
---|
299 | /** Number of OUTs to this port from GC. */
|
---|
300 | STAMCOUNTER OutGC;
|
---|
301 | /** Profiling IN handler overhead in R3. */
|
---|
302 | STAMPROFILEADV ProfInR3;
|
---|
303 | /** Profiling OUT handler overhead in R3. */
|
---|
304 | STAMPROFILEADV ProfOutR3;
|
---|
305 | /** Profiling IN handler overhead in R0. */
|
---|
306 | STAMPROFILEADV ProfInR0;
|
---|
307 | /** Profiling OUT handler overhead in R0. */
|
---|
308 | STAMPROFILEADV ProfOutR0;
|
---|
309 | /** Profiling IN handler overhead in GC. */
|
---|
310 | STAMPROFILEADV ProfInGC;
|
---|
311 | /** Profiling OUT handler overhead in GC. */
|
---|
312 | STAMPROFILEADV ProfOutGC;
|
---|
313 | /** Number of INs to this port from R0 which was serviced in R3. */
|
---|
314 | STAMCOUNTER InR0ToR3;
|
---|
315 | /** Number of OUTs to this port from R0 which was serviced in R3. */
|
---|
316 | STAMCOUNTER OutR0ToR3;
|
---|
317 | /** Number of INs to this port from GC which was serviced in R3. */
|
---|
318 | STAMCOUNTER InGCToR3;
|
---|
319 | /** Number of OUTs to this port from GC which was serviced in R3. */
|
---|
320 | STAMCOUNTER OutGCToR3;
|
---|
321 | } IOMIOPORTSTATS;
|
---|
322 | /** Pointer to I/O port statistics. */
|
---|
323 | typedef IOMIOPORTSTATS *PIOMIOPORTSTATS;
|
---|
324 |
|
---|
325 |
|
---|
326 | /**
|
---|
327 | * The IOM trees.
|
---|
328 | * These are offset based the nodes and root must be in the same
|
---|
329 | * memory block in HC. The locations of IOM structure and the hypervisor heap
|
---|
330 | * are quite different in HC and GC.
|
---|
331 | */
|
---|
332 | typedef struct IOMTREES
|
---|
333 | {
|
---|
334 | /** Tree containing I/O port range descriptors registered for HC (IOMIOPORTRANGEHC). */
|
---|
335 | AVLROIOPORTTREE IOPortTreeR3;
|
---|
336 | /** Tree containing I/O port range descriptors registered for R0 (IOMIOPORTRANGER0). */
|
---|
337 | AVLROIOPORTTREE IOPortTreeR0;
|
---|
338 | /** Tree containing I/O port range descriptors registered for GC (IOMIOPORTRANGEGC). */
|
---|
339 | AVLROIOPORTTREE IOPortTreeGC;
|
---|
340 |
|
---|
341 | /** Tree containing MMIO range descriptors registered for HC (IOMMMIORANGEHC). */
|
---|
342 | AVLROGCPHYSTREE MMIOTreeR3;
|
---|
343 | /** Tree containing MMIO range descriptors registered for R0 (IOMMMIORANGER0). */
|
---|
344 | AVLROGCPHYSTREE MMIOTreeR0;
|
---|
345 | /** Tree containing MMIO range descriptors registered for GC (IOMMMIORANGEGC). */
|
---|
346 | AVLROGCPHYSTREE MMIOTreeGC;
|
---|
347 |
|
---|
348 | /** Tree containing I/O port statistics (IOMIOPORTSTATS). */
|
---|
349 | AVLOIOPORTTREE IOPortStatTree;
|
---|
350 | /** Tree containing MMIO statistics (IOMMMIOSTATS). */
|
---|
351 | AVLOGCPHYSTREE MMIOStatTree;
|
---|
352 | } IOMTREES;
|
---|
353 | /** Pointer to the IOM trees. */
|
---|
354 | typedef IOMTREES *PIOMTREES;
|
---|
355 |
|
---|
356 |
|
---|
357 | /**
|
---|
358 | * Converts an IOM pointer into a VM pointer.
|
---|
359 | * @returns Pointer to the VM structure the PGM is part of.
|
---|
360 | * @param pIOM Pointer to IOM instance data.
|
---|
361 | */
|
---|
362 | #define IOM2VM(pIOM) ( (PVM)((char*)pIOM - pIOM->offVM) )
|
---|
363 |
|
---|
364 | /**
|
---|
365 | * IOM Data (part of VM)
|
---|
366 | */
|
---|
367 | typedef struct IOM
|
---|
368 | {
|
---|
369 | /** Offset to the VM structure. */
|
---|
370 | RTINT offVM;
|
---|
371 |
|
---|
372 | /** Pointer to the trees - GC ptr. */
|
---|
373 | GCPTRTYPE(PIOMTREES) pTreesGC;
|
---|
374 | /** Pointer to the trees - HC ptr. */
|
---|
375 | R3R0PTRTYPE(PIOMTREES) pTreesHC;
|
---|
376 |
|
---|
377 |
|
---|
378 | /** @name Caching of I/O Port ranges and statistics.
|
---|
379 | * (Saves quite some time in rep outs/ins instruction emulation.)
|
---|
380 | * @{ */
|
---|
381 | R3PTRTYPE(PIOMIOPORTRANGER3) pRangeLastReadR3;
|
---|
382 | R3PTRTYPE(PIOMIOPORTRANGER3) pRangeLastWriteR3;
|
---|
383 | R3PTRTYPE(PIOMIOPORTSTATS) pStatsLastReadR3;
|
---|
384 | R3PTRTYPE(PIOMIOPORTSTATS) pStatsLastWriteR3;
|
---|
385 |
|
---|
386 | R3R0PTRTYPE(PIOMIOPORTRANGER0) pRangeLastReadR0;
|
---|
387 | R3R0PTRTYPE(PIOMIOPORTRANGER0) pRangeLastWriteR0;
|
---|
388 | R3R0PTRTYPE(PIOMIOPORTSTATS) pStatsLastReadR0;
|
---|
389 | R3R0PTRTYPE(PIOMIOPORTSTATS) pStatsLastWriteR0;
|
---|
390 |
|
---|
391 | GCPTRTYPE(PIOMIOPORTRANGEGC) pRangeLastReadGC;
|
---|
392 | GCPTRTYPE(PIOMIOPORTRANGEGC) pRangeLastWriteGC;
|
---|
393 | GCPTRTYPE(PIOMIOPORTSTATS) pStatsLastReadGC;
|
---|
394 | GCPTRTYPE(PIOMIOPORTSTATS) pStatsLastWriteGC;
|
---|
395 | /** @} */
|
---|
396 |
|
---|
397 | /** @name I/O Port statistics.
|
---|
398 | * @{ */
|
---|
399 | STAMPROFILE StatGCIOPortHandler;
|
---|
400 |
|
---|
401 | STAMCOUNTER StatGCInstIn;
|
---|
402 | STAMCOUNTER StatGCInstOut;
|
---|
403 | STAMCOUNTER StatGCInstIns;
|
---|
404 | STAMCOUNTER StatGCInstOuts;
|
---|
405 | /** @} */
|
---|
406 |
|
---|
407 | /** @name MMIO statistics.
|
---|
408 | * @{ */
|
---|
409 | STAMPROFILE StatGCMMIOHandler;
|
---|
410 | STAMCOUNTER StatGCMMIOFailures;
|
---|
411 |
|
---|
412 | STAMPROFILE StatGCInstMov;
|
---|
413 | STAMPROFILE StatGCInstCmp;
|
---|
414 | STAMPROFILE StatGCInstAnd;
|
---|
415 | STAMPROFILE StatGCInstTest;
|
---|
416 | STAMPROFILE StatGCInstXchg;
|
---|
417 | STAMPROFILE StatGCInstStos;
|
---|
418 | STAMPROFILE StatGCInstLods;
|
---|
419 | STAMPROFILE StatGCInstMovs;
|
---|
420 | STAMPROFILE StatGCInstMovsToMMIO;
|
---|
421 | STAMPROFILE StatGCInstMovsFromMMIO;
|
---|
422 | STAMPROFILE StatGCInstMovsMMIO;
|
---|
423 | STAMCOUNTER StatGCInstOther;
|
---|
424 |
|
---|
425 | STAMCOUNTER StatGCMMIO1Byte;
|
---|
426 | STAMCOUNTER StatGCMMIO2Bytes;
|
---|
427 | STAMCOUNTER StatGCMMIO4Bytes;
|
---|
428 |
|
---|
429 | RTUINT cMovsMaxBytes;
|
---|
430 | RTUINT cStosMaxBytes;
|
---|
431 | /** @} */
|
---|
432 |
|
---|
433 | } IOM;
|
---|
434 | /** Pointer to IOM instance data. */
|
---|
435 | typedef IOM *PIOM;
|
---|
436 |
|
---|
437 |
|
---|
438 | __BEGIN_DECLS
|
---|
439 |
|
---|
440 | #ifdef IN_IOM_R3
|
---|
441 | PIOMIOPORTSTATS iomr3IOPortStatsCreate(PVM pVM, RTIOPORT Port, const char *pszDesc);
|
---|
442 | PIOMMMIOSTATS iomR3MMIOStatsCreate(PVM pVM, RTGCPHYS GCPhys, const char *pszDesc);
|
---|
443 | #endif /* IN_IOM_R3 */
|
---|
444 |
|
---|
445 | /**
|
---|
446 | * \#PF Handler callback for MMIO ranges.
|
---|
447 | *
|
---|
448 | * @returns VBox status code (appropriate for GC return).
|
---|
449 | *
|
---|
450 | * @param pVM VM Handle.
|
---|
451 | * @param uErrorCode CPU Error code.
|
---|
452 | * @param pRegFrame Trap register frame.
|
---|
453 | * @param pvFault The fault address (cr2).
|
---|
454 | * @param GCPhysFault The GC physical address corresponding to pvFault.
|
---|
455 | * @param pvUser Pointer to the MMIO range entry.
|
---|
456 | */
|
---|
457 | IOMDECL(int) IOMMMIOHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, void *pvFault, RTGCPHYS GCPhysFault, void *pvUser);
|
---|
458 |
|
---|
459 | /**
|
---|
460 | * Gets the I/O port range for the specified I/O port in the current context.
|
---|
461 | *
|
---|
462 | * @returns Pointer to I/O port range.
|
---|
463 | * @returns NULL if no port registered.
|
---|
464 | *
|
---|
465 | * @param pIOM IOM instance data.
|
---|
466 | * @param Port Port to lookup.
|
---|
467 | */
|
---|
468 | inline CTXALLSUFF(PIOMIOPORTRANGE) iomIOPortGetRange(PIOM pIOM, RTIOPORT Port)
|
---|
469 | {
|
---|
470 | CTXALLSUFF(PIOMIOPORTRANGE) pRange = (CTXALLSUFF(PIOMIOPORTRANGE))RTAvlroIOPortRangeGet(&pIOM->CTXSUFF(pTrees)->CTXALLSUFF(IOPortTree), Port);
|
---|
471 | return pRange;
|
---|
472 | }
|
---|
473 |
|
---|
474 | /**
|
---|
475 | * Gets the I/O port range for the specified I/O port in the HC.
|
---|
476 | *
|
---|
477 | * @returns Pointer to I/O port range.
|
---|
478 | * @returns NULL if no port registered.
|
---|
479 | *
|
---|
480 | * @param pIOM IOM instance data.
|
---|
481 | * @param Port Port to lookup.
|
---|
482 | */
|
---|
483 | inline PIOMIOPORTRANGER3 iomIOPortGetRangeHC(PIOM pIOM, RTIOPORT Port)
|
---|
484 | {
|
---|
485 | PIOMIOPORTRANGER3 pRange = (PIOMIOPORTRANGER3)RTAvlroIOPortRangeGet(&pIOM->CTXSUFF(pTrees)->IOPortTreeR3, Port);
|
---|
486 | return pRange;
|
---|
487 | }
|
---|
488 |
|
---|
489 |
|
---|
490 | /**
|
---|
491 | * Gets the MMIO range for the specified physical address in the current context.
|
---|
492 | *
|
---|
493 | * @returns Pointer to MMIO range.
|
---|
494 | * @returns NULL if address not in a MMIO range.
|
---|
495 | *
|
---|
496 | * @param pIOM IOM instance data.
|
---|
497 | * @param GCPhys Physical address to lookup.
|
---|
498 | */
|
---|
499 | inline CTXALLSUFF(PIOMMMIORANGE) iomMMIOGetRange(PIOM pIOM, RTGCPHYS GCPhys)
|
---|
500 | {
|
---|
501 | CTXALLSUFF(PIOMMMIORANGE) pRange = (CTXALLSUFF(PIOMMMIORANGE))RTAvlroGCPhysRangeGet(&pIOM->CTXSUFF(pTrees)->CTXALLSUFF(MMIOTree), GCPhys);
|
---|
502 | return pRange;
|
---|
503 | }
|
---|
504 |
|
---|
505 |
|
---|
506 | /**
|
---|
507 | * Gets the MMIO range for the specified physical address in the current context.
|
---|
508 | *
|
---|
509 | * @returns Pointer to MMIO range.
|
---|
510 | * @returns NULL if address not in a MMIO range.
|
---|
511 | *
|
---|
512 | * @param pIOM IOM instance data.
|
---|
513 | * @param GCPhys Physical address to lookup.
|
---|
514 | */
|
---|
515 | inline PIOMMMIORANGER3 iomMMIOGetRangeHC(PIOM pIOM, RTGCPHYS GCPhys)
|
---|
516 | {
|
---|
517 | PIOMMMIORANGER3 pRange = (PIOMMMIORANGER3)RTAvlroGCPhysRangeGet(&pIOM->CTXSUFF(pTrees)->MMIOTreeR3, GCPhys);
|
---|
518 | return pRange;
|
---|
519 | }
|
---|
520 |
|
---|
521 | #ifdef VBOX_WITH_STATISTICS
|
---|
522 | /**
|
---|
523 | * Gets the MMIO statistics record.
|
---|
524 | * @returns Pointer to MMIO stats.
|
---|
525 | * @returns NULL if not found.
|
---|
526 | *
|
---|
527 | * @param pIOM IOM instance data.
|
---|
528 | * @param GCPhys Physical address to lookup.
|
---|
529 | */
|
---|
530 | inline PIOMMMIOSTATS iomMMIOGetStats(PIOM pIOM, RTGCPHYS GCPhys)
|
---|
531 | {
|
---|
532 | PIOMMMIOSTATS pStats = (PIOMMMIOSTATS)RTAvloGCPhysGet(&pIOM->CTXSUFF(pTrees)->MMIOStatTree, GCPhys);
|
---|
533 | return pStats;
|
---|
534 | }
|
---|
535 | #endif
|
---|
536 |
|
---|
537 | __END_DECLS
|
---|
538 |
|
---|
539 | #ifdef IN_RING3
|
---|
540 |
|
---|
541 | #endif
|
---|
542 |
|
---|
543 | /** @} */
|
---|
544 |
|
---|
545 | #endif /* ___IOMInternal_h */
|
---|