VirtualBox

source: vbox/trunk/include/VBox/iom.h@ 16214

Last change on this file since 16214 was 13832, checked in by vboxsync, 16 years ago

IN_GC -> IN_RC.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.3 KB
Line 
1/** @file
2 * IOM - Input / Output Monitor.
3 */
4
5/*
6 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
26 * Clara, CA 95054 USA or visit http://www.sun.com if you need
27 * additional information or have any questions.
28 */
29
30#ifndef ___VBox_iom_h
31#define ___VBox_iom_h
32
33#include <VBox/cdefs.h>
34#include <VBox/types.h>
35#include <VBox/dis.h>
36
37__BEGIN_DECLS
38
39
40/** @defgroup grp_iom The Input / Ouput Monitor API
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 is must be used to correctly
56 * determin if the call succeeded and things like the EIP 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 * @remark To avoid making assumptions about the layout of the
65 * VINF_EM_FIRST...VINF_EM_LAST range we're checking
66 * explicitly for each for exach the exceptions.
67 * However, for efficieny we ASSUME that the
68 * VINF_EM_LAST is smaller than most of the relevant
69 * status codes. We also ASSUME that the
70 * VINF_EM_RESCHEDULE_REM status code is the most
71 * frequent status code we'll enounter in this range.
72 *
73 * @todo Will have to add VINF_EM_DBG_HYPER_BREAKPOINT if the
74 * I/O port and MMIO breakpoints should trigger before
75 * the I/O is done. Currently, we don't implement these
76 * kind of breakpoints.
77 */
78#define IOM_SUCCESS(rc) ( (rc) == VINF_SUCCESS \
79 || ( (rc) <= VINF_EM_LAST \
80 && (rc) != VINF_EM_RESCHEDULE_REM \
81 && (rc) >= VINF_EM_FIRST \
82 && (rc) != VINF_EM_RESCHEDULE_RAW \
83 && (rc) != VINF_EM_RESCHEDULE_HWACC \
84 ) \
85 )
86
87
88/**
89 * Port I/O Handler for IN operations.
90 *
91 * @returns VINF_SUCCESS or VINF_EM_*.
92 * @returns VERR_IOM_IOPORT_UNUSED if the port is really unused and a ~0 value should be returned.
93 *
94 * @param pDevIns The device instance.
95 * @param pvUser User argument.
96 * @param uPort Port number used for the IN operation.
97 * @param pu32 Where to store the result.
98 * @param cb Number of bytes read.
99 */
100typedef DECLCALLBACK(int) FNIOMIOPORTIN(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb);
101/** Pointer to a FNIOMIOPORTIN(). */
102typedef FNIOMIOPORTIN *PFNIOMIOPORTIN;
103
104/**
105 * Port I/O Handler for string IN operations.
106 *
107 * @returns VINF_SUCCESS or VINF_EM_*.
108 * @returns VERR_IOM_IOPORT_UNUSED if the port is really unused and a ~0 value should be returned.
109 *
110 * @param pDevIns The device instance.
111 * @param pvUser User argument.
112 * @param uPort Port number used for the IN operation.
113 * @param pGCPtrDst Pointer to the destination buffer (GC, incremented appropriately).
114 * @param pcTransfers Pointer to the number of transfer units to read, on return remaining transfer units.
115 * @param cb Size of the transfer unit (1, 2 or 4 bytes).
116 */
117typedef DECLCALLBACK(int) FNIOMIOPORTINSTRING(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, RTGCPTR *pGCPtrDst, PRTGCUINTREG pcTransfers, unsigned cb);
118/** Pointer to a FNIOMIOPORTINSTRING(). */
119typedef FNIOMIOPORTINSTRING *PFNIOMIOPORTINSTRING;
120
121/**
122 * Port I/O Handler for OUT operations.
123 *
124 * @returns VINF_SUCCESS or VINF_EM_*.
125 *
126 * @param pDevIns The device instance.
127 * @param pvUser User argument.
128 * @param uPort Port number used for the OUT operation.
129 * @param u32 The value to output.
130 * @param cb The value size in bytes.
131 */
132typedef DECLCALLBACK(int) FNIOMIOPORTOUT(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb);
133/** Pointer to a FNIOMIOPORTOUT(). */
134typedef FNIOMIOPORTOUT *PFNIOMIOPORTOUT;
135
136/**
137 * Port I/O Handler for string OUT operations.
138 *
139 * @returns VINF_SUCCESS or VINF_EM_*.
140 *
141 * @param pDevIns The device instance.
142 * @param pvUser User argument.
143 * @param uPort Port number used for the OUT operation.
144 * @param pGCPtrSrc Pointer to the source buffer (GC, incremented appropriately).
145 * @param pcTransfers Pointer to the number of transfer units to write, on return remaining transfer units.
146 * @param cb Size of the transfer unit (1, 2 or 4 bytes).
147 */
148typedef DECLCALLBACK(int) FNIOMIOPORTOUTSTRING(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, RTGCPTR *pGCPtrSrc, PRTGCUINTREG pcTransfers, unsigned cb);
149/** Pointer to a FNIOMIOPORTOUTSTRING(). */
150typedef FNIOMIOPORTOUTSTRING *PFNIOMIOPORTOUTSTRING;
151
152
153/**
154 * Memory mapped I/O Handler for read operations.
155 *
156 * @returns VBox status code.
157 *
158 * @param pDevIns The device instance.
159 * @param pvUser User argument.
160 * @param GCPhysAddr Physical address (in GC) where the read starts.
161 * @param pv Where to store the result.
162 * @param cb Number of bytes read.
163 *
164 * @remark wonder if we could merge the IOMMMIO* and IOMPORT* callbacks...
165 */
166typedef DECLCALLBACK(int) FNIOMMMIOREAD(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb);
167/** Pointer to a FNIOMMMIOREAD(). */
168typedef FNIOMMMIOREAD *PFNIOMMMIOREAD;
169
170/**
171 * Port I/O Handler for write operations.
172 *
173 * @returns VBox status code.
174 *
175 * @param pDevIns The device instance.
176 * @param pvUser User argument.
177 * @param GCPhysAddr Physical address (in GC) where the read starts.
178 * @param pv Where to fetch the result.
179 * @param cb Number of bytes to write.
180 *
181 * @remark wonder if we could merge the IOMMMIO* and IOMPORT* callbacks...
182 */
183typedef DECLCALLBACK(int) FNIOMMMIOWRITE(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb);
184/** Pointer to a FNIOMMMIOWRITE(). */
185typedef FNIOMMMIOWRITE *PFNIOMMMIOWRITE;
186
187/**
188 * Port I/O Handler for memset operations, actually for REP STOS* instructions handling.
189 *
190 * @returns VBox status code.
191 *
192 * @param pDevIns The device instance.
193 * @param pvUser User argument.
194 * @param GCPhysAddr Physical address (in GC) where the write starts.
195 * @param u32Item Byte/Word/Dword data to fill.
196 * @param cbItem Size of data in u32Item parameter, restricted to 1/2/4 bytes.
197 * @param cItems Number of iterations.
198 */
199typedef DECLCALLBACK(int) FNIOMMMIOFILL(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, uint32_t u32Item, unsigned cbItem, unsigned cItems);
200/** Pointer to a FNIOMMMIOFILL(). */
201typedef FNIOMMMIOFILL *PFNIOMMMIOFILL;
202
203VMMDECL(int) IOMIOPortRead(PVM pVM, RTIOPORT Port, uint32_t *pu32Value, size_t cbValue);
204VMMDECL(int) IOMIOPortWrite(PVM pVM, RTIOPORT Port, uint32_t u32Value, size_t cbValue);
205VMMDECL(int) IOMInterpretOUT(PVM pVM, PCPUMCTXCORE pRegFrame, PDISCPUSTATE pCpu);
206VMMDECL(int) IOMInterpretIN(PVM pVM, PCPUMCTXCORE pRegFrame, PDISCPUSTATE pCpu);
207VMMDECL(int) IOMIOPortReadString(PVM pVM, RTIOPORT Port, PRTGCPTR pGCPtrDst, PRTGCUINTREG pcTransfers, unsigned cb);
208VMMDECL(int) IOMIOPortWriteString(PVM pVM, RTIOPORT Port, PRTGCPTR pGCPtrSrc, PRTGCUINTREG pcTransfers, unsigned cb);
209VMMDECL(int) IOMInterpretINS(PVM pVM, PCPUMCTXCORE pRegFrame, PDISCPUSTATE pCpu);
210VMMDECL(int) IOMInterpretINSEx(PVM pVM, PCPUMCTXCORE pRegFrame, uint32_t uPort, uint32_t uPrefix, uint32_t cbTransfer);
211VMMDECL(int) IOMInterpretOUTS(PVM pVM, PCPUMCTXCORE pRegFrame, PDISCPUSTATE pCpu);
212VMMDECL(int) IOMInterpretOUTSEx(PVM pVM, PCPUMCTXCORE pRegFrame, uint32_t uPort, uint32_t uPrefix, uint32_t cbTransfer);
213VMMDECL(int) IOMMMIORead(PVM pVM, RTGCPHYS GCPhys, uint32_t *pu32Value, size_t cbValue);
214VMMDECL(int) IOMMMIOWrite(PVM pVM, RTGCPHYS GCPhys, uint32_t u32Value, size_t cbValue);
215VMMDECL(int) IOMInterpretCheckPortIOAccess(PVM pVM, PCPUMCTXCORE pCtxCore, RTIOPORT Port, unsigned cb);
216VMMDECL(int) IOMMMIOModifyPage(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysRemapped, uint64_t fPageFlags);
217VMMDECL(int) IOMMMIOResetRegion(PVM pVM, RTGCPHYS GCPhys);
218
219#ifdef IN_RC
220/** @defgroup grp_iom_gc The IOM Guest Context API
221 * @ingroup grp_iom
222 * @{
223 */
224VMMRCDECL(int) IOMGCIOPortHandler(PVM pVM, PCPUMCTXCORE pRegFrame, PDISCPUSTATE pCpu);
225/** @} */
226#endif /* IN_RC */
227
228
229
230#ifdef IN_RING3
231/** @defgroup grp_iom_r3 The IOM Host Context Ring-3 API
232 * @ingroup grp_iom
233 * @{
234 */
235VMMR3DECL(int) IOMR3Init(PVM pVM);
236VMMR3DECL(void) IOMR3Reset(PVM pVM);
237VMMR3DECL(void) IOMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
238VMMR3DECL(int) IOMR3Term(PVM pVM);
239VMMR3DECL(int) IOMR3IOPortRegisterR3(PVM pVM, PPDMDEVINS pDevIns, RTIOPORT PortStart, RTUINT cPorts, RTHCPTR pvUser,
240 R3PTRTYPE(PFNIOMIOPORTOUT) pfnOutCallback, R3PTRTYPE(PFNIOMIOPORTIN) pfnInCallback,
241 R3PTRTYPE(PFNIOMIOPORTOUTSTRING) pfnOutStringCallback, R3PTRTYPE(PFNIOMIOPORTINSTRING) pfnInStringCallback,
242 const char *pszDesc);
243VMMR3DECL(int) IOMR3IOPortRegisterRC(PVM pVM, PPDMDEVINS pDevIns, RTIOPORT PortStart, RTUINT cPorts, RTRCPTR pvUser,
244 RCPTRTYPE(PFNIOMIOPORTOUT) pfnOutCallback, RCPTRTYPE(PFNIOMIOPORTIN) pfnInCallback,
245 RCPTRTYPE(PFNIOMIOPORTOUTSTRING) pfnOutStrCallback, RCPTRTYPE(PFNIOMIOPORTINSTRING) pfnInStrCallback,
246 const char *pszDesc);
247VMMR3DECL(int) IOMR3IOPortRegisterR0(PVM pVM, PPDMDEVINS pDevIns, RTIOPORT PortStart, RTUINT cPorts, RTR0PTR pvUser,
248 R0PTRTYPE(PFNIOMIOPORTOUT) pfnOutCallback, R0PTRTYPE(PFNIOMIOPORTIN) pfnInCallback,
249 R0PTRTYPE(PFNIOMIOPORTOUTSTRING) pfnOutStrCallback, R0PTRTYPE(PFNIOMIOPORTINSTRING) pfnInStrCallback,
250 const char *pszDesc);
251VMMR3DECL(int) IOMR3IOPortDeregister(PVM pVM, PPDMDEVINS pDevIns, RTIOPORT PortStart, RTUINT cPorts);
252
253VMMR3DECL(int) IOMR3MMIORegisterR3(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTHCPTR pvUser,
254 R3PTRTYPE(PFNIOMMMIOWRITE) pfnWriteCallback,
255 R3PTRTYPE(PFNIOMMMIOREAD) pfnReadCallback,
256 R3PTRTYPE(PFNIOMMMIOFILL) pfnFillCallback, const char *pszDesc);
257VMMR3DECL(int) IOMR3MMIORegisterR0(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTR0PTR pvUser,
258 R0PTRTYPE(PFNIOMMMIOWRITE) pfnWriteCallback,
259 R0PTRTYPE(PFNIOMMMIOREAD) pfnReadCallback,
260 R0PTRTYPE(PFNIOMMMIOFILL) pfnFillCallback);
261VMMR3DECL(int) IOMR3MMIORegisterRC(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTGCPTR pvUser,
262 RCPTRTYPE(PFNIOMMMIOWRITE) pfnWriteCallback,
263 RCPTRTYPE(PFNIOMMMIOREAD) pfnReadCallback,
264 RCPTRTYPE(PFNIOMMMIOFILL) pfnFillCallback);
265VMMR3DECL(int) IOMR3MMIODeregister(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange);
266/** @} */
267#endif /* IN_RING3 */
268
269
270/** @} */
271
272__END_DECLS
273
274#endif
275
Note: See TracBrowser for help on using the repository browser.

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