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