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