VirtualBox

source: vbox/trunk/include/VBox/pdmqueue.h@ 4011

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

fixed some header hacks.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 9.7 KB
Line 
1/** @file
2 * PDM - Pluggable Device Manager, Queues.
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_pdmqueue_h
22#define ___VBox_pdmqueue_h
23
24#include <VBox/types.h>
25
26__BEGIN_DECLS
27
28/** @defgroup grp_pdm_queue Queues
29 * @ingroup grp_pdm
30 * @{
31 */
32
33/** Pointer to a PDM queue. Also called PDM queue handle. */
34typedef struct PDMQUEUE *PPDMQUEUE;
35
36/** Pointer to a PDM queue item core. */
37typedef struct PDMQUEUEITEMCORE *PPDMQUEUEITEMCORE;
38
39/**
40 * PDM queue item core.
41 */
42typedef struct PDMQUEUEITEMCORE
43{
44 /** Pointer to the next item in the pending list - HC Pointer. */
45 HCPTRTYPE(PPDMQUEUEITEMCORE) pNextHC;
46 /** Pointer to the next item in the pending list - GC Pointer. */
47 GCPTRTYPE(PPDMQUEUEITEMCORE) pNextGC;
48#if HC_ARCH_BITS == 64 && GC_ARCH_BITS == 32
49 uint32_t Alignment0;
50#endif
51} PDMQUEUEITEMCORE;
52
53
54/**
55 * Queue consumer callback for devices.
56 *
57 * @returns Success indicator.
58 * If false the item will not be removed and the flushing will stop.
59 * @param pDevIns The device instance.
60 * @param pItem The item to consume. Upon return this item will be freed.
61 */
62typedef DECLCALLBACK(bool) FNPDMQUEUEDEV(PPDMDEVINS pDevIns, PPDMQUEUEITEMCORE pItem);
63/** Pointer to a FNPDMQUEUEDEV(). */
64typedef FNPDMQUEUEDEV *PFNPDMQUEUEDEV;
65
66/**
67 * Queue consumer callback for drivers.
68 *
69 * @returns Success indicator.
70 * If false the item will not be removed and the flushing will stop.
71 * @param pDrvIns The driver instance.
72 * @param pItem The item to consume. Upon return this item will be freed.
73 */
74typedef DECLCALLBACK(bool) FNPDMQUEUEDRV(PPDMDRVINS pDrvIns, PPDMQUEUEITEMCORE pItem);
75/** Pointer to a FNPDMQUEUEDRV(). */
76typedef FNPDMQUEUEDRV *PFNPDMQUEUEDRV;
77
78/**
79 * Queue consumer callback for internal component.
80 *
81 * @returns Success indicator.
82 * If false the item will not be removed and the flushing will stop.
83 * @param pVM The VM handle.
84 * @param pItem The item to consume. Upon return this item will be freed.
85 */
86typedef DECLCALLBACK(bool) FNPDMQUEUEINT(PVM pVM, PPDMQUEUEITEMCORE pItem);
87/** Pointer to a FNPDMQUEUEINT(). */
88typedef FNPDMQUEUEINT *PFNPDMQUEUEINT;
89
90/**
91 * Queue consumer callback for external component.
92 *
93 * @returns Success indicator.
94 * If false the item will not be removed and the flushing will stop.
95 * @param pvUser User argument.
96 * @param pItem The item to consume. Upon return this item will be freed.
97 */
98typedef DECLCALLBACK(bool) FNPDMQUEUEEXT(void *pvUser, PPDMQUEUEITEMCORE pItem);
99/** Pointer to a FNPDMQUEUEEXT(). */
100typedef FNPDMQUEUEEXT *PFNPDMQUEUEEXT;
101
102/**
103 * Create a queue with a device owner.
104 *
105 * @returns VBox status code.
106 * @param pVM VM handle.
107 * @param pDevIns Device instance.
108 * @param cbItem Size a queue item.
109 * @param cItems Number of items in the queue.
110 * @param cMilliesInterval Number of milliseconds between polling the queue.
111 * If 0 then the emulation thread will be notified whenever an item arrives.
112 * @param pfnCallback The consumer function.
113 * @param fGCEnabled Set if the queue must be usable from GC.
114 * @param ppQueue Where to store the queue handle on success.
115 * @thread Emulation thread only.
116 */
117PDMR3DECL(int) PDMR3QueueCreateDevice(PVM pVM, PPDMDEVINS pDevIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
118 PFNPDMQUEUEDEV pfnCallback, bool fGCEnabled, PPDMQUEUE *ppQueue);
119
120/**
121 * Create a queue with a driver owner.
122 *
123 * @returns VBox status code.
124 * @param pVM VM handle.
125 * @param pDrvIns Driver instance.
126 * @param cbItem Size a queue item.
127 * @param cItems Number of items in the queue.
128 * @param cMilliesInterval Number of milliseconds between polling the queue.
129 * If 0 then the emulation thread will be notified whenever an item arrives.
130 * @param pfnCallback The consumer function.
131 * @param ppQueue Where to store the queue handle on success.
132 * @thread The emulation thread.
133 */
134PDMR3DECL(int) PDMR3QueueCreateDriver(PVM pVM, PPDMDRVINS pDrvIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
135 PFNPDMQUEUEDRV pfnCallback, PPDMQUEUE *ppQueue);
136
137/**
138 * Create a queue with an internal owner.
139 *
140 * @returns VBox status code.
141 * @param pVM VM handle.
142 * @param cbItem Size a queue item.
143 * @param cItems Number of items in the queue.
144 * @param cMilliesInterval Number of milliseconds between polling the queue.
145 * If 0 then the emulation thread will be notified whenever an item arrives.
146 * @param pfnCallback The consumer function.
147 * @param fGCEnabled Set if the queue must be usable from GC.
148 * @param ppQueue Where to store the queue handle on success.
149 * @thread Emulation thread only.
150 */
151PDMR3DECL(int) PDMR3QueueCreateInternal(PVM pVM, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
152 PFNPDMQUEUEINT pfnCallback, bool fGCEnabled, PPDMQUEUE *ppQueue);
153
154/**
155 * Create a queue with an external owner.
156 *
157 * @returns VBox status code.
158 * @param pVM VM handle.
159 * @param cbItem Size a queue item.
160 * @param cItems Number of items in the queue.
161 * @param cMilliesInterval Number of milliseconds between polling the queue.
162 * If 0 then the emulation thread will be notified whenever an item arrives.
163 * @param pfnCallback The consumer function.
164 * @param pvUser The user argument to the consumer function.
165 * @param ppQueue Where to store the queue handle on success.
166 * @thread The emulation thread.
167 */
168PDMR3DECL(int) PDMR3QueueCreateExternal(PVM pVM, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
169 PFNPDMQUEUEEXT pfnCallback, void *pvUser, PPDMQUEUE *ppQueue);
170
171/**
172 * Destroy a queue.
173 *
174 * @returns VBox status code.
175 * @param pQueue Queue to destroy.
176 * @thread The emulation thread.
177 */
178PDMR3DECL(int) PDMR3QueueDestroy(PPDMQUEUE pQueue);
179
180/**
181 * Destroy a all queues owned by the specified device.
182 *
183 * @returns VBox status code.
184 * @param pVM VM handle.
185 * @param pDevIns Device instance.
186 * @thread Emulation thread only.
187 */
188PDMR3DECL(int) PDMR3QueueDestroyDevice(PVM pVM, PPDMDEVINS pDevIns);
189
190/**
191 * Destroy a all queues owned by the specified driver.
192 *
193 * @returns VBox status code.
194 * @param pVM VM handle.
195 * @param pDrvIns Driver instance.
196 * @thread Emulation thread only.
197 */
198PDMR3DECL(int) PDMR3QueueDestroyDriver(PVM pVM, PPDMDRVINS pDrvIns);
199
200/**
201 * Flushes pending queues.
202 * This is a forced action callback.
203 *
204 * @param pVM VM handle.
205 * @thread The emulation thread.
206 */
207PDMR3DECL(void) PDMR3QueueFlushAll(PVM pVM);
208
209/**
210 * This is a worker function used by PDMQueueFlush to perform the
211 * flush in ring-3.
212 *
213 * The queue which should be flushed is pointed to by either pQueueFlushGC,
214 * pQueueFlushHC, or pQueueue. This function will flush that queue and
215 * recalc the queue FF.
216 *
217 * @param pVM The VM handle.
218 * @param pQueue The queue to flush. Only used in Ring-3.
219 */
220PDMR3DECL(void) PDMR3QueueFlushWorker(PVM pVM, PPDMQUEUE pQueue);
221
222/**
223 * Flushes a PDM queue.
224 *
225 * @param pQueue The queue handle.
226 */
227PDMDECL(void) PDMQueueFlush(PPDMQUEUE pQueue);
228
229/**
230 * Allocate an item from a queue.
231 * The allocated item must be handed on to PDMQueueInsert() after the
232 * data has been filled in.
233 *
234 * @returns Pointer to allocated queue item.
235 * @returns NULL on failure. The queue is exhausted.
236 * @param pQueue The queue handle.
237 * @thread Any thread.
238 */
239PDMDECL(PPDMQUEUEITEMCORE) PDMQueueAlloc(PPDMQUEUE pQueue);
240
241/**
242 * Queue an item.
243 * The item must have been obtained using PDMQueueAlloc(). Once the item
244 * has been passed to this function it must not be touched!
245 *
246 * @param pQueue The queue handle.
247 * @param pItem The item to insert.
248 * @thread Any thread.
249 */
250PDMDECL(void) PDMQueueInsert(PPDMQUEUE pQueue, PPDMQUEUEITEMCORE pItem);
251
252/**
253 * Queue an item.
254 * The item must have been obtained using PDMQueueAlloc(). Once the item
255 * have been passed to this function it must not be touched!
256 *
257 * @param pQueue The queue handle.
258 * @param pItem The item to insert.
259 * @param NanoMaxDelay The maximum delay before processing the queue, in nanoseconds.
260 * This applies only to GC.
261 * @thread Any thread.
262 */
263PDMDECL(void) PDMQueueInsertEx(PPDMQUEUE pQueue, PPDMQUEUEITEMCORE pItem, uint64_t NanoMaxDelay);
264
265
266/**
267 * Gets the GC pointer for the specified queue.
268 *
269 * @returns The GC address of the queue.
270 * @returns NULL if pQueue is invalid.
271 * @param pQueue The queue handle.
272 */
273PDMDECL(GCPTRTYPE(PPDMQUEUE)) PDMQueueGCPtr(PPDMQUEUE pQueue);
274
275/** @} */
276
277__END_DECLS
278
279#endif
280
281
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