VirtualBox

source: vbox/trunk/include/VBox/pdmasynccompletion.h@ 6168

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

Wrappers for template creation the right way.

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