VirtualBox

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

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

Eliminated HCPTRTYPE and replaced with R3R0PTRTYPE where necessary.

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