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 as published by the Free Software Foundation,
|
---|
12 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
13 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
14 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * If you received this file as part of a commercial VirtualBox
|
---|
17 | * distribution, then only the terms of your commercial VirtualBox
|
---|
18 | * license agreement apply instead of the previous paragraph.
|
---|
19 | */
|
---|
20 |
|
---|
21 | #ifndef __VBox_iom_h__
|
---|
22 | #define __VBox_iom_h__
|
---|
23 |
|
---|
24 |
|
---|
25 | #include <VBox/cdefs.h>
|
---|
26 | #include <VBox/types.h>
|
---|
27 | #include <VBox/cpum.h>
|
---|
28 | #include <VBox/dis.h>
|
---|
29 |
|
---|
30 | __BEGIN_DECLS
|
---|
31 |
|
---|
32 |
|
---|
33 | /** @defgroup grp_iom The Input / Ouput Monitor API
|
---|
34 | * @{
|
---|
35 | */
|
---|
36 |
|
---|
37 | /** @def IOM_NO_PDMINS_CHECKS
|
---|
38 | * Untill all devices have been fully adjusted to PDM style, the pPdmIns parameter
|
---|
39 | * is not checked by IOM.
|
---|
40 | */
|
---|
41 | #define IOM_NO_PDMINS_CHECKS
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * Macro for checking if an I/O or MMIO emulation call succeeded.
|
---|
45 | *
|
---|
46 | * This macro shall only be used with the IOM APIs where it's mentioned
|
---|
47 | * in the return value description. And there is must be used to correctly
|
---|
48 | * determin if the call succeeded and things like the EIP needs updating.
|
---|
49 | *
|
---|
50 | *
|
---|
51 | * @returns Success indicator (true/false).
|
---|
52 | *
|
---|
53 | * @param rc The status code. This may be evaluated
|
---|
54 | * more than once!
|
---|
55 | *
|
---|
56 | * @remark To avoid making assumptions about the layout of the
|
---|
57 | * VINF_EM_FIRST...VINF_EM_LAST range we're checking
|
---|
58 | * explicitly for each for exach the exceptions.
|
---|
59 | * However, for efficieny we ASSUME that the
|
---|
60 | * VINF_EM_LAST is smaller than most of the relevant
|
---|
61 | * status codes. We also ASSUME that the
|
---|
62 | * VINF_EM_RESCHEDULE_REM status code is the most
|
---|
63 | * frequent status code we'll enounter in this range.
|
---|
64 | *
|
---|
65 | * @todo Will have to add VINF_EM_DBG_HYPER_BREAKPOINT if the
|
---|
66 | * I/O port and MMIO breakpoints should trigger before
|
---|
67 | * the I/O is done. Currently, we don't implement these
|
---|
68 | * kind of breakpoints.
|
---|
69 | */
|
---|
70 | #define IOM_SUCCESS(rc) ( (rc) == VINF_SUCCESS \
|
---|
71 | || ( (rc) <= VINF_EM_LAST \
|
---|
72 | && (rc) != VINF_EM_RESCHEDULE_REM \
|
---|
73 | && (rc) >= VINF_EM_FIRST \
|
---|
74 | && (rc) != VINF_EM_RESCHEDULE_RAW \
|
---|
75 | && (rc) != VINF_EM_RESCHEDULE_HWACC \
|
---|
76 | ) \
|
---|
77 | )
|
---|
78 |
|
---|
79 |
|
---|
80 | /**
|
---|
81 | * Port I/O Handler for IN operations.
|
---|
82 | *
|
---|
83 | * @returns VINF_SUCCESS or VINF_EM_*.
|
---|
84 | * @returns VERR_IOM_IOPORT_UNUSED if the port is really unused and a ~0 value should be returned.
|
---|
85 | *
|
---|
86 | * @param pDevIns The device instance.
|
---|
87 | * @param pvUser User argument.
|
---|
88 | * @param uPort Port number used for the IN operation.
|
---|
89 | * @param pu32 Where to store the result.
|
---|
90 | * @param cb Number of bytes read.
|
---|
91 | */
|
---|
92 | typedef DECLCALLBACK(int) FNIOMIOPORTIN(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb);
|
---|
93 | /** Pointer to a FNIOMIOPORTIN(). */
|
---|
94 | typedef FNIOMIOPORTIN *PFNIOMIOPORTIN;
|
---|
95 |
|
---|
96 | /**
|
---|
97 | * Port I/O Handler for string IN operations.
|
---|
98 | *
|
---|
99 | * @returns VINF_SUCCESS or VINF_EM_*.
|
---|
100 | * @returns VERR_IOM_IOPORT_UNUSED if the port is really unused and a ~0 value should be returned.
|
---|
101 | *
|
---|
102 | * @param pDevIns The device instance.
|
---|
103 | * @param pvUser User argument.
|
---|
104 | * @param uPort Port number used for the IN operation.
|
---|
105 | * @param pGCPtrDst Pointer to the destination buffer (GC, incremented appropriately).
|
---|
106 | * @param pcTransfers Pointer to the number of transfer units to read, on return remaining transfer units.
|
---|
107 | * @param cb Size of the transfer unit (1, 2 or 4 bytes).
|
---|
108 | */
|
---|
109 | typedef DECLCALLBACK(int) FNIOMIOPORTINSTRING(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, RTGCPTR *pGCPtrDst, unsigned *pcTransfers, unsigned cb);
|
---|
110 | /** Pointer to a FNIOMIOPORTINSTRING(). */
|
---|
111 | typedef FNIOMIOPORTINSTRING *PFNIOMIOPORTINSTRING;
|
---|
112 |
|
---|
113 | /**
|
---|
114 | * Port I/O Handler for OUT operations.
|
---|
115 | *
|
---|
116 | * @returns VINF_SUCCESS or VINF_EM_*.
|
---|
117 | *
|
---|
118 | * @param pDevIns The device instance.
|
---|
119 | * @param pvUser User argument.
|
---|
120 | * @param uPort Port number used for the OUT operation.
|
---|
121 | * @param u32 The value to output.
|
---|
122 | * @param cb The value size in bytes.
|
---|
123 | */
|
---|
124 | typedef DECLCALLBACK(int) FNIOMIOPORTOUT(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb);
|
---|
125 | /** Pointer to a FNIOMIOPORTOUT(). */
|
---|
126 | typedef FNIOMIOPORTOUT *PFNIOMIOPORTOUT;
|
---|
127 |
|
---|
128 | /**
|
---|
129 | * Port I/O Handler for string OUT operations.
|
---|
130 | *
|
---|
131 | * @returns VINF_SUCCESS or VINF_EM_*.
|
---|
132 | *
|
---|
133 | * @param pDevIns The device instance.
|
---|
134 | * @param pvUser User argument.
|
---|
135 | * @param uPort Port number used for the OUT operation.
|
---|
136 | * @param pGCPtrSrc Pointer to the source buffer (GC, incremented appropriately).
|
---|
137 | * @param pcTransfers Pointer to the number of transfer units to write, on return remaining transfer units.
|
---|
138 | * @param cb Size of the transfer unit (1, 2 or 4 bytes).
|
---|
139 | */
|
---|
140 | typedef DECLCALLBACK(int) FNIOMIOPORTOUTSTRING(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, RTGCPTR *pGCPtrSrc, unsigned *pcTransfers, unsigned cb);
|
---|
141 | /** Pointer to a FNIOMIOPORTOUTSTRING(). */
|
---|
142 | typedef FNIOMIOPORTOUTSTRING *PFNIOMIOPORTOUTSTRING;
|
---|
143 |
|
---|
144 |
|
---|
145 | /**
|
---|
146 | * Memory mapped I/O Handler for read operations.
|
---|
147 | *
|
---|
148 | * @returns VBox status code.
|
---|
149 | *
|
---|
150 | * @param pDevIns The device instance.
|
---|
151 | * @param pvUser User argument.
|
---|
152 | * @param GCPhysAddr Physical address (in GC) where the read starts.
|
---|
153 | * @param pv Where to store the result.
|
---|
154 | * @param cb Number of bytes read.
|
---|
155 | *
|
---|
156 | * @remark wonder if we could merge the IOMMMIO* and IOMPORT* callbacks...
|
---|
157 | */
|
---|
158 | typedef DECLCALLBACK(int) FNIOMMMIOREAD(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb);
|
---|
159 | /** Pointer to a FNIOMMMIOREAD(). */
|
---|
160 | typedef FNIOMMMIOREAD *PFNIOMMMIOREAD;
|
---|
161 |
|
---|
162 | /**
|
---|
163 | * Port I/O Handler for write operations.
|
---|
164 | *
|
---|
165 | * @returns VBox status code.
|
---|
166 | *
|
---|
167 | * @param pDevIns The device instance.
|
---|
168 | * @param pvUser User argument.
|
---|
169 | * @param GCPhysAddr Physical address (in GC) where the read starts.
|
---|
170 | * @param pv Where to fetch the result.
|
---|
171 | * @param cb Number of bytes to write.
|
---|
172 | *
|
---|
173 | * @remark wonder if we could merge the IOMMMIO* and IOMPORT* callbacks...
|
---|
174 | */
|
---|
175 | typedef DECLCALLBACK(int) FNIOMMMIOWRITE(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb);
|
---|
176 | /** Pointer to a FNIOMMMIOWRITE(). */
|
---|
177 | typedef FNIOMMMIOWRITE *PFNIOMMMIOWRITE;
|
---|
178 |
|
---|
179 | /**
|
---|
180 | * Port I/O Handler for memset operations, actually for REP STOS* instructions handling.
|
---|
181 | *
|
---|
182 | * @returns VBox status code.
|
---|
183 | *
|
---|
184 | * @param pDevIns The device instance.
|
---|
185 | * @param pvUser User argument.
|
---|
186 | * @param GCPhysAddr Physical address (in GC) where the write starts.
|
---|
187 | * @param u32Item Byte/Word/Dword data to fill.
|
---|
188 | * @param cbItem Size of data in u32Item parameter, restricted to 1/2/4 bytes.
|
---|
189 | * @param cItems Number of iterations.
|
---|
190 | */
|
---|
191 | typedef DECLCALLBACK(int) FNIOMMMIOFILL(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, uint32_t u32Item, unsigned cbItem, unsigned cItems);
|
---|
192 | /** Pointer to a FNIOMMMIOFILL(). */
|
---|
193 | typedef FNIOMMMIOFILL *PFNIOMMMIOFILL;
|
---|
194 |
|
---|
195 |
|
---|
196 |
|
---|
197 | /**
|
---|
198 | * Registers a Port IO GC handler.
|
---|
199 | *
|
---|
200 | * This API is called by PDM on behalf of a device. Devices must first register HC ranges
|
---|
201 | * using IOMR3IOPortRegisterHC() before calling this function.
|
---|
202 | *
|
---|
203 | *
|
---|
204 | * @returns VBox status code.
|
---|
205 | *
|
---|
206 | * @param pVM VM handle.
|
---|
207 | * @param pDevIns PDM device instance owning the port range.
|
---|
208 | * @param PortStart First port number in the range.
|
---|
209 | * @param cPorts Number of ports to register.
|
---|
210 | * @param pvUser User argument for the callbacks.
|
---|
211 | * @param pfnOutCallback Pointer to function which is gonna handle OUT operations in GC.
|
---|
212 | * @param pfnInCallback Pointer to function which is gonna handle IN operations in GC.
|
---|
213 | * @param pfnOutStrCallback Pointer to function which is gonna handle OUT operations in GC.
|
---|
214 | * @param pfnInStrCallback Pointer to function which is gonna handle IN operations in GC.
|
---|
215 | * @param pszDesc Pointer to description string. This must not be freed.
|
---|
216 | */
|
---|
217 | IOMDECL(int) IOMIOPortRegisterGC(PVM pVM, PPDMDEVINS pDevIns, RTIOPORT PortStart, RTUINT cPorts, RTGCPTR pvUser,
|
---|
218 | GCPTRTYPE(PFNIOMIOPORTOUT) pfnOutCallback, GCPTRTYPE(PFNIOMIOPORTIN) pfnInCallback,
|
---|
219 | GCPTRTYPE(PFNIOMIOPORTOUTSTRING) pfnOutStrCallback, GCPTRTYPE(PFNIOMIOPORTINSTRING) pfnInStrCallback,
|
---|
220 | const char *pszDesc);
|
---|
221 |
|
---|
222 |
|
---|
223 |
|
---|
224 | /**
|
---|
225 | * Registers a Memory Mapped I/O GC handler range.
|
---|
226 | *
|
---|
227 | * This API is called by PDM on behalf of a device. Devices must first register HC ranges
|
---|
228 | * using IOMMR3MIORegisterHC() before calling this function.
|
---|
229 | *
|
---|
230 | *
|
---|
231 | * @returns VBox status code.
|
---|
232 | *
|
---|
233 | * @param pVM VM handle.
|
---|
234 | * @param pDevIns PDM device instance owning the MMIO range.
|
---|
235 | * @param GCPhysStart First physical address in the range.
|
---|
236 | * @param cbRange The size of the range (in bytes).
|
---|
237 | * @param pvUser User argument for the callbacks.
|
---|
238 | * @param pfnWriteCallback Pointer to function which is gonna handle Write operations.
|
---|
239 | * @param pfnReadCallback Pointer to function which is gonna handle Read operations.
|
---|
240 | * @param pfnFillCallback Pointer to function which is gonna handle Fill/memset operations.
|
---|
241 | * @param pszDesc Pointer to description string. This must not be freed.
|
---|
242 | */
|
---|
243 | IOMDECL(int) IOMMMIORegisterGC(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTGCPTR pvUser,
|
---|
244 | GCPTRTYPE(PFNIOMMMIOWRITE) pfnWriteCallback, GCPTRTYPE(PFNIOMMMIOREAD) pfnReadCallback,
|
---|
245 | GCPTRTYPE(PFNIOMMMIOFILL) pfnFillCallback, const char *pszDesc);
|
---|
246 |
|
---|
247 |
|
---|
248 | /**
|
---|
249 | * Registers a Port IO R0 handler.
|
---|
250 | *
|
---|
251 | * This API is called by PDM on behalf of a device. Devices must first register ring-3 ranges
|
---|
252 | * using IOMR3IOPortRegisterR3() before calling this function.
|
---|
253 | *
|
---|
254 | *
|
---|
255 | * @returns VBox status code.
|
---|
256 | *
|
---|
257 | * @param pVM VM handle.
|
---|
258 | * @param pDevIns PDM device instance owning the port range.
|
---|
259 | * @param PortStart First port number in the range.
|
---|
260 | * @param cPorts Number of ports to register.
|
---|
261 | * @param pvUser User argument for the callbacks.
|
---|
262 | * @param pfnOutCallback Pointer to function which is gonna handle OUT operations in GC.
|
---|
263 | * @param pfnInCallback Pointer to function which is gonna handle IN operations in GC.
|
---|
264 | * @param pfnOutStrCallback Pointer to function which is gonna handle OUT operations in GC.
|
---|
265 | * @param pfnInStrCallback Pointer to function which is gonna handle IN operations in GC.
|
---|
266 | * @param pszDesc Pointer to description string. This must not be freed.
|
---|
267 | */
|
---|
268 | IOMDECL(int) IOMIOPortRegisterR0(PVM pVM, PPDMDEVINS pDevIns, RTIOPORT PortStart, RTUINT cPorts, RTR0PTR pvUser,
|
---|
269 | R0PTRTYPE(PFNIOMIOPORTOUT) pfnOutCallback, R0PTRTYPE(PFNIOMIOPORTIN) pfnInCallback,
|
---|
270 | R0PTRTYPE(PFNIOMIOPORTOUTSTRING) pfnOutStrCallback, R0PTRTYPE(PFNIOMIOPORTINSTRING) pfnInStrCallback,
|
---|
271 | const char *pszDesc);
|
---|
272 |
|
---|
273 | /**
|
---|
274 | * Registers a Memory Mapped I/O R0 handler range.
|
---|
275 | *
|
---|
276 | * This API is called by PDM on behalf of a device. Devices must first register ring-3 ranges
|
---|
277 | * using IOMMR3MIORegisterR3() before calling this function.
|
---|
278 | *
|
---|
279 | *
|
---|
280 | * @returns VBox status code.
|
---|
281 | *
|
---|
282 | * @param pVM VM handle.
|
---|
283 | * @param pDevIns PDM device instance owning the MMIO range.
|
---|
284 | * @param GCPhysStart First physical address in the range.
|
---|
285 | * @param cbRange The size of the range (in bytes).
|
---|
286 | * @param pvUser User argument for the callbacks.
|
---|
287 | * @param pfnWriteCallback Pointer to function which is gonna handle Write operations.
|
---|
288 | * @param pfnReadCallback Pointer to function which is gonna handle Read operations.
|
---|
289 | * @param pfnFillCallback Pointer to function which is gonna handle Fill/memset operations.
|
---|
290 | * @param pszDesc Pointer to description string. This must not be freed.
|
---|
291 | */
|
---|
292 | IOMDECL(int) IOMMMIORegisterR0(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTR0PTR pvUser,
|
---|
293 | R0PTRTYPE(PFNIOMMMIOWRITE) pfnWriteCallback, R0PTRTYPE(PFNIOMMMIOREAD) pfnReadCallback,
|
---|
294 | R0PTRTYPE(PFNIOMMMIOFILL) pfnFillCallback, const char *pszDesc);
|
---|
295 |
|
---|
296 |
|
---|
297 | /**
|
---|
298 | * Reads an I/O port register.
|
---|
299 | *
|
---|
300 | * @returns Strict VBox status code. Informational status codes other than the one documented
|
---|
301 | * here are to be treated as internal failure. Use IOM_SUCCESS() to check for success.
|
---|
302 | * @retval VINF_SUCCESS Success.
|
---|
303 | * @retval VINF_EM_FIRST-VINF_EM_LAST Success with some exceptions (see IOM_SUCCESS()), the
|
---|
304 | * status code must be passed on to EM.
|
---|
305 | * @retval VINF_IOM_HC_IOPORT_READ Defer the read to ring-3. (R0/GC only)
|
---|
306 | *
|
---|
307 | * @param pVM VM handle.
|
---|
308 | * @param Port The port to read.
|
---|
309 | * @param pu32Value Where to store the value read.
|
---|
310 | * @param cbValue The size of the register to read in bytes. 1, 2 or 4 bytes.
|
---|
311 | */
|
---|
312 | IOMDECL(int) IOMIOPortRead(PVM pVM, RTIOPORT Port, uint32_t *pu32Value, size_t cbValue);
|
---|
313 |
|
---|
314 | /**
|
---|
315 | * Writes to an I/O port register.
|
---|
316 | *
|
---|
317 | * @returns Strict VBox status code. Informational status codes other than the one documented
|
---|
318 | * here are to be treated as internal failure. Use IOM_SUCCESS() to check for success.
|
---|
319 | * @retval VINF_SUCCESS Success.
|
---|
320 | * @retval VINF_EM_FIRST-VINF_EM_LAST Success with some exceptions (see IOM_SUCCESS()), the
|
---|
321 | * status code must be passed on to EM.
|
---|
322 | * @retval VINF_IOM_HC_IOPORT_WRITE Defer the write to ring-3. (R0/GC only)
|
---|
323 | *
|
---|
324 | * @param pVM VM handle.
|
---|
325 | * @param Port The port to write to.
|
---|
326 | * @param u32Value The value to write.
|
---|
327 | * @param cbValue The size of the register to read in bytes. 1, 2 or 4 bytes.
|
---|
328 | */
|
---|
329 | IOMDECL(int) IOMIOPortWrite(PVM pVM, RTIOPORT Port, uint32_t u32Value, size_t cbValue);
|
---|
330 |
|
---|
331 | /**
|
---|
332 | * OUT <DX|imm16>, <AL|AX|EAX>
|
---|
333 | *
|
---|
334 | * @returns Strict VBox status code. Informational status codes other than the one documented
|
---|
335 | * here are to be treated as internal failure. Use IOM_SUCCESS() to check for success.
|
---|
336 | * @retval VINF_SUCCESS Success.
|
---|
337 | * @retval VINF_EM_FIRST-VINF_EM_LAST Success with some exceptions (see IOM_SUCCESS()), the
|
---|
338 | * status code must be passed on to EM.
|
---|
339 | * @retval VINF_IOM_HC_IOPORT_WRITE Defer the write to ring-3. (R0/GC only)
|
---|
340 | * @retval VINF_EM_RAW_GUEST_TRAP The exception was left pending. (TRPMRaiseXcptErr)
|
---|
341 | * @retval VINF_TRPM_XCPT_DISPATCHED The exception was raised and dispatched for raw-mode execution. (TRPMRaiseXcptErr)
|
---|
342 | * @retval VINF_EM_RESCHEDULE_REM The exception was dispatched and cannot be executed in raw-mode. (TRPMRaiseXcptErr)
|
---|
343 | *
|
---|
344 | * @param pVM The virtual machine (GC pointer ofcourse).
|
---|
345 | * @param pRegFrame Pointer to CPUMCTXCORE guest registers structure.
|
---|
346 | * @param pCpu Disassembler CPU state.
|
---|
347 | */
|
---|
348 | IOMDECL(int) IOMInterpretOUT(PVM pVM, PCPUMCTXCORE pRegFrame, PDISCPUSTATE pCpu);
|
---|
349 |
|
---|
350 | /**
|
---|
351 | * IN <AL|AX|EAX>, <DX|imm16>
|
---|
352 | *
|
---|
353 | * @returns Strict VBox status code. Informational status codes other than the one documented
|
---|
354 | * here are to be treated as internal failure. Use IOM_SUCCESS() to check for success.
|
---|
355 | * @retval VINF_SUCCESS Success.
|
---|
356 | * @retval VINF_EM_FIRST-VINF_EM_LAST Success with some exceptions (see IOM_SUCCESS()), the
|
---|
357 | * status code must be passed on to EM.
|
---|
358 | * @retval VINF_IOM_HC_IOPORT_READ Defer the read to ring-3. (R0/GC only)
|
---|
359 | * @retval VINF_EM_RAW_GUEST_TRAP The exception was left pending. (TRPMRaiseXcptErr)
|
---|
360 | * @retval VINF_TRPM_XCPT_DISPATCHED The exception was raised and dispatched for raw-mode execution. (TRPMRaiseXcptErr)
|
---|
361 | * @retval VINF_EM_RESCHEDULE_REM The exception was dispatched and cannot be executed in raw-mode. (TRPMRaiseXcptErr)
|
---|
362 | *
|
---|
363 | * @param pVM The virtual machine (GC pointer ofcourse).
|
---|
364 | * @param pRegFrame Pointer to CPUMCTXCORE guest registers structure.
|
---|
365 | * @param pCpu Disassembler CPU state.
|
---|
366 | */
|
---|
367 | IOMDECL(int) IOMInterpretIN(PVM pVM, PCPUMCTXCORE pRegFrame, PDISCPUSTATE pCpu);
|
---|
368 |
|
---|
369 |
|
---|
370 | /**
|
---|
371 | * Reads the string buffer of an I/O port register.
|
---|
372 | *
|
---|
373 | * @returns Strict VBox status code. Informational status codes other than the one documented
|
---|
374 | * here are to be treated as internal failure. Use IOM_SUCCESS() to check for success.
|
---|
375 | * @retval VINF_SUCCESS Success.
|
---|
376 | * @retval VINF_EM_FIRST-VINF_EM_LAST Success with some exceptions (see IOM_SUCCESS()), the
|
---|
377 | * status code must be passed on to EM.
|
---|
378 | * @retval VINF_IOM_HC_IOPORT_READ Defer the read to ring-3. (R0/GC only)
|
---|
379 | *
|
---|
380 | * @param pVM VM handle.
|
---|
381 | * @param Port The port to read.
|
---|
382 | * @param pGCPtrDst Pointer to the destination buffer (GC, incremented appropriately).
|
---|
383 | * @param pcTransfers Pointer to the number of transfer units to read, on return remaining transfer units.
|
---|
384 | * @param cb Size of the transfer unit (1, 2 or 4 bytes).
|
---|
385 | */
|
---|
386 | IOMDECL(int) IOMIOPortReadString(PVM pVM, RTIOPORT Port, PRTGCPTR pGCPtrDst, PRTGCUINTREG pcTransfers, unsigned cb);
|
---|
387 |
|
---|
388 | /**
|
---|
389 | * Writes the string buffer of an I/O port register.
|
---|
390 | *
|
---|
391 | * @returns Strict VBox status code. Informational status codes other than the one documented
|
---|
392 | * here are to be treated as internal failure.
|
---|
393 | * @retval VINF_SUCCESS Success.
|
---|
394 | * @retval VINF_EM_FIRST-VINF_EM_LAST Success but schedulinging information needs to be passed onto EM.
|
---|
395 | * @retval VINF_IOM_HC_IOPORT_WRITE Defer the write to ring-3. (R0/GC only)
|
---|
396 | *
|
---|
397 | * @param pVM VM handle.
|
---|
398 | * @param Port The port to write.
|
---|
399 | * @param pGCPtrSrc Pointer to the source buffer (GC, incremented appropriately).
|
---|
400 | * @param pcTransfer Pointer to the number of transfer units to write, on return remaining transfer units.
|
---|
401 | * @param cb Size of the transfer unit (1, 2 or 4 bytes).
|
---|
402 | */
|
---|
403 | IOMDECL(int) IOMIOPortWriteString(PVM pVM, RTIOPORT Port, PRTGCPTR pGCPtrSrc, PRTGCUINTREG pcTransfers, unsigned cb);
|
---|
404 |
|
---|
405 | /**
|
---|
406 | * [REP*] INSB/INSW/INSD
|
---|
407 | * ES:EDI,DX[,ECX]
|
---|
408 | *
|
---|
409 | * @returns Strict VBox status code. Informational status codes other than the one documented
|
---|
410 | * here are to be treated as internal failure. Use IOM_SUCCESS() to check for success.
|
---|
411 | * @retval VINF_SUCCESS Success.
|
---|
412 | * @retval VINF_EM_FIRST-VINF_EM_LAST Success with some exceptions (see IOM_SUCCESS()), the
|
---|
413 | * status code must be passed on to EM.
|
---|
414 | * @retval VINF_IOM_HC_IOPORT_READ Defer the read to ring-3. (R0/GC only)
|
---|
415 | * @retval VINF_EM_RAW_GUEST_TRAP The exception was left pending. (TRPMRaiseXcptErr)
|
---|
416 | * @retval VINF_TRPM_XCPT_DISPATCHED The exception was raised and dispatched for raw-mode execution. (TRPMRaiseXcptErr)
|
---|
417 | * @retval VINF_EM_RESCHEDULE_REM The exception was dispatched and cannot be executed in raw-mode. (TRPMRaiseXcptErr)
|
---|
418 | *
|
---|
419 | * @param pVM The virtual machine (GC pointer ofcourse).
|
---|
420 | * @param pRegFrame Pointer to CPUMCTXCORE guest registers structure.
|
---|
421 | * @param pCpu Disassembler CPU state.
|
---|
422 | */
|
---|
423 | IOMDECL(int) IOMInterpretINS(PVM pVM, PCPUMCTXCORE pRegFrame, PDISCPUSTATE pCpu);
|
---|
424 |
|
---|
425 | /**
|
---|
426 | * [REP*] INSB/INSW/INSD
|
---|
427 | * ES:EDI,DX[,ECX]
|
---|
428 | *
|
---|
429 | * @remark Assumes caller checked the access privileges (IOMInterpretCheckPortIOAccess)
|
---|
430 | *
|
---|
431 | * @returns Strict VBox status code. Informational status codes other than the one documented
|
---|
432 | * here are to be treated as internal failure.
|
---|
433 | * @retval VINF_SUCCESS Success.
|
---|
434 | * @retval VINF_EM_FIRST-VINF_EM_LAST Success but schedulinging information needs to be passed onto EM.
|
---|
435 | * @retval VINF_IOM_HC_IOPORT_READ Defer the read to ring-3. (R0/GC only)
|
---|
436 | * @retval VINF_EM_RAW_GUEST_TRAP The exception was left pending. (TRPMRaiseXcptErr)
|
---|
437 | * @retval VINF_TRPM_XCPT_DISPATCHED The exception was raised and dispatched for raw-mode execution. (TRPMRaiseXcptErr)
|
---|
438 | * @retval VINF_EM_RESCHEDULE_REM The exception was dispatched and cannot be executed in raw-mode. (TRPMRaiseXcptErr)
|
---|
439 | *
|
---|
440 | * @param pVM The virtual machine (GC pointer ofcourse).
|
---|
441 | * @param pRegFrame Pointer to CPUMCTXCORE guest registers structure.
|
---|
442 | * @param uPort IO Port
|
---|
443 | * @param uPrefix IO instruction prefix
|
---|
444 | * @param cbTransfer Size of transfer unit
|
---|
445 | */
|
---|
446 | IOMDECL(int) IOMInterpretINSEx(PVM pVM, PCPUMCTXCORE pRegFrame, uint32_t uPort, uint32_t uPrefix, uint32_t cbTransfer);
|
---|
447 |
|
---|
448 | /**
|
---|
449 | * [REP*] OUTSB/OUTSW/OUTSD
|
---|
450 | * DS:ESI,DX[,ECX]
|
---|
451 | *
|
---|
452 | * @returns Strict VBox status code. Informational status codes other than the one documented
|
---|
453 | * here are to be treated as internal failure. Use IOM_SUCCESS() to check for success.
|
---|
454 | * @retval VINF_SUCCESS Success.
|
---|
455 | * @retval VINF_EM_FIRST-VINF_EM_LAST Success with some exceptions (see IOM_SUCCESS()), the
|
---|
456 | * status code must be passed on to EM.
|
---|
457 | * @retval VINF_IOM_HC_IOPORT_WRITE Defer the write to ring-3. (R0/GC only)
|
---|
458 | * @retval VINF_EM_RAW_GUEST_TRAP The exception was left pending. (TRPMRaiseXcptErr)
|
---|
459 | * @retval VINF_TRPM_XCPT_DISPATCHED The exception was raised and dispatched for raw-mode execution. (TRPMRaiseXcptErr)
|
---|
460 | * @retval VINF_EM_RESCHEDULE_REM The exception was dispatched and cannot be executed in raw-mode. (TRPMRaiseXcptErr)
|
---|
461 | *
|
---|
462 | * @param pVM The virtual machine (GC pointer ofcourse).
|
---|
463 | * @param pRegFrame Pointer to CPUMCTXCORE guest registers structure.
|
---|
464 | * @param pCpu Disassembler CPU state.
|
---|
465 | */
|
---|
466 | IOMDECL(int) IOMInterpretOUTS(PVM pVM, PCPUMCTXCORE pRegFrame, PDISCPUSTATE pCpu);
|
---|
467 |
|
---|
468 | /**
|
---|
469 | * [REP*] OUTSB/OUTSW/OUTSD
|
---|
470 | * DS:ESI,DX[,ECX]
|
---|
471 | *
|
---|
472 | * @remark Assumes caller checked the access privileges (IOMInterpretCheckPortIOAccess)
|
---|
473 | *
|
---|
474 | * @returns Strict VBox status code. Informational status codes other than the one documented
|
---|
475 | * here are to be treated as internal failure. Use IOM_SUCCESS() to check for success.
|
---|
476 | * @retval VINF_SUCCESS Success.
|
---|
477 | * @retval VINF_EM_FIRST-VINF_EM_LAST Success with some exceptions (see IOM_SUCCESS()), the
|
---|
478 | * status code must be passed on to EM.
|
---|
479 | * @retval VINF_IOM_HC_IOPORT_WRITE Defer the write to ring-3. (R0/GC only)
|
---|
480 | * @retval VINF_EM_RAW_GUEST_TRAP The exception was left pending. (TRPMRaiseXcptErr)
|
---|
481 | * @retval VINF_TRPM_XCPT_DISPATCHED The exception was raised and dispatched for raw-mode execution. (TRPMRaiseXcptErr)
|
---|
482 | * @retval VINF_EM_RESCHEDULE_REM The exception was dispatched and cannot be executed in raw-mode. (TRPMRaiseXcptErr)
|
---|
483 | *
|
---|
484 | * @param pVM The virtual machine (GC pointer ofcourse).
|
---|
485 | * @param pRegFrame Pointer to CPUMCTXCORE guest registers structure.
|
---|
486 | * @param uPort IO Port
|
---|
487 | * @param uPrefix IO instruction prefix
|
---|
488 | * @param cbTransfer Size of transfer unit
|
---|
489 | */
|
---|
490 | IOMDECL(int) IOMInterpretOUTSEx(PVM pVM, PCPUMCTXCORE pRegFrame, uint32_t uPort, uint32_t uPrefix, uint32_t cbTransfer);
|
---|
491 |
|
---|
492 | /**
|
---|
493 | * Flushes the IOM port & statistics lookup cache
|
---|
494 | *
|
---|
495 | * @param pVM The VM.
|
---|
496 | */
|
---|
497 | IOMDECL(void) IOMFlushCache(PVM pVM);
|
---|
498 |
|
---|
499 | /**
|
---|
500 | * Reads a MMIO register.
|
---|
501 | *
|
---|
502 | * @returns VBox status code.
|
---|
503 | *
|
---|
504 | * @param pVM VM handle.
|
---|
505 | * @param GCPhys The physical address to read.
|
---|
506 | * @param pu32Value Where to store the value read.
|
---|
507 | * @param cbValue The size of the register to read in bytes. 1, 2 or 4 bytes.
|
---|
508 | */
|
---|
509 | IOMDECL(int) IOMMMIORead(PVM pVM, RTGCPHYS GCPhys, uint32_t *pu32Value, size_t cbValue);
|
---|
510 |
|
---|
511 | /**
|
---|
512 | * Writes to a MMIO register.
|
---|
513 | *
|
---|
514 | * @returns VBox status code.
|
---|
515 | *
|
---|
516 | * @param pVM VM handle.
|
---|
517 | * @param GCPhys The physical address to write to.
|
---|
518 | * @param u32Value The value to write.
|
---|
519 | * @param cbValue The size of the register to read in bytes. 1, 2 or 4 bytes.
|
---|
520 | */
|
---|
521 | IOMDECL(int) IOMMMIOWrite(PVM pVM, RTGCPHYS GCPhys, uint32_t u32Value, size_t cbValue);
|
---|
522 |
|
---|
523 |
|
---|
524 | /**
|
---|
525 | * Checks that the operation is allowed according to the IOPL
|
---|
526 | * level and I/O bitmap.
|
---|
527 | *
|
---|
528 | * @returns Strict VBox status code. Informational status codes other than the one documented
|
---|
529 | * here are to be treated as internal failure.
|
---|
530 | * @retval VINF_SUCCESS Success.
|
---|
531 | * @retval VINF_EM_RAW_GUEST_TRAP The exception was left pending. (TRPMRaiseXcptErr)
|
---|
532 | * @retval VINF_TRPM_XCPT_DISPATCHED The exception was raised and dispatched for raw-mode execution. (TRPMRaiseXcptErr)
|
---|
533 | * @retval VINF_EM_RESCHEDULE_REM The exception was dispatched and cannot be executed in raw-mode. (TRPMRaiseXcptErr)
|
---|
534 | *
|
---|
535 | * @param pVM VM handle.
|
---|
536 | * @param pCtxCore Pointer to register frame.
|
---|
537 | * @param Port The I/O port number.
|
---|
538 | * @param cb The access size.
|
---|
539 | */
|
---|
540 | IOMDECL(int) IOMInterpretCheckPortIOAccess(PVM pVM, PCPUMCTXCORE pCtxCore, RTIOPORT Port, unsigned cb);
|
---|
541 |
|
---|
542 |
|
---|
543 | #ifdef IN_GC
|
---|
544 | /** @defgroup grp_iom_gc The IOM Guest Context API
|
---|
545 | * @ingroup grp_iom
|
---|
546 | * @{
|
---|
547 | */
|
---|
548 |
|
---|
549 | /**
|
---|
550 | * Attempts to service an IN/OUT instruction.
|
---|
551 | *
|
---|
552 | * The \#GP trap handler in GC will call this function if the opcode causing the
|
---|
553 | * trap is a in or out type instruction. (Call it indirectly via EM that is.)
|
---|
554 | *
|
---|
555 | * @returns Strict VBox status code. Informational status codes other than the one documented
|
---|
556 | * here are to be treated as internal failure. Use IOM_SUCCESS() to check for success.
|
---|
557 | * @retval VINF_SUCCESS Success.
|
---|
558 | * @retval VINF_EM_FIRST-VINF_EM_LAST Success with some exceptions (see IOM_SUCCESS()), the
|
---|
559 | * status code must be passed on to EM.
|
---|
560 | * @retval VINF_IOM_HC_IOPORT_READ Defer the read to ring-3. (R0/GC only)
|
---|
561 | * @retval VINF_EM_RAW_GUEST_TRAP The exception was left pending. (TRPMRaiseXcptErr)
|
---|
562 | * @retval VINF_TRPM_XCPT_DISPATCHED The exception was raised and dispatched for raw-mode execution. (TRPMRaiseXcptErr)
|
---|
563 | * @retval VINF_EM_RESCHEDULE_REM The exception was dispatched and cannot be executed in raw-mode. (TRPMRaiseXcptErr)
|
---|
564 | *
|
---|
565 | * @param pVM The virtual machine (GC pointer ofcourse).
|
---|
566 | * @param pRegFrame Pointer to CPUMCTXCORE guest registers structure.
|
---|
567 | * @param pCpu Disassembler CPU state.
|
---|
568 | */
|
---|
569 | IOMGCDECL(int) IOMGCIOPortHandler(PVM pVM, PCPUMCTXCORE pRegFrame, PDISCPUSTATE pCpu);
|
---|
570 |
|
---|
571 | /** @} */
|
---|
572 | #endif
|
---|
573 |
|
---|
574 |
|
---|
575 |
|
---|
576 | #ifdef IN_RING3
|
---|
577 | /** @defgroup grp_iom_r3 The IOM Host Context Ring-3 API
|
---|
578 | * @ingroup grp_iom
|
---|
579 | * @{
|
---|
580 | */
|
---|
581 |
|
---|
582 | /**
|
---|
583 | * Initializes the IOM.
|
---|
584 | *
|
---|
585 | * @returns VBox status code.
|
---|
586 | * @param pVM The VM to operate on.
|
---|
587 | */
|
---|
588 | IOMR3DECL(int) IOMR3Init(PVM pVM);
|
---|
589 |
|
---|
590 | /**
|
---|
591 | * The VM is being reset.
|
---|
592 | *
|
---|
593 | * @param pVM VM handle.
|
---|
594 | */
|
---|
595 | IOMR3DECL(void) IOMR3Reset(PVM pVM);
|
---|
596 |
|
---|
597 | /**
|
---|
598 | * Applies relocations to data and code managed by this
|
---|
599 | * component. This function will be called at init and
|
---|
600 | * whenever the VMM need to relocate it self inside the GC.
|
---|
601 | *
|
---|
602 | * The IOM will update the addresses used by the switcher.
|
---|
603 | *
|
---|
604 | * @param pVM The VM.
|
---|
605 | * @param offDelta Relocation delta relative to old location.
|
---|
606 | */
|
---|
607 | IOMR3DECL(void) IOMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
|
---|
608 |
|
---|
609 | /**
|
---|
610 | * Terminates the IOM.
|
---|
611 | *
|
---|
612 | * Termination means cleaning up and freeing all resources,
|
---|
613 | * the VM it self is at this point powered off or suspended.
|
---|
614 | *
|
---|
615 | * @returns VBox status code.
|
---|
616 | * @param pVM The VM to operate on.
|
---|
617 | */
|
---|
618 | IOMR3DECL(int) IOMR3Term(PVM pVM);
|
---|
619 |
|
---|
620 | /**
|
---|
621 | * Registers a I/O port R3 handler.
|
---|
622 | *
|
---|
623 | * This API is called by PDM on behalf of a device. Devices must first register
|
---|
624 | * ring-3 ranges before any GC and R0 ranges can be registered using IOMIOPortRegisterGC()
|
---|
625 | * and IOMIOPortRegisterR0().
|
---|
626 | *
|
---|
627 | * @returns VBox status code.
|
---|
628 | *
|
---|
629 | * @param pVM VM handle.
|
---|
630 | * @param pDevIns PDM device instance owning the port range.
|
---|
631 | * @param PortStart First port number in the range.
|
---|
632 | * @param cPorts Number of ports to register.
|
---|
633 | * @param pvUser User argument for the callbacks.
|
---|
634 | * @param pfnOutCallback Pointer to function which is gonna handle OUT operations in R3.
|
---|
635 | * @param pfnInCallback Pointer to function which is gonna handle IN operations in R3.
|
---|
636 | * @param pfnOutStringCallback Pointer to function which is gonna handle string OUT operations in R3.
|
---|
637 | * @param pfnInStringCallback Pointer to function which is gonna handle string IN operations in R3.
|
---|
638 | * @param pszDesc Pointer to description string. This must not be freed.
|
---|
639 | */
|
---|
640 | IOMR3DECL(int) IOMR3IOPortRegisterR3(PVM pVM, PPDMDEVINS pDevIns, RTIOPORT PortStart, RTUINT cPorts, RTHCPTR pvUser,
|
---|
641 | HCPTRTYPE(PFNIOMIOPORTOUT) pfnOutCallback, HCPTRTYPE(PFNIOMIOPORTIN) pfnInCallback,
|
---|
642 | HCPTRTYPE(PFNIOMIOPORTOUTSTRING) pfnOutStringCallback, HCPTRTYPE(PFNIOMIOPORTINSTRING) pfnInStringCallback,
|
---|
643 | const char *pszDesc);
|
---|
644 |
|
---|
645 | /**
|
---|
646 | * Registers a Memory Mapped I/O R3 handler.
|
---|
647 | *
|
---|
648 | * This API is called by PDM on behalf of a device. Devices must register ring-3 ranges
|
---|
649 | * before any GC and R0 ranges can be registered using IOMMMIORegisterGC() and IOMMMIORegisterR0().
|
---|
650 | *
|
---|
651 | * @returns VBox status code.
|
---|
652 | *
|
---|
653 | * @param pVM VM handle.
|
---|
654 | * @param pDevIns PDM device instance owning the MMIO range.
|
---|
655 | * @param GCPhysStart First physical address in the range.
|
---|
656 | * @param cbRange The size of the range (in bytes).
|
---|
657 | * @param pvUser User argument for the callbacks.
|
---|
658 | * @param pfnWriteCallback Pointer to function which is gonna handle Write operations.
|
---|
659 | * @param pfnReadCallback Pointer to function which is gonna handle Read operations.
|
---|
660 | * @param pfnFillCallback Pointer to function which is gonna handle Fill/memset operations.
|
---|
661 | * @param pszDesc Pointer to description string. This must not be freed.
|
---|
662 | */
|
---|
663 | IOMR3DECL(int) IOMR3MMIORegisterR3(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange, RTHCPTR pvUser,
|
---|
664 | HCPTRTYPE(PFNIOMMMIOWRITE) pfnWriteCallback, HCPTRTYPE(PFNIOMMMIOREAD) pfnReadCallback,
|
---|
665 | HCPTRTYPE(PFNIOMMMIOFILL) pfnFillCallback, const char *pszDesc);
|
---|
666 |
|
---|
667 |
|
---|
668 |
|
---|
669 | /**
|
---|
670 | * Deregisters a I/O Port range.
|
---|
671 | *
|
---|
672 | * The specified range must be registered using IOMR3IOPortRegister previous to
|
---|
673 | * this call. The range does can be a smaller part of the range specified to
|
---|
674 | * IOMR3IOPortRegister, but it can never be larger.
|
---|
675 | *
|
---|
676 | * This function will remove GC, R0 and R3 context port handlers for this range.
|
---|
677 | *
|
---|
678 | * @returns VBox status code.
|
---|
679 | *
|
---|
680 | * @param pVM The virtual machine.
|
---|
681 | * @param pDevIns The device instance associated with the range.
|
---|
682 | * @param PortStart First port number in the range.
|
---|
683 | * @param cPorts Number of ports to remove starting at PortStart.
|
---|
684 | */
|
---|
685 | IOMR3DECL(int) IOMR3IOPortDeregister(PVM pVM, PPDMDEVINS pDevIns, RTIOPORT PortStart, RTUINT cPorts);
|
---|
686 |
|
---|
687 |
|
---|
688 | /**
|
---|
689 | * Deregisters a Memory Mapped I/O handler range.
|
---|
690 | *
|
---|
691 | * Registered GC, R0, and R3 ranges are affected.
|
---|
692 | *
|
---|
693 | * @returns VBox status code.
|
---|
694 | *
|
---|
695 | * @param pVM The virtual machine.
|
---|
696 | * @param pDevIns Device instance which the MMIO region is registered.
|
---|
697 | * @param GCPhysStart First physical address (GC) in the range.
|
---|
698 | * @param cbRange Number of bytes to deregister.
|
---|
699 | *
|
---|
700 | *
|
---|
701 | * @remark This function mainly for PCI PnP Config and will not do
|
---|
702 | * all the checks you might expect it to do.
|
---|
703 | */
|
---|
704 | IOMR3DECL(int) IOMR3MMIODeregister(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, RTUINT cbRange);
|
---|
705 |
|
---|
706 |
|
---|
707 | /** @} */
|
---|
708 | #endif
|
---|
709 |
|
---|
710 |
|
---|
711 | /** @} */
|
---|
712 |
|
---|
713 | __END_DECLS
|
---|
714 |
|
---|
715 | #endif
|
---|
716 |
|
---|