VirtualBox

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

Last change on this file since 11261 was 9293, checked in by vboxsync, 17 years ago

Enforce RTRCPTR usage.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.1 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 * Untill all devices have been fully adjusted to PDM style, the pPdmIns parameter
46 * is not checked by IOM.
47 */
48#define IOM_NO_PDMINS_CHECKS
49
50/**
51 * Macro for checking if an I/O or MMIO emulation call succeeded.
52 *
53 * This macro shall only be used with the IOM APIs where it's mentioned
54 * in the return value description. And there is must be used to correctly
55 * determin if the call succeeded and things like the EIP needs updating.
56 *
57 *
58 * @returns Success indicator (true/false).
59 *
60 * @param rc The status code. This may be evaluated
61 * more than once!
62 *
63 * @remark To avoid making assumptions about the layout of the
64 * VINF_EM_FIRST...VINF_EM_LAST range we're checking
65 * explicitly for each for exach the exceptions.
66 * However, for efficieny we ASSUME that the
67 * VINF_EM_LAST is smaller than most of the relevant
68 * status codes. We also ASSUME that the
69 * VINF_EM_RESCHEDULE_REM status code is the most
70 * frequent status code we'll enounter in this range.
71 *
72 * @todo Will have to add VINF_EM_DBG_HYPER_BREAKPOINT if the
73 * I/O port and MMIO breakpoints should trigger before
74 * the I/O is done. Currently, we don't implement these
75 * kind of breakpoints.
76 */
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_HWACC \
83 ) \
84 )
85
86
87/**
88 * Port I/O Handler for IN operations.
89 *
90 * @returns VINF_SUCCESS or VINF_EM_*.
91 * @returns VERR_IOM_IOPORT_UNUSED if the port is really unused and a ~0 value should be returned.
92 *
93 * @param pDevIns The device instance.
94 * @param pvUser User argument.
95 * @param uPort Port number used for the IN operation.
96 * @param pu32 Where to store the result.
97 * @param cb Number of bytes read.
98 */
99typedef DECLCALLBACK(int) FNIOMIOPORTIN(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb);
100/** Pointer to a FNIOMIOPORTIN(). */
101typedef FNIOMIOPORTIN *PFNIOMIOPORTIN;
102
103/**
104 * Port I/O Handler for string IN operations.
105 *
106 * @returns VINF_SUCCESS or VINF_EM_*.
107 * @returns VERR_IOM_IOPORT_UNUSED if the port is really unused and a ~0 value should be returned.
108 *
109 * @param pDevIns The device instance.
110 * @param pvUser User argument.
111 * @param uPort Port number used for the IN operation.
112 * @param pGCPtrDst Pointer to the destination buffer (GC, incremented appropriately).
113 * @param pcTransfers Pointer to the number of transfer units to read, on return remaining transfer units.
114 * @param cb Size of the transfer unit (1, 2 or 4 bytes).
115 */
116typedef DECLCALLBACK(int) FNIOMIOPORTINSTRING(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, RTGCPTR *pGCPtrDst, PRTGCUINTREG pcTransfers, unsigned cb);
117/** Pointer to a FNIOMIOPORTINSTRING(). */
118typedef FNIOMIOPORTINSTRING *PFNIOMIOPORTINSTRING;
119
120/**
121 * Port I/O Handler for OUT operations.
122 *
123 * @returns VINF_SUCCESS or VINF_EM_*.
124 *
125 * @param pDevIns The device instance.
126 * @param pvUser User argument.
127 * @param uPort Port number used for the OUT operation.
128 * @param u32 The value to output.
129 * @param cb The value size in bytes.
130 */
131typedef DECLCALLBACK(int) FNIOMIOPORTOUT(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb);
132/** Pointer to a FNIOMIOPORTOUT(). */
133typedef FNIOMIOPORTOUT *PFNIOMIOPORTOUT;
134
135/**
136 * Port I/O Handler for string OUT operations.
137 *
138 * @returns VINF_SUCCESS or VINF_EM_*.
139 *
140 * @param pDevIns The device instance.
141 * @param pvUser User argument.
142 * @param uPort Port number used for the OUT operation.
143 * @param pGCPtrSrc Pointer to the source buffer (GC, incremented appropriately).
144 * @param pcTransfers Pointer to the number of transfer units to write, on return remaining transfer units.
145 * @param cb Size of the transfer unit (1, 2 or 4 bytes).
146 */
147typedef DECLCALLBACK(int) FNIOMIOPORTOUTSTRING(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, RTGCPTR *pGCPtrSrc, PRTGCUINTREG pcTransfers, unsigned cb);
148/** Pointer to a FNIOMIOPORTOUTSTRING(). */
149typedef FNIOMIOPORTOUTSTRING *PFNIOMIOPORTOUTSTRING;
150
151
152/**
153 * Memory mapped I/O Handler for read operations.
154 *
155 * @returns VBox status code.
156 *
157 * @param pDevIns The device instance.
158 * @param pvUser User argument.
159 * @param GCPhysAddr Physical address (in GC) where the read starts.
160 * @param pv Where to store the result.
161 * @param cb Number of bytes read.
162 *
163 * @remark wonder if we could merge the IOMMMIO* and IOMPORT* callbacks...
164 */
165typedef DECLCALLBACK(int) FNIOMMMIOREAD(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb);
166/** Pointer to a FNIOMMMIOREAD(). */
167typedef FNIOMMMIOREAD *PFNIOMMMIOREAD;
168
169/**
170 * Port I/O Handler for write operations.
171 *
172 * @returns VBox status code.
173 *
174 * @param pDevIns The device instance.
175 * @param pvUser User argument.
176 * @param GCPhysAddr Physical address (in GC) where the read starts.
177 * @param pv Where to fetch the result.
178 * @param cb Number of bytes to write.
179 *
180 * @remark wonder if we could merge the IOMMMIO* and IOMPORT* callbacks...
181 */
182typedef DECLCALLBACK(int) FNIOMMMIOWRITE(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb);
183/** Pointer to a FNIOMMMIOWRITE(). */
184typedef FNIOMMMIOWRITE *PFNIOMMMIOWRITE;
185
186/**
187 * Port I/O Handler for memset operations, actually for REP STOS* instructions handling.
188 *
189 * @returns VBox status code.
190 *
191 * @param pDevIns The device instance.
192 * @param pvUser User argument.
193 * @param GCPhysAddr Physical address (in GC) where the write starts.
194 * @param u32Item Byte/Word/Dword data to fill.
195 * @param cbItem Size of data in u32Item parameter, restricted to 1/2/4 bytes.
196 * @param cItems Number of iterations.
197 */
198typedef DECLCALLBACK(int) FNIOMMMIOFILL(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, uint32_t u32Item, unsigned cbItem, unsigned cItems);
199/** Pointer to a FNIOMMMIOFILL(). */
200typedef FNIOMMMIOFILL *PFNIOMMMIOFILL;
201
202IOMDECL(int) IOMIOPortRead(PVM pVM, RTIOPORT Port, uint32_t *pu32Value, size_t cbValue);
203IOMDECL(int) IOMIOPortWrite(PVM pVM, RTIOPORT Port, uint32_t u32Value, size_t cbValue);
204IOMDECL(int) IOMInterpretOUT(PVM pVM, PCPUMCTXCORE pRegFrame, PDISCPUSTATE pCpu);
205IOMDECL(int) IOMInterpretIN(PVM pVM, PCPUMCTXCORE pRegFrame, PDISCPUSTATE pCpu);
206IOMDECL(int) IOMIOPortReadString(PVM pVM, RTIOPORT Port, PRTGCPTR pGCPtrDst, PRTGCUINTREG pcTransfers, unsigned cb);
207IOMDECL(int) IOMIOPortWriteString(PVM pVM, RTIOPORT Port, PRTGCPTR pGCPtrSrc, PRTGCUINTREG pcTransfers, unsigned cb);
208IOMDECL(int) IOMInterpretINS(PVM pVM, PCPUMCTXCORE pRegFrame, PDISCPUSTATE pCpu);
209IOMDECL(int) IOMInterpretINSEx(PVM pVM, PCPUMCTXCORE pRegFrame, uint32_t uPort, uint32_t uPrefix, uint32_t cbTransfer);
210IOMDECL(int) IOMInterpretOUTS(PVM pVM, PCPUMCTXCORE pRegFrame, PDISCPUSTATE pCpu);
211IOMDECL(int) IOMInterpretOUTSEx(PVM pVM, PCPUMCTXCORE pRegFrame, uint32_t uPort, uint32_t uPrefix, uint32_t cbTransfer);
212IOMDECL(int) IOMMMIORead(PVM pVM, RTGCPHYS GCPhys, uint32_t *pu32Value, size_t cbValue);
213IOMDECL(int) IOMMMIOWrite(PVM pVM, RTGCPHYS GCPhys, uint32_t u32Value, size_t cbValue);
214IOMDECL(int) IOMInterpretCheckPortIOAccess(PVM pVM, PCPUMCTXCORE pCtxCore, RTIOPORT Port, unsigned cb);
215
216
217#ifdef IN_GC
218/** @defgroup grp_iom_gc The IOM Guest Context API
219 * @ingroup grp_iom
220 * @{
221 */
222IOMGCDECL(int) IOMGCIOPortHandler(PVM pVM, PCPUMCTXCORE pRegFrame, PDISCPUSTATE pCpu);
223/** @} */
224#endif /* IN_GC */
225
226
227
228#ifdef IN_RING3
229/** @defgroup grp_iom_r3 The IOM Host Context Ring-3 API
230 * @ingroup grp_iom
231 * @{
232 */
233IOMR3DECL(int) IOMR3Init(PVM pVM);
234IOMR3DECL(void) IOMR3Reset(PVM pVM);
235IOMR3DECL(void) IOMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
236IOMR3DECL(int) IOMR3Term(PVM pVM);
237IOMR3DECL(int) IOMR3IOPortRegisterR3(PVM pVM, PPDMDEVINS pDevIns, RTIOPORT PortStart, RTUINT cPorts, RTHCPTR pvUser,
238 R3PTRTYPE(PFNIOMIOPORTOUT) pfnOutCallback, R3PTRTYPE(PFNIOMIOPORTIN) pfnInCallback,
239 R3PTRTYPE(PFNIOMIOPORTOUTSTRING) pfnOutStringCallback, R3PTRTYPE(PFNIOMIOPORTINSTRING) pfnInStringCallback,
240 const char *pszDesc);
241IOMR3DECL(int) IOMR3IOPortRegisterGC(PVM pVM, PPDMDEVINS pDevIns, RTIOPORT PortStart, RTUINT cPorts, RTRCPTR pvUser,
242 RCPTRTYPE(PFNIOMIOPORTOUT) pfnOutCallback, RCPTRTYPE(PFNIOMIOPORTIN) pfnInCallback,
243 RCPTRTYPE(PFNIOMIOPORTOUTSTRING) pfnOutStrCallback, RCPTRTYPE(PFNIOMIOPORTINSTRING) pfnInStrCallback,
244 const char *pszDesc);
245IOMR3DECL(int) IOMR3IOPortRegisterR0(PVM pVM, PPDMDEVINS pDevIns, RTIOPORT PortStart, RTUINT cPorts, RTR0PTR pvUser,
246 R0PTRTYPE(PFNIOMIOPORTOUT) pfnOutCallback, R0PTRTYPE(PFNIOMIOPORTIN) pfnInCallback,
247 R0PTRTYPE(PFNIOMIOPORTOUTSTRING) pfnOutStrCallback, R0PTRTYPE(PFNIOMIOPORTINSTRING) pfnInStrCallback,
248 const char *pszDesc);
249IOMR3DECL(int) IOMR3IOPortDeregister(PVM pVM, PPDMDEVINS pDevIns, RTIOPORT PortStart, RTUINT cPorts);
250
251IOMR3DECL(int) IOMR3MMIORegisterR3(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTHCPTR pvUser,
252 R3PTRTYPE(PFNIOMMMIOWRITE) pfnWriteCallback,
253 R3PTRTYPE(PFNIOMMMIOREAD) pfnReadCallback,
254 R3PTRTYPE(PFNIOMMMIOFILL) pfnFillCallback, const char *pszDesc);
255IOMR3DECL(int) IOMR3MMIORegisterR0(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTR0PTR pvUser,
256 R0PTRTYPE(PFNIOMMMIOWRITE) pfnWriteCallback,
257 R0PTRTYPE(PFNIOMMMIOREAD) pfnReadCallback,
258 R0PTRTYPE(PFNIOMMMIOFILL) pfnFillCallback);
259IOMR3DECL(int) IOMR3MMIORegisterGC(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTGCPTR pvUser,
260 RCPTRTYPE(PFNIOMMMIOWRITE) pfnWriteCallback,
261 RCPTRTYPE(PFNIOMMMIOREAD) pfnReadCallback,
262 RCPTRTYPE(PFNIOMMMIOFILL) pfnFillCallback);
263IOMR3DECL(int) IOMR3MMIODeregister(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange);
264/** @} */
265#endif /* IN_RING3 */
266
267
268/** @} */
269
270__END_DECLS
271
272#endif
273
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