VirtualBox

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

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

stripped duplicate doxygen docs.

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