VirtualBox

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

Last change on this file since 3880 was 3854, checked in by vboxsync, 18 years ago

Splitting up pdm.h - export the fragments.

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette