1 | /** @file
|
---|
2 | * PDM - Pluggable Device Manager, Async I/O Completion.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2007 innotek GmbH
|
---|
7 | *
|
---|
8 | * innotek GmbH confidential
|
---|
9 | * All rights reserved
|
---|
10 | */
|
---|
11 |
|
---|
12 | #ifndef ___VBox_pdmasynccompletion_h
|
---|
13 | #define ___VBox_pdmasynccompletion_h
|
---|
14 |
|
---|
15 | #include <VBox/types.h>
|
---|
16 |
|
---|
17 | __BEGIN_DECLS
|
---|
18 |
|
---|
19 | /** @defgroup grp_pdm_async_completion Async I/O Completion
|
---|
20 | * @ingroup grp_pdm
|
---|
21 | * @{
|
---|
22 | */
|
---|
23 |
|
---|
24 | /** Pointer to a PDM async completion template handle. */
|
---|
25 | typedef struct PDMASYNCCOMPLETIONTEMPLATE *PPDMASYNCCOMPLETIONTEMPLATE;
|
---|
26 | /** Pointer to a PDM async completion template handle pointer. */
|
---|
27 | typedef PPDMASYNCCOMPLETIONTEMPLATE *PPPDMASYNCCOMPLETIONTEMPLATE;
|
---|
28 |
|
---|
29 | /** Pointer to a PDM async completion task handle. */
|
---|
30 | typedef struct PDMASYNCCOMPLETION *PPDMASYNCCOMPLETION;
|
---|
31 | /** Pointer to a PDM async completion task handle pointer. */
|
---|
32 | typedef PPDMASYNCCOMPLETION *PPPDMASYNCCOMPLETION;
|
---|
33 |
|
---|
34 |
|
---|
35 | /**
|
---|
36 | * Completion callback for devices.
|
---|
37 | *
|
---|
38 | * @param pDevIns The device instance.
|
---|
39 | * @param pTask Pointer to the completion task.
|
---|
40 | * The task is at the time of the call setup to be resumed. So, the callback must
|
---|
41 | * call PDMR3AsyncCompletionSuspend or PDMR3AsyncCompletionDestroy if any other
|
---|
42 | * action is wanted upon return.
|
---|
43 | * @param pvCtx Pointer to any additional, OS specific, completion context. TBD.
|
---|
44 | * @param pvUser User argument.
|
---|
45 | */
|
---|
46 | typedef DECLCALLBACK(void) FNPDMASYNCCOMPLETEDEV(PPDMDEVINS pDevIns, PPDMASYNCCOMPLETION pTask, void *pvCtx, void *pvUser);
|
---|
47 | /** Pointer to a FNPDMASYNCCOMPLETEDEV(). */
|
---|
48 | typedef FNPDMASYNCCOMPLETEDEV *PFNPDMASYNCCOMPLETEDEV;
|
---|
49 |
|
---|
50 |
|
---|
51 | /**
|
---|
52 | * Completion callback for drivers.
|
---|
53 | *
|
---|
54 | * @param pDrvIns The driver instance.
|
---|
55 | * @param pTask Pointer to the completion task.
|
---|
56 | * The task is at the time of the call setup to be resumed. So, the callback must
|
---|
57 | * call PDMR3AsyncCompletionSuspend or PDMR3AsyncCompletionDestroy if any other
|
---|
58 | * action is wanted upon return.
|
---|
59 | * @param pvCtx Pointer to any additional, OS specific, completion context. TBD.
|
---|
60 | * @param pvUser User argument.
|
---|
61 | */
|
---|
62 | typedef DECLCALLBACK(void) FNPDMASYNCCOMPLETEDRV(PPDMDRVINS pDrvIns, PPDMASYNCCOMPLETION pTask, void *pvCtx, void *pvUser);
|
---|
63 | /** Pointer to a FNPDMASYNCCOMPLETEDRV(). */
|
---|
64 | typedef FNPDMASYNCCOMPLETEDRV *PFNPDMASYNCCOMPLETEDRV;
|
---|
65 |
|
---|
66 |
|
---|
67 | /**
|
---|
68 | * Completion callback for USB devices.
|
---|
69 | *
|
---|
70 | * @param pUsbIns The USB device instance.
|
---|
71 | * @param pTask Pointer to the completion task.
|
---|
72 | * The task is at the time of the call setup to be resumed. So, the callback must
|
---|
73 | * call PDMR3AsyncCompletionSuspend or PDMR3AsyncCompletionDestroy if any other
|
---|
74 | * action is wanted upon return.
|
---|
75 | * @param pvCtx Pointer to any additional, OS specific, completion context. TBD.
|
---|
76 | * @param pvUser User argument.
|
---|
77 | */
|
---|
78 | typedef DECLCALLBACK(void) FNPDMASYNCCOMPLETEUSB(PPDMUSBINS pUsbIns, PPDMASYNCCOMPLETION pTask, void *pvCtx, void *pvUser);
|
---|
79 | /** Pointer to a FNPDMASYNCCOMPLETEUSB(). */
|
---|
80 | typedef FNPDMASYNCCOMPLETEUSB *PFNPDMASYNCCOMPLETEUSB;
|
---|
81 |
|
---|
82 |
|
---|
83 | /**
|
---|
84 | * Completion callback for internal.
|
---|
85 | *
|
---|
86 | * @param pVM Pointer to the shared VM structure.
|
---|
87 | * @param pTask Pointer to the completion task.
|
---|
88 | * The task is at the time of the call setup to be resumed. So, the callback must
|
---|
89 | * call PDMR3AsyncCompletionSuspend or PDMR3AsyncCompletionDestroy if any other
|
---|
90 | * action is wanted upon return.
|
---|
91 | * @param pvCtx Pointer to any additional, OS specific, completion context. TBD.
|
---|
92 | * @param pvUser User argument for the task.
|
---|
93 | * @param pvUser2 User argument for the template.
|
---|
94 | */
|
---|
95 | typedef DECLCALLBACK(void) FNPDMASYNCCOMPLETEINT(PVM pVM, PPDMASYNCCOMPLETION pTask, void *pvCtx, void *pvUser, void *pvUser2);
|
---|
96 | /** Pointer to a FNPDMASYNCCOMPLETEINT(). */
|
---|
97 | typedef FNPDMASYNCCOMPLETEINT *PFNPDMASYNCCOMPLETEINT;
|
---|
98 |
|
---|
99 |
|
---|
100 | /**
|
---|
101 | * Creates a async completion template for a device instance.
|
---|
102 | *
|
---|
103 | * The template is used when creating new completion tasks.
|
---|
104 | *
|
---|
105 | * @returns VBox status code.
|
---|
106 | * @param pVM Pointer to the shared VM structure.
|
---|
107 | * @param pDevIns The device instance.
|
---|
108 | * @param ppTemplate Where to store the template pointer on success.
|
---|
109 | * @param pfnCompleted The completion callback routine.
|
---|
110 | * @param pszDesc Description.
|
---|
111 | */
|
---|
112 | PDMR3DECL(int) PDMR3AsyncCompletionTemplateCreateDevice(PVM pVM, PPDMDEVINS pDevIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate, PFNPDMASYNCCOMPLETEDEV pfnCompleted, const char *pszDesc);
|
---|
113 |
|
---|
114 | /**
|
---|
115 | * Creates a async completion template for a driver instance.
|
---|
116 | *
|
---|
117 | * The template is used when creating new completion tasks.
|
---|
118 | *
|
---|
119 | * @returns VBox status code.
|
---|
120 | * @param pVM Pointer to the shared VM structure.
|
---|
121 | * @param pDrvIns The driver instance.
|
---|
122 | * @param ppTemplate Where to store the template pointer on success.
|
---|
123 | * @param pfnCompleted The completion callback routine.
|
---|
124 | * @param pszDesc Description.
|
---|
125 | */
|
---|
126 | PDMR3DECL(int) PDMR3AsyncCompletionTemplateCreateDriver(PVM pVM, PPDMDRVINS pDrvIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate, PFNPDMASYNCCOMPLETEDRV pfnCompleted, const char *pszDesc);
|
---|
127 |
|
---|
128 | /**
|
---|
129 | * Creates a async completion template for a USB device instance.
|
---|
130 | *
|
---|
131 | * The template is used when creating new completion tasks.
|
---|
132 | *
|
---|
133 | * @returns VBox status code.
|
---|
134 | * @param pVM Pointer to the shared VM structure.
|
---|
135 | * @param pUsbIns The USB device instance.
|
---|
136 | * @param ppTemplate Where to store the template pointer on success.
|
---|
137 | * @param pfnCompleted The completion callback routine.
|
---|
138 | * @param pszDesc Description.
|
---|
139 | */
|
---|
140 | PDMR3DECL(int) PDMR3AsyncCompletionTemplateCreateUsb(PVM pVM, PPDMUSBINS pUsbIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate, PFNPDMASYNCCOMPLETEUSB pfnCompleted, const char *pszDesc);
|
---|
141 |
|
---|
142 | /**
|
---|
143 | * Creates a async completion template for internally by the VMM.
|
---|
144 | *
|
---|
145 | * The template is used when creating new completion tasks.
|
---|
146 | *
|
---|
147 | * @returns VBox status code.
|
---|
148 | * @param pVM Pointer to the shared VM structure.
|
---|
149 | * @param ppTemplate Where to store the template pointer on success.
|
---|
150 | * @param pfnCompleted The completion callback routine.
|
---|
151 | * @param pvUser2 The 2nd user argument for the callback.
|
---|
152 | * @param pszDesc Description.
|
---|
153 | */
|
---|
154 | PDMR3DECL(int) PDMR3AsyncCompletionTemplateCreateInternal(PVM pVM, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate, PFNPDMASYNCCOMPLETEINT pfnCompleted, void *pvUser2, const char *pszDesc);
|
---|
155 |
|
---|
156 | /**
|
---|
157 | * Destroys the specified async completion template.
|
---|
158 | *
|
---|
159 | * @returns VBox status codes:
|
---|
160 | * @retval VINF_SUCCESS on success.
|
---|
161 | * @retval VERR_PDM_ASYNC_TEMPLATE_BUSY if the template is still in use.
|
---|
162 | *
|
---|
163 | * @param pTemplate The template in question.
|
---|
164 | */
|
---|
165 | PDMR3DECL(int) PDMR3AsyncCompletionTemplateDestroy(PPDMASYNCCOMPLETIONTEMPLATE pTemplate);
|
---|
166 |
|
---|
167 | /**
|
---|
168 | * Destroys all the specified async completion templates for the given device instance.
|
---|
169 | *
|
---|
170 | * @returns VBox status codes:
|
---|
171 | * @retval VINF_SUCCESS on success.
|
---|
172 | * @retval VERR_PDM_ASYNC_TEMPLATE_BUSY if one or more of the templates are still in use.
|
---|
173 | *
|
---|
174 | * @param pVM Pointer to the shared VM structure.
|
---|
175 | * @param pDevIns The device instance.
|
---|
176 | */
|
---|
177 | PDMR3DECL(int) PDMR3AsyncCompletionTemplateDestroyDevice(PVM pVM, PPDMDEVINS pDevIns);
|
---|
178 |
|
---|
179 | /**
|
---|
180 | * Destroys all the specified async completion templates for the given driver instance.
|
---|
181 | *
|
---|
182 | * @returns VBox status codes:
|
---|
183 | * @retval VINF_SUCCESS on success.
|
---|
184 | * @retval VERR_PDM_ASYNC_TEMPLATE_BUSY if one or more of the templates are still in use.
|
---|
185 | *
|
---|
186 | * @param pVM Pointer to the shared VM structure.
|
---|
187 | * @param pDrvIns The driver instance.
|
---|
188 | */
|
---|
189 | PDMR3DECL(int) PDMR3AsyncCompletionTemplateDestroyDriver(PVM pVM, PPDMDRVINS pDrvIns);
|
---|
190 |
|
---|
191 | /**
|
---|
192 | * Destroys all the specified async completion templates for the given USB device instance.
|
---|
193 | *
|
---|
194 | * @returns VBox status codes:
|
---|
195 | * @retval VINF_SUCCESS on success.
|
---|
196 | * @retval VERR_PDM_ASYNC_TEMPLATE_BUSY if one or more of the templates are still in use.
|
---|
197 | *
|
---|
198 | * @param pVM Pointer to the shared VM structure.
|
---|
199 | * @param pUsbIns The USB device instance.
|
---|
200 | */
|
---|
201 | PDMR3DECL(int) PDMR3AsyncCompletionTemplateDestroyUsb(PVM pVM, PPDMUSBINS pUsbIns);
|
---|
202 |
|
---|
203 |
|
---|
204 | /**
|
---|
205 | * Socket completion context (pvCtx).
|
---|
206 | */
|
---|
207 | typedef struct PDMASYNCCOMPLETIONSOCKET
|
---|
208 | {
|
---|
209 | /** The socket. */
|
---|
210 | RTSOCKET Socket;
|
---|
211 | /** Readable. */
|
---|
212 | bool fReadable;
|
---|
213 | /** Writable. */
|
---|
214 | bool fWriteable;
|
---|
215 | /** Exceptions. */
|
---|
216 | bool fXcpt;
|
---|
217 | } PDMASYNCCOMPLETIONSOCKET;
|
---|
218 | /** Pointer to a socket completion context. */
|
---|
219 | typedef PDMASYNCCOMPLETIONSOCKET *PPDMASYNCCOMPLETIONSOCKET;
|
---|
220 |
|
---|
221 |
|
---|
222 | /**
|
---|
223 | * Creates a completion task for a socket.
|
---|
224 | *
|
---|
225 | * The pvCtx callback argument will be pointing to a PDMASYNCCOMPLETIONSOCKET structure.
|
---|
226 | *
|
---|
227 | * @returns VBox status code.
|
---|
228 | * @param ppTask Where to store the task handle on success.
|
---|
229 | * @param pTemplate The async completion template.
|
---|
230 | * @param Socket The socket.
|
---|
231 | * @param fReadable Whether to callback when the socket becomes readable.
|
---|
232 | * @param fWriteable Whether to callback when the socket becomes writable.
|
---|
233 | * @param fXcpt Whether to callback on exception.
|
---|
234 | * @param pvUser The user argument for the callback.
|
---|
235 | */
|
---|
236 | PDMR3DECL(int) PDMR3AsyncCompletionCreateSocket(PPPDMASYNCCOMPLETION ppTask, PPDMASYNCCOMPLETIONTEMPLATE pTemplate, RTSOCKET Socket, bool fReadable, bool fWriteable, bool fXcpt, void *pvUser);
|
---|
237 |
|
---|
238 | /**
|
---|
239 | * Modifies a socket completion task.
|
---|
240 | *
|
---|
241 | * @returns VBox status code.
|
---|
242 | * @retval VINF_SUCCESS on success.
|
---|
243 | * @retval VERR_NOT_SUPPORTED if the task isn't a socket task.
|
---|
244 | * @param pTemplate The async completion template.
|
---|
245 | * @param fReadable Whether to callback when the socket becomes readable.
|
---|
246 | * @param fWriteable Whether to callback when the socket becomes writable.
|
---|
247 | * @param fXcpt Whether to callback on exception.
|
---|
248 | */
|
---|
249 | PDMR3DECL(int) PDMR3AsyncCompletionModifySocket(PPDMASYNCCOMPLETION pTask, bool fReadable, bool fWriteable, bool fXcpt);
|
---|
250 |
|
---|
251 |
|
---|
252 | #if defined(RT_OS_LINUX) && defined(_AIO_H)
|
---|
253 | /**
|
---|
254 | * Creates a completion task for an AIO operation on Linux.
|
---|
255 | *
|
---|
256 | * The pvCtx callback argument will be pAioCB.
|
---|
257 | *
|
---|
258 | * @returns VBox status code.
|
---|
259 | * @param ppTask Where to store the task handle on success.
|
---|
260 | * @param pTemplate The async completion template.
|
---|
261 | * @param pAioCB The asynchronous I/O control block to wait for.
|
---|
262 | * @param pvUser The user argument for the callback.
|
---|
263 | */
|
---|
264 | PDMR3DECL(int) PDMR3AsyncCompletionCreateLnxAIO(PPPDMASYNCCOMPLETION ppTask, PPDMASYNCCOMPLETIONTEMPLATE pTemplate, const struct aiocb *pAioCB, void *pvUser);
|
---|
265 | #endif /* RT_OS_LINUX */
|
---|
266 |
|
---|
267 | #ifdef RT_OS_OS2
|
---|
268 | /**
|
---|
269 | * Creates a completion task for an event semaphore on OS/2.
|
---|
270 | *
|
---|
271 | * The pvCtx callback argument will be hev.
|
---|
272 | *
|
---|
273 | * @returns VBox status code.
|
---|
274 | * @param ppTask Where to store the task handle on success.
|
---|
275 | * @param pTemplate The async completion template.
|
---|
276 | * @param hev The handle of the event semaphore to wait on.
|
---|
277 | * @param pvUser The user argument for the callback.
|
---|
278 | */
|
---|
279 | PDMR3DECL(int) PDMR3AsyncCompletionCreateOs2Event(PPPDMASYNCCOMPLETION ppTask, PPDMASYNCCOMPLETIONTEMPLATE pTemplate, unsigned long hev, void *pvUser);
|
---|
280 | #endif /* RT_OS_OS2 */
|
---|
281 |
|
---|
282 | #ifdef RT_OS_WINDOWS
|
---|
283 | /**
|
---|
284 | * Creates a completion task for an object on Windows.
|
---|
285 | *
|
---|
286 | * The pvCtx callback argument will be hObject.
|
---|
287 | *
|
---|
288 | * @returns VBox status code.
|
---|
289 | * @param ppTask Where to store the task handle on success.
|
---|
290 | * @param pTemplate The async completion template.
|
---|
291 | * @param hObject The object to wait for.
|
---|
292 | * @param pvUser The user argument for the callback.
|
---|
293 | */
|
---|
294 | PDMR3DECL(int) PDMR3AsyncCompletionCreateWinObject(PPPDMASYNCCOMPLETION ppTask, PPDMASYNCCOMPLETIONTEMPLATE pTemplate, void *hObject, void *pvUser);
|
---|
295 | #endif /* RT_OS_WINDOWS */
|
---|
296 |
|
---|
297 |
|
---|
298 |
|
---|
299 | /**
|
---|
300 | * Sets the user argument of a completion task.
|
---|
301 | *
|
---|
302 | * @returns VBox status code.
|
---|
303 | * @param pTask The async completion task.
|
---|
304 | * @param pvUser The user argument for the callback.
|
---|
305 | */
|
---|
306 | PDMR3DECL(int) PDMR3AsyncCompletionSetUserArg(PPDMASYNCCOMPLETION pTask, void *pvUser);
|
---|
307 |
|
---|
308 | /**
|
---|
309 | * Suspends a async completion task.
|
---|
310 | *
|
---|
311 | * @returns VBox status codes:
|
---|
312 | * @retval VINF_SUCCESS on success.
|
---|
313 | * @retval VERR_PDM_ASYNC_COMPLETION_ALREADY_SUSPENDED if already suspended.
|
---|
314 | * @retval VERR_INVALID_HANDLE if pTask is invalid (asserts).
|
---|
315 | * @param pTask The async completion task.
|
---|
316 | */
|
---|
317 | PDMR3DECL(int) PDMR3AsyncCompletionSuspend(PPDMASYNCCOMPLETION pTask);
|
---|
318 |
|
---|
319 | /**
|
---|
320 | * Suspends a async completion task.
|
---|
321 | *
|
---|
322 | * @returns VBox status codes:
|
---|
323 | * @retval VINF_SUCCESS on success.
|
---|
324 | * @retval VERR_PDM_ASYNC_COMPLETION_NOT_SUSPENDED if not suspended.
|
---|
325 | * @retval VERR_INVALID_HANDLE if pTask is invalid (asserts).
|
---|
326 | * @param pTask The async completion task.
|
---|
327 | */
|
---|
328 | PDMR3DECL(int) PDMR3AsyncCompletionResume(PPDMASYNCCOMPLETION pTask);
|
---|
329 |
|
---|
330 | /**
|
---|
331 | * Destroys a async completion task.
|
---|
332 | *
|
---|
333 | * The task doesn't have to be suspended or anything.
|
---|
334 | *
|
---|
335 | * @returns VBox status codes:
|
---|
336 | * @retval VINF_SUCCESS on success.
|
---|
337 | * @retval VERR_INVALID_HANDLE if pTask is invalid but not NIL (asserts).
|
---|
338 | * @param pTask The async completion task.
|
---|
339 | */
|
---|
340 | PDMR3DECL(int) PDMR3AsyncCompletionDestroy(PPDMASYNCCOMPLETION pTask);
|
---|
341 |
|
---|
342 | /** @} */
|
---|
343 |
|
---|
344 | __END_DECLS
|
---|
345 |
|
---|
346 | #endif
|
---|
347 |
|
---|
348 |
|
---|
349 |
|
---|