VirtualBox

source: vbox/trunk/include/VBox/vmm/iom.h@ 81197

最後變更 在這個檔案從81197是 81197,由 vboxsync 提交於 5 年 前

IOM: More MMIO code. bugref:9218

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 28.4 KB
 
1/** @file
2 * IOM - Input / Output Monitor.
3 */
4
5/*
6 * Copyright (C) 2006-2019 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.alldomusa.eu.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef VBOX_INCLUDED_vmm_iom_h
27#define VBOX_INCLUDED_vmm_iom_h
28#ifndef RT_WITHOUT_PRAGMA_ONCE
29# pragma once
30#endif
31
32#include <VBox/types.h>
33#include <VBox/dis.h>
34#include <VBox/vmm/dbgf.h>
35
36RT_C_DECLS_BEGIN
37
38
39/** @defgroup grp_iom The Input / Ouput Monitor API
40 * @ingroup grp_vmm
41 * @{
42 */
43
44/** @def IOM_NO_PDMINS_CHECKS
45 * Until all devices have been fully adjusted to PDM style, the pPdmIns
46 * parameter is not checked by IOM.
47 * @todo Check this again, now.
48 */
49#define IOM_NO_PDMINS_CHECKS
50
51/**
52 * Macro for checking if an I/O or MMIO emulation call succeeded.
53 *
54 * This macro shall only be used with the IOM APIs where it's mentioned
55 * in the return value description. And there it must be used to correctly
56 * determine if the call succeeded and things like the RIP needs updating.
57 *
58 *
59 * @returns Success indicator (true/false).
60 *
61 * @param rc The status code. This may be evaluated
62 * more than once!
63 *
64 * @remarks To avoid making assumptions about the layout of the
65 * VINF_EM_FIRST...VINF_EM_LAST range we're checking explicitly for
66 * each exact exception. However, for efficiency we ASSUME that the
67 * VINF_EM_LAST is smaller than most of the relevant status codes. We
68 * also ASSUME that the VINF_EM_RESCHEDULE_REM status code is the
69 * most frequent status code we'll enounter in this range.
70 *
71 * @todo Will have to add VINF_EM_DBG_HYPER_BREAKPOINT if the
72 * I/O port and MMIO breakpoints should trigger before
73 * the I/O is done. Currently, we don't implement these
74 * kind of breakpoints.
75 */
76#ifdef IN_RING3
77# define IOM_SUCCESS(rc) ( (rc) == VINF_SUCCESS \
78 || ( (rc) <= VINF_EM_LAST \
79 && (rc) != VINF_EM_RESCHEDULE_REM \
80 && (rc) >= VINF_EM_FIRST \
81 && (rc) != VINF_EM_RESCHEDULE_RAW \
82 && (rc) != VINF_EM_RESCHEDULE_HM \
83 ) \
84 )
85#else
86# define IOM_SUCCESS(rc) ( (rc) == VINF_SUCCESS \
87 || ( (rc) <= VINF_EM_LAST \
88 && (rc) != VINF_EM_RESCHEDULE_REM \
89 && (rc) >= VINF_EM_FIRST \
90 && (rc) != VINF_EM_RESCHEDULE_RAW \
91 && (rc) != VINF_EM_RESCHEDULE_HM \
92 ) \
93 || (rc) == VINF_IOM_R3_IOPORT_COMMIT_WRITE \
94 || (rc) == VINF_IOM_R3_MMIO_COMMIT_WRITE \
95 )
96#endif
97
98/** @name IOMMMIO_FLAGS_XXX
99 * @{ */
100/** Pass all reads thru unmodified. */
101#define IOMMMIO_FLAGS_READ_PASSTHRU UINT32_C(0x00000000)
102/** All read accesses are DWORD sized (32-bit). */
103#define IOMMMIO_FLAGS_READ_DWORD UINT32_C(0x00000001)
104/** All read accesses are DWORD (32-bit) or QWORD (64-bit) sized.
105 * Only accesses that are both QWORD sized and aligned are performed as QWORD.
106 * All other access will be done DWORD fashion (because it is way simpler). */
107#define IOMMMIO_FLAGS_READ_DWORD_QWORD UINT32_C(0x00000002)
108/** The read access mode mask. */
109#define IOMMMIO_FLAGS_READ_MODE UINT32_C(0x00000003)
110
111/** Pass all writes thru unmodified. */
112#define IOMMMIO_FLAGS_WRITE_PASSTHRU UINT32_C(0x00000000)
113/** All write accesses are DWORD (32-bit) sized and unspecified bytes are
114 * written as zero. */
115#define IOMMMIO_FLAGS_WRITE_DWORD_ZEROED UINT32_C(0x00000010)
116/** All write accesses are either DWORD (32-bit) or QWORD (64-bit) sized,
117 * missing bytes will be written as zero. Only accesses that are both QWORD
118 * sized and aligned are performed as QWORD, all other accesses will be done
119 * DWORD fashion (because it's way simpler). */
120#define IOMMMIO_FLAGS_WRITE_DWORD_QWORD_ZEROED UINT32_C(0x00000020)
121/** All write accesses are DWORD (32-bit) sized and unspecified bytes are
122 * read from the device first as DWORDs.
123 * @remarks This isn't how it happens on real hardware, but it allows
124 * simplifications of devices where reads doesn't change the device
125 * state in any way. */
126#define IOMMMIO_FLAGS_WRITE_DWORD_READ_MISSING UINT32_C(0x00000030)
127/** All write accesses are DWORD (32-bit) or QWORD (64-bit) sized and
128 * unspecified bytes are read from the device first as DWORDs. Only accesses
129 * that are both QWORD sized and aligned are performed as QWORD, all other
130 * accesses will be done DWORD fashion (because it's way simpler).
131 * @remarks This isn't how it happens on real hardware, but it allows
132 * simplifications of devices where reads doesn't change the device
133 * state in any way. */
134#define IOMMMIO_FLAGS_WRITE_DWORD_QWORD_READ_MISSING UINT32_C(0x00000040)
135/** All write accesses are DWORD (32-bit) sized and aligned, attempts at other
136 * accesses are ignored.
137 * @remarks E1000, APIC */
138#define IOMMMIO_FLAGS_WRITE_ONLY_DWORD UINT32_C(0x00000050)
139/** All write accesses are DWORD (32-bit) or QWORD (64-bit) sized and aligned,
140 * attempts at other accesses are ignored.
141 * @remarks Seemingly required by AHCI (although I doubt it's _really_
142 * required as EM/REM doesn't do the right thing in ring-3 anyway,
143 * esp. not in raw-mode). */
144#define IOMMMIO_FLAGS_WRITE_ONLY_DWORD_QWORD UINT32_C(0x00000060)
145/** The read access mode mask. */
146#define IOMMMIO_FLAGS_WRITE_MODE UINT32_C(0x00000070)
147
148/** Whether to do a DBGSTOP on complicated reads.
149 * What this includes depends on the read mode, but generally all misaligned
150 * reads as well as word and byte reads and maybe qword reads. */
151#define IOMMMIO_FLAGS_DBGSTOP_ON_COMPLICATED_READ UINT32_C(0x00000100)
152/** Whether to do a DBGSTOP on complicated writes.
153 * This depends on the write mode, but generally all writes where we have to
154 * supply bytes (zero them or read them). */
155#define IOMMMIO_FLAGS_DBGSTOP_ON_COMPLICATED_WRITE UINT32_C(0x00000200)
156
157/** Mask of valid flags. */
158#define IOMMMIO_FLAGS_VALID_MASK UINT32_C(0x00000373)
159/** @} */
160
161/**
162 * Checks whether the write mode allows aligned QWORD accesses to be passed
163 * thru to the device handler.
164 * @param a_fFlags The MMIO handler flags.
165 */
166#define IOMMMIO_DOES_WRITE_MODE_ALLOW_QWORD(a_fFlags) \
167 ( ((a_fFlags) & IOMMMIO_FLAGS_WRITE_MODE) == IOMMMIO_FLAGS_WRITE_DWORD_QWORD_ZEROED \
168 || ((a_fFlags) & IOMMMIO_FLAGS_WRITE_MODE) == IOMMMIO_FLAGS_WRITE_DWORD_QWORD_READ_MISSING \
169 || ((a_fFlags) & IOMMMIO_FLAGS_WRITE_MODE) == IOMMMIO_FLAGS_WRITE_ONLY_DWORD_QWORD )
170
171
172/**
173 * Port I/O Handler for IN operations.
174 *
175 * @returns VINF_SUCCESS or VINF_EM_*.
176 * @returns VERR_IOM_IOPORT_UNUSED if the port is really unused and a ~0 value should be returned.
177 *
178 * @param pDevIns The device instance.
179 * @param pvUser User argument.
180 * @param uPort Port number used for the IN operation.
181 * @param pu32 Where to store the result. This is always a 32-bit
182 * variable regardless of what @a cb might say.
183 * @param cb Number of bytes read.
184 * @remarks Caller enters the device critical section.
185 */
186typedef DECLCALLBACK(int) FNIOMIOPORTIN(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT uPort, uint32_t *pu32, unsigned cb);
187/** Pointer to a FNIOMIOPORTIN(). */
188typedef FNIOMIOPORTIN *PFNIOMIOPORTIN;
189
190/**
191 * Port I/O Handler for string IN operations.
192 *
193 * @returns VINF_SUCCESS or VINF_EM_*.
194 * @returns VERR_IOM_IOPORT_UNUSED if the port is really unused and a ~0 value should be returned.
195 *
196 * @param pDevIns The device instance.
197 * @param pvUser User argument.
198 * @param uPort Port number used for the IN operation.
199 * @param pbDst Pointer to the destination buffer.
200 * @param pcTransfers Pointer to the number of transfer units to read, on
201 * return remaining transfer units.
202 * @param cb Size of the transfer unit (1, 2 or 4 bytes).
203 * @remarks Caller enters the device critical section.
204 */
205typedef DECLCALLBACK(int) FNIOMIOPORTINSTRING(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT uPort, uint8_t *pbDst,
206 uint32_t *pcTransfers, unsigned cb);
207/** Pointer to a FNIOMIOPORTINSTRING(). */
208typedef FNIOMIOPORTINSTRING *PFNIOMIOPORTINSTRING;
209
210/**
211 * Port I/O Handler for OUT operations.
212 *
213 * @returns VINF_SUCCESS or VINF_EM_*.
214 *
215 * @param pDevIns The device instance.
216 * @param pvUser User argument.
217 * @param uPort Port number used for the OUT operation.
218 * @param u32 The value to output.
219 * @param cb The value size in bytes.
220 * @remarks Caller enters the device critical section.
221 */
222typedef DECLCALLBACK(int) FNIOMIOPORTOUT(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT uPort, uint32_t u32, unsigned cb);
223/** Pointer to a FNIOMIOPORTOUT(). */
224typedef FNIOMIOPORTOUT *PFNIOMIOPORTOUT;
225
226/**
227 * Port I/O Handler for string OUT operations.
228 *
229 * @returns VINF_SUCCESS or VINF_EM_*.
230 *
231 * @param pDevIns The device instance.
232 * @param pvUser User argument.
233 * @param uPort Port number used for the OUT operation.
234 * @param pbSrc Pointer to the source buffer.
235 * @param pcTransfers Pointer to the number of transfer units to write, on
236 * return remaining transfer units.
237 * @param cb Size of the transfer unit (1, 2 or 4 bytes).
238 * @remarks Caller enters the device critical section.
239 */
240typedef DECLCALLBACK(int) FNIOMIOPORTOUTSTRING(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT uPort, const uint8_t *pbSrc,
241 uint32_t *pcTransfers, unsigned cb);
242/** Pointer to a FNIOMIOPORTOUTSTRING(). */
243typedef FNIOMIOPORTOUTSTRING *PFNIOMIOPORTOUTSTRING;
244
245
246/**
247 * Port I/O Handler for IN operations.
248 *
249 * @returns VINF_SUCCESS or VINF_EM_*.
250 * @returns VERR_IOM_IOPORT_UNUSED if the port is really unused and a ~0 value should be returned.
251 *
252 * @param pDevIns The device instance.
253 * @param pvUser User argument.
254 * @param offPort The port number if IOM_IOPORT_F_ABS is used, otherwise
255 * relative to the mapping base.
256 * @param pu32 Where to store the result. This is always a 32-bit
257 * variable regardless of what @a cb might say.
258 * @param cb Number of bytes read.
259 * @remarks Caller enters the device critical section.
260 */
261typedef DECLCALLBACK(VBOXSTRICTRC) FNIOMIOPORTNEWIN(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t *pu32, unsigned cb);
262/** Pointer to a FNIOMIOPORTNEWIN(). */
263typedef FNIOMIOPORTNEWIN *PFNIOMIOPORTNEWIN;
264
265/**
266 * Port I/O Handler for string IN operations.
267 *
268 * @returns VINF_SUCCESS or VINF_EM_*.
269 * @returns VERR_IOM_IOPORT_UNUSED if the port is really unused and a ~0 value should be returned.
270 *
271 * @param pDevIns The device instance.
272 * @param pvUser User argument.
273 * @param offPort The port number if IOM_IOPORT_F_ABS is used, otherwise
274 * relative to the mapping base.
275 * @param pbDst Pointer to the destination buffer.
276 * @param pcTransfers Pointer to the number of transfer units to read, on
277 * return remaining transfer units.
278 * @param cb Size of the transfer unit (1, 2 or 4 bytes).
279 * @remarks Caller enters the device critical section.
280 */
281typedef DECLCALLBACK(VBOXSTRICTRC) FNIOMIOPORTNEWINSTRING(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint8_t *pbDst,
282 uint32_t *pcTransfers, unsigned cb);
283/** Pointer to a FNIOMIOPORTNEWINSTRING(). */
284typedef FNIOMIOPORTNEWINSTRING *PFNIOMIOPORTNEWINSTRING;
285
286/**
287 * Port I/O Handler for OUT operations.
288 *
289 * @returns VINF_SUCCESS or VINF_EM_*.
290 *
291 * @param pDevIns The device instance.
292 * @param pvUser User argument.
293 * @param offPort The port number if IOM_IOPORT_F_ABS is used, otherwise
294 * relative to the mapping base.
295 * @param u32 The value to output.
296 * @param cb The value size in bytes.
297 * @remarks Caller enters the device critical section.
298 */
299typedef DECLCALLBACK(VBOXSTRICTRC) FNIOMIOPORTNEWOUT(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb);
300/** Pointer to a FNIOMIOPORTNEWOUT(). */
301typedef FNIOMIOPORTNEWOUT *PFNIOMIOPORTNEWOUT;
302
303/**
304 * Port I/O Handler for string OUT operations.
305 *
306 * @returns VINF_SUCCESS or VINF_EM_*.
307 *
308 * @param pDevIns The device instance.
309 * @param pvUser User argument.
310 * @param offPort The port number if IOM_IOPORT_F_ABS is used, otherwise
311 * relative to the mapping base.
312 * @param pbSrc Pointer to the source buffer.
313 * @param pcTransfers Pointer to the number of transfer units to write, on
314 * return remaining transfer units.
315 * @param cb Size of the transfer unit (1, 2 or 4 bytes).
316 * @remarks Caller enters the device critical section.
317 */
318typedef DECLCALLBACK(VBOXSTRICTRC) FNIOMIOPORTNEWOUTSTRING(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, const uint8_t *pbSrc,
319 uint32_t *pcTransfers, unsigned cb);
320/** Pointer to a FNIOMIOPORTNEWOUTSTRING(). */
321typedef FNIOMIOPORTNEWOUTSTRING *PFNIOMIOPORTNEWOUTSTRING;
322
323/**
324 * I/O port description.
325 *
326 * If both pszIn and pszOut are NULL, the entry is considered a terminator.
327 */
328typedef struct IOMIOPORTDESC
329{
330 /** Brief description / name of the IN port. */
331 const char *pszIn;
332 /** Brief description / name of the OUT port. */
333 const char *pszOut;
334 /** Detailed description of the IN port, optional. */
335 const char *pszInDetail;
336 /** Detialed description of the OUT port, optional. */
337 const char *pszOutDetail;
338} IOMIOPORTDESC;
339/** Pointer to an I/O port description. */
340typedef IOMIOPORTDESC const *PCIOMIOPORTDESC;
341
342
343/**
344 * Memory mapped I/O Handler for read operations.
345 *
346 * @returns VBox status code.
347 *
348 * @param pDevIns The device instance.
349 * @param pvUser User argument.
350 * @param GCPhysAddr Physical address (in GC) where the read starts.
351 * @param pv Where to store the result.
352 * @param cb Number of bytes read.
353 * @remarks Caller enters the device critical section.
354 */
355typedef DECLCALLBACK(int) FNIOMMMIOREAD(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb);
356/** Pointer to a FNIOMMMIOREAD(). */
357typedef FNIOMMMIOREAD *PFNIOMMMIOREAD;
358
359/**
360 * Memory mapped I/O Handler for write operations.
361 *
362 * @returns VBox status code.
363 *
364 * @param pDevIns The device instance.
365 * @param pvUser User argument.
366 * @param GCPhysAddr Physical address (in GC) where the read starts.
367 * @param pv Where to fetch the result.
368 * @param cb Number of bytes to write.
369 * @remarks Caller enters the device critical section.
370 */
371typedef DECLCALLBACK(int) FNIOMMMIOWRITE(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void const *pv, unsigned cb);
372/** Pointer to a FNIOMMMIOWRITE(). */
373typedef FNIOMMMIOWRITE *PFNIOMMMIOWRITE;
374
375/**
376 * Memory mapped I/O Handler for memset operations, actually for REP STOS* instructions handling.
377 *
378 * @returns VBox status code.
379 *
380 * @param pDevIns The device instance.
381 * @param pvUser User argument.
382 * @param GCPhysAddr Physical address (in GC) where the write starts.
383 * @param u32Item Byte/Word/Dword data to fill.
384 * @param cbItem Size of data in u32Item parameter, restricted to 1/2/4 bytes.
385 * @param cItems Number of iterations.
386 * @remarks Caller enters the device critical section.
387 */
388typedef DECLCALLBACK(int) FNIOMMMIOFILL(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, uint32_t u32Item, unsigned cbItem, unsigned cItems);
389/** Pointer to a FNIOMMMIOFILL(). */
390typedef FNIOMMMIOFILL *PFNIOMMMIOFILL;
391
392
393/**
394 * Memory mapped I/O Handler for read operations.
395 *
396 * @returns Strict VBox status code.
397 *
398 * @param pDevIns The device instance.
399 * @param pvUser User argument.
400 * @param off Offset into the mapping of the read,
401 * or the physical address if IOM_MMIO_F_ABS is active.
402 * @param pv Where to store the result.
403 * @param cb Number of bytes read.
404 * @remarks Caller enters the device critical section.
405 */
406typedef DECLCALLBACK(VBOXSTRICTRC) FNIOMMMIONEWREAD(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void *pv, uint32_t cb);
407/** Pointer to a FNIOMMMIONEWREAD(). */
408typedef FNIOMMMIONEWREAD *PFNIOMMMIONEWREAD;
409
410/**
411 * Memory mapped I/O Handler for write operations.
412 *
413 * @returns Strict VBox status code.
414 *
415 * @param pDevIns The device instance.
416 * @param pvUser User argument.
417 * @param off Offset into the mapping of the write,
418 * or the physical address if IOM_MMIO_F_ABS is active.
419 * @param pv Where to fetch the result.
420 * @param cb Number of bytes to write.
421 * @remarks Caller enters the device critical section.
422 */
423typedef DECLCALLBACK(VBOXSTRICTRC) FNIOMMMIONEWWRITE(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void const *pv, uint32_t cb);
424/** Pointer to a FNIOMMMIONEWWRITE(). */
425typedef FNIOMMMIONEWWRITE *PFNIOMMMIONEWWRITE;
426
427/**
428 * Memory mapped I/O Handler for memset operations, actually for REP STOS* instructions handling.
429 *
430 * @returns Strict VBox status code.
431 *
432 * @param pDevIns The device instance.
433 * @param pvUser User argument.
434 * @param off Offset into the mapping of the fill,
435 * or the physical address if IOM_MMIO_F_ABS is active.
436 * @param u32Item Byte/Word/Dword data to fill.
437 * @param cbItem Size of data in u32Item parameter, restricted to 1/2/4 bytes.
438 * @param cItems Number of iterations.
439 * @remarks Caller enters the device critical section.
440 */
441typedef DECLCALLBACK(VBOXSTRICTRC) FNIOMMMIONEWFILL(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off,
442 uint32_t u32Item, uint32_t cbItem, uint32_t cItems);
443/** Pointer to a FNIOMMMIONEWFILL(). */
444typedef FNIOMMMIONEWFILL *PFNIOMMMIONEWFILL;
445
446VMMDECL(VBOXSTRICTRC) IOMIOPortRead(PVMCC pVM, PVMCPU pVCpu, RTIOPORT Port, uint32_t *pu32Value, size_t cbValue);
447VMMDECL(VBOXSTRICTRC) IOMIOPortWrite(PVMCC pVM, PVMCPU pVCpu, RTIOPORT Port, uint32_t u32Value, size_t cbValue);
448VMM_INT_DECL(VBOXSTRICTRC) IOMIOPortReadString(PVMCC pVM, PVMCPU pVCpu, RTIOPORT Port, void *pvDst,
449 uint32_t *pcTransfers, unsigned cb);
450VMM_INT_DECL(VBOXSTRICTRC) IOMIOPortWriteString(PVMCC pVM, PVMCPU pVCpu, RTIOPORT uPort, void const *pvSrc,
451 uint32_t *pcTransfers, unsigned cb);
452VMMDECL(VBOXSTRICTRC) IOMMMIORead(PVM pVM, PVMCPU pVCpu, RTGCPHYS GCPhys, uint32_t *pu32Value, size_t cbValue);
453VMMDECL(VBOXSTRICTRC) IOMMMIOWrite(PVM pVM, PVMCPU pVCpu, RTGCPHYS GCPhys, uint32_t u32Value, size_t cbValue);
454VMMDECL(VBOXSTRICTRC) IOMMMIOPhysHandler(PVMCC pVM, PVMCPUCC pVCpu, RTGCUINT uErrorCode, PCPUMCTXCORE pCtxCore, RTGCPHYS GCPhysFault);
455VMMDECL(int) IOMMMIOMapMMIO2Page(PVMCC pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysRemapped, uint64_t fPageFlags);
456VMMDECL(int) IOMMMIOMapMMIOHCPage(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhys, RTHCPHYS HCPhys, uint64_t fPageFlags);
457VMMDECL(int) IOMMMIOResetRegion(PVMCC pVM, RTGCPHYS GCPhys);
458VMMDECL(bool) IOMIsLockWriteOwner(PVM pVM);
459
460/** @name IOM_IOPORT_F_XXX - Flags for IOMR3IoPortCreate() and PDMDevHlpIoPortCreateEx().
461 * @{ */
462/** Pass the absolute I/O port to the callback rather than the relative one. */
463#define IOM_IOPORT_F_ABS RT_BIT_32(0)
464/** Valid flags for IOMR3IoPortCreate(). */
465#define IOM_IOPORT_F_VALID_MASK UINT32_C(0x00000001)
466/** @} */
467
468/** @name IOM_MMIO_F_XXX - Flags for IOMR3MmioCreate() and PDMDevHlpMmioCreateEx().
469 * @{ */
470/** Pass the absolute physical address (GC) to the callback rather than the
471 * relative one. */
472#define IOM_MMIO_F_ABS RT_BIT_32(0)
473/** Valid flags for IOMR3IoPortCreate(). */
474#define IOM_MMIO_F_VALID_MASK UINT32_C(0x00000001)
475/** @} */
476
477#ifdef IN_RING3
478/** @defgroup grp_iom_r3 The IOM Host Context Ring-3 API
479 * @{
480 */
481VMMR3_INT_DECL(int) IOMR3Init(PVM pVM);
482VMMR3_INT_DECL(int) IOMR3InitCompleted(PVM pVM, VMINITCOMPLETED enmWhat);
483VMMR3_INT_DECL(void) IOMR3Reset(PVM pVM);
484VMMR3_INT_DECL(void) IOMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
485VMMR3_INT_DECL(int) IOMR3Term(PVM pVM);
486
487VMMR3_INT_DECL(int) IOMR3IoPortCreate(PVM pVM, PPDMDEVINS pDevIns, RTIOPORT cPorts, uint32_t fFlags, PPDMPCIDEV pPciDev,
488 uint32_t iPciRegion, PFNIOMIOPORTNEWOUT pfnOut, PFNIOMIOPORTNEWIN pfnIn,
489 PFNIOMIOPORTNEWOUTSTRING pfnOutStr, PFNIOMIOPORTNEWINSTRING pfnInStr, RTR3PTR pvUser,
490 const char *pszDesc, PCIOMIOPORTDESC paExtDescs, PIOMIOPORTHANDLE phIoPorts);
491VMMR3_INT_DECL(int) IOMR3IoPortMap(PVM pVM, PPDMDEVINS pDevIns, IOMIOPORTHANDLE hIoPorts, RTIOPORT Port);
492VMMR3_INT_DECL(int) IOMR3IoPortUnmap(PVM pVM, PPDMDEVINS pDevIns, IOMIOPORTHANDLE hIoPorts);
493
494VMMR3_INT_DECL(int) IOMR3MmioCreate(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS cbRegion, uint32_t fFlags, PPDMPCIDEV pPciDev,
495 uint32_t iPciRegion, PFNIOMMMIONEWWRITE pfnWrite, PFNIOMMMIONEWREAD pfnRead,
496 PFNIOMMMIONEWFILL pfnFill, void *pvUser, const char *pszDesc, PIOMMMIOHANDLE phRegion);
497VMMR3_INT_DECL(int) IOMR3MmioMap(PVM pVM, PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion, RTGCPHYS GCPhys);
498VMMR3_INT_DECL(int) IOMR3MmioUnmap(PVM pVM, PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion);
499VMMR3_INT_DECL(int) IOMR3MmioReduce(PVM pVM, PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion, RTGCPHYS cbRegion);
500
501/** @name obsolete
502 * @deprecated
503 * @{ */
504VMMR3_INT_DECL(int) IOMR3IOPortRegisterR3(PVM pVM, PPDMDEVINS pDevIns, RTIOPORT PortStart, RTUINT cPorts, RTHCPTR pvUser,
505 R3PTRTYPE(PFNIOMIOPORTOUT) pfnOutCallback, R3PTRTYPE(PFNIOMIOPORTIN) pfnInCallback,
506 R3PTRTYPE(PFNIOMIOPORTOUTSTRING) pfnOutStringCallback, R3PTRTYPE(PFNIOMIOPORTINSTRING) pfnInStringCallback,
507 const char *pszDesc);
508#if 0
509VMMR3_INT_DECL(int) IOMR3IOPortRegisterRC(PVM pVM, PPDMDEVINS pDevIns, RTIOPORT PortStart, RTUINT cPorts, RTRCPTR pvUser,
510 RCPTRTYPE(PFNIOMIOPORTOUT) pfnOutCallback, RCPTRTYPE(PFNIOMIOPORTIN) pfnInCallback,
511 RCPTRTYPE(PFNIOMIOPORTOUTSTRING) pfnOutStrCallback, RCPTRTYPE(PFNIOMIOPORTINSTRING) pfnInStrCallback,
512 const char *pszDesc);
513#endif
514VMMR3_INT_DECL(int) IOMR3IOPortRegisterR0(PVM pVM, PPDMDEVINS pDevIns, RTIOPORT PortStart, RTUINT cPorts, RTR0PTR pvUser,
515 R0PTRTYPE(PFNIOMIOPORTOUT) pfnOutCallback, R0PTRTYPE(PFNIOMIOPORTIN) pfnInCallback,
516 R0PTRTYPE(PFNIOMIOPORTOUTSTRING) pfnOutStrCallback, R0PTRTYPE(PFNIOMIOPORTINSTRING) pfnInStrCallback,
517 const char *pszDesc);
518VMMR3_INT_DECL(int) IOMR3IOPortDeregister(PVM pVM, PPDMDEVINS pDevIns, RTIOPORT PortStart, RTUINT cPorts);
519
520VMMR3_INT_DECL(int) IOMR3MmioRegisterR3(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTGCPHYS cbRange, RTHCPTR pvUser,
521 R3PTRTYPE(PFNIOMMMIOWRITE) pfnWriteCallback,
522 R3PTRTYPE(PFNIOMMMIOREAD) pfnReadCallback,
523 R3PTRTYPE(PFNIOMMMIOFILL) pfnFillCallback,
524 uint32_t fFlags, const char *pszDesc);
525VMMR3_INT_DECL(int) IOMR3MmioRegisterR0(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTGCPHYS cbRange, RTR0PTR pvUser,
526 R0PTRTYPE(PFNIOMMMIOWRITE) pfnWriteCallback,
527 R0PTRTYPE(PFNIOMMMIOREAD) pfnReadCallback,
528 R0PTRTYPE(PFNIOMMMIOFILL) pfnFillCallback);
529#if 0
530VMMR3_INT_DECL(int) IOMR3MmioRegisterRC(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTGCPHYS cbRange, RTGCPTR pvUser,
531 RCPTRTYPE(PFNIOMMMIOWRITE) pfnWriteCallback,
532 RCPTRTYPE(PFNIOMMMIOREAD) pfnReadCallback,
533 RCPTRTYPE(PFNIOMMMIOFILL) pfnFillCallback);
534#endif
535VMMR3_INT_DECL(int) IOMR3MmioDeregister(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTGCPHYS cbRange);
536VMMR3_INT_DECL(int) IOMR3MmioExPreRegister(PVM pVM, PPDMDEVINS pDevIns, uint32_t iSubDev, uint32_t iRegion, RTGCPHYS cbRange,
537 uint32_t fFlags, const char *pszDesc,
538 RTR3PTR pvUserR3,
539 R3PTRTYPE(PFNIOMMMIOWRITE) pfnWriteCallbackR3,
540 R3PTRTYPE(PFNIOMMMIOREAD) pfnReadCallbackR3,
541 R3PTRTYPE(PFNIOMMMIOFILL) pfnFillCallbackR3,
542 RTR0PTR pvUserR0,
543 R0PTRTYPE(PFNIOMMMIOWRITE) pfnWriteCallbackR0,
544 R0PTRTYPE(PFNIOMMMIOREAD) pfnReadCallbackR0,
545 R0PTRTYPE(PFNIOMMMIOFILL) pfnFillCallbackR0,
546 RTRCPTR pvUserRC,
547 RCPTRTYPE(PFNIOMMMIOWRITE) pfnWriteCallbackRC,
548 RCPTRTYPE(PFNIOMMMIOREAD) pfnReadCallbackRC,
549 RCPTRTYPE(PFNIOMMMIOFILL) pfnFillCallbackRC);
550VMMR3_INT_DECL(int) IOMR3MmioExNotifyMapped(PVM pVM, void *pvUser, RTGCPHYS GCPhys);
551VMMR3_INT_DECL(void) IOMR3MmioExNotifyUnmapped(PVM pVM, void *pvUser, RTGCPHYS GCPhys);
552VMMR3_INT_DECL(void) IOMR3MmioExNotifyDeregistered(PVM pVM, void *pvUser);
553
554/** @} */
555
556VMMR3_INT_DECL(VBOXSTRICTRC) IOMR3ProcessForceFlag(PVM pVM, PVMCPU pVCpu, VBOXSTRICTRC rcStrict);
557
558VMMR3_INT_DECL(void) IOMR3NotifyBreakpointCountChange(PVM pVM, bool fPortIo, bool fMmio);
559VMMR3_INT_DECL(void) IOMR3NotifyDebugEventChange(PVM pVM, DBGFEVENT enmEvent, bool fEnabled);
560
561/** @} */
562#endif /* IN_RING3 */
563
564
565#if defined(IN_RING0) || defined(DOXYGEN_RUNNING)
566/** @defgroup grpm_iom_r0 The IOM Host Context Ring-0 API
567 * @{ */
568VMMR0_INT_DECL(void) IOMR0InitPerVMData(PGVM pGVM);
569VMMR0_INT_DECL(void) IOMR0CleanupVM(PGVM pGVM);
570
571VMMR0_INT_DECL(int) IOMR0IoPortSetUpContext(PGVM pGVM, PPDMDEVINS pDevIns, IOMIOPORTHANDLE hIoPorts,
572 PFNIOMIOPORTNEWOUT pfnOut, PFNIOMIOPORTNEWIN pfnIn,
573 PFNIOMIOPORTNEWOUTSTRING pfnOutStr, PFNIOMIOPORTNEWINSTRING pfnInStr, void *pvUser);
574VMMR0_INT_DECL(int) IOMR0IoPortGrowRegistrationTables(PGVM pGVM, uint64_t cMinEntries);
575VMMR0_INT_DECL(int) IOMR0IoPortGrowStatisticsTable(PGVM pGVM, uint64_t cMinEntries);
576
577VMMR0_INT_DECL(int) IOMR0MmioSetUpContext(PGVM pGVM, PPDMDEVINS pDevIns, IOMMMIOHANDLE hRegion, PFNIOMMMIONEWWRITE pfnWrite,
578 PFNIOMMMIONEWREAD pfnRead, PFNIOMMMIONEWFILL pfnFill, void *pvUser);
579VMMR0_INT_DECL(int) IOMR0MmioGrowRegistrationTables(PGVM pGVM, uint64_t cMinEntries);
580VMMR0_INT_DECL(int) IOMR0MmioGrowStatisticsTable(PGVM pGVM, uint64_t cMinEntries);
581/** @} */
582#endif /* IN_RING0 || DOXYGEN_RUNNING */
583
584/** @} */
585
586RT_C_DECLS_END
587
588#endif /* !VBOX_INCLUDED_vmm_iom_h */
589
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette