1 | /** @file
|
---|
2 | * PDM - Pluggable Device Manager, Queues.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2013 Oracle Corporation
|
---|
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_vmm_pdmqueue_h
|
---|
27 | #define ___VBox_vmm_pdmqueue_h
|
---|
28 |
|
---|
29 | #include <VBox/types.h>
|
---|
30 |
|
---|
31 | RT_C_DECLS_BEGIN
|
---|
32 |
|
---|
33 | /** @defgroup grp_pdm_queue The PDM Queues API
|
---|
34 | * @ingroup grp_pdm
|
---|
35 | * @{
|
---|
36 | */
|
---|
37 |
|
---|
38 | /** Pointer to a PDM queue. Also called PDM queue handle. */
|
---|
39 | typedef struct PDMQUEUE *PPDMQUEUE;
|
---|
40 |
|
---|
41 | /** Pointer to a PDM queue item core. */
|
---|
42 | typedef struct PDMQUEUEITEMCORE *PPDMQUEUEITEMCORE;
|
---|
43 |
|
---|
44 | /**
|
---|
45 | * PDM queue item core.
|
---|
46 | */
|
---|
47 | typedef struct PDMQUEUEITEMCORE
|
---|
48 | {
|
---|
49 | /** Pointer to the next item in the pending list - R3 Pointer. */
|
---|
50 | R3PTRTYPE(PPDMQUEUEITEMCORE) pNextR3;
|
---|
51 | /** Pointer to the next item in the pending list - R0 Pointer. */
|
---|
52 | R0PTRTYPE(PPDMQUEUEITEMCORE) pNextR0;
|
---|
53 | /** Pointer to the next item in the pending list - RC Pointer. */
|
---|
54 | RCPTRTYPE(PPDMQUEUEITEMCORE) pNextRC;
|
---|
55 | #if HC_ARCH_BITS == 64
|
---|
56 | RTRCPTR Alignment0;
|
---|
57 | #endif
|
---|
58 | } PDMQUEUEITEMCORE;
|
---|
59 |
|
---|
60 |
|
---|
61 | /**
|
---|
62 | * Queue consumer callback for devices.
|
---|
63 | *
|
---|
64 | * @returns Success indicator.
|
---|
65 | * If false the item will not be removed and the flushing will stop.
|
---|
66 | * @param pDevIns The device instance.
|
---|
67 | * @param pItem The item to consume. Upon return this item will be freed.
|
---|
68 | * @remarks The device critical section will NOT be entered before calling the
|
---|
69 | * callback. No locks will be held, but for now it's safe to assume
|
---|
70 | * that only one EMT will do queue callbacks at any one time.
|
---|
71 | */
|
---|
72 | typedef DECLCALLBACK(bool) FNPDMQUEUEDEV(PPDMDEVINS pDevIns, PPDMQUEUEITEMCORE pItem);
|
---|
73 | /** Pointer to a FNPDMQUEUEDEV(). */
|
---|
74 | typedef FNPDMQUEUEDEV *PFNPDMQUEUEDEV;
|
---|
75 |
|
---|
76 | /**
|
---|
77 | * Queue consumer callback for USB devices.
|
---|
78 | *
|
---|
79 | * @returns Success indicator.
|
---|
80 | * If false the item will not be removed and the flushing will stop.
|
---|
81 | * @param pDevIns The USB device instance.
|
---|
82 | * @param pItem The item to consume. Upon return this item will be freed.
|
---|
83 | * @remarks No locks will be held, but for now it's safe to assume that only one
|
---|
84 | * EMT will do queue callbacks at any one time.
|
---|
85 | */
|
---|
86 | typedef DECLCALLBACK(bool) FNPDMQUEUEUSB(PPDMUSBINS pUsbIns, PPDMQUEUEITEMCORE pItem);
|
---|
87 | /** Pointer to a FNPDMQUEUEUSB(). */
|
---|
88 | typedef FNPDMQUEUEUSB *PFNPDMQUEUEUSB;
|
---|
89 |
|
---|
90 | /**
|
---|
91 | * Queue consumer callback for drivers.
|
---|
92 | *
|
---|
93 | * @returns Success indicator.
|
---|
94 | * If false the item will not be removed and the flushing will stop.
|
---|
95 | * @param pDrvIns The driver instance.
|
---|
96 | * @param pItem The item to consume. Upon return this item will be freed.
|
---|
97 | * @remarks No locks will be held, but for now it's safe to assume that only one
|
---|
98 | * EMT will do queue callbacks at any one time.
|
---|
99 | */
|
---|
100 | typedef DECLCALLBACK(bool) FNPDMQUEUEDRV(PPDMDRVINS pDrvIns, PPDMQUEUEITEMCORE pItem);
|
---|
101 | /** Pointer to a FNPDMQUEUEDRV(). */
|
---|
102 | typedef FNPDMQUEUEDRV *PFNPDMQUEUEDRV;
|
---|
103 |
|
---|
104 | /**
|
---|
105 | * Queue consumer callback for internal component.
|
---|
106 | *
|
---|
107 | * @returns Success indicator.
|
---|
108 | * If false the item will not be removed and the flushing will stop.
|
---|
109 | * @param pVM The VM handle.
|
---|
110 | * @param pItem The item to consume. Upon return this item will be freed.
|
---|
111 | * @remarks No locks will be held, but for now it's safe to assume that only one
|
---|
112 | * EMT will do queue callbacks at any one time.
|
---|
113 | */
|
---|
114 | typedef DECLCALLBACK(bool) FNPDMQUEUEINT(PVM pVM, PPDMQUEUEITEMCORE pItem);
|
---|
115 | /** Pointer to a FNPDMQUEUEINT(). */
|
---|
116 | typedef FNPDMQUEUEINT *PFNPDMQUEUEINT;
|
---|
117 |
|
---|
118 | /**
|
---|
119 | * Queue consumer callback for external component.
|
---|
120 | *
|
---|
121 | * @returns Success indicator.
|
---|
122 | * If false the item will not be removed and the flushing will stop.
|
---|
123 | * @param pvUser User argument.
|
---|
124 | * @param pItem The item to consume. Upon return this item will be freed.
|
---|
125 | * @remarks No locks will be held, but for now it's safe to assume that only one
|
---|
126 | * EMT will do queue callbacks at any one time.
|
---|
127 | */
|
---|
128 | typedef DECLCALLBACK(bool) FNPDMQUEUEEXT(void *pvUser, PPDMQUEUEITEMCORE pItem);
|
---|
129 | /** Pointer to a FNPDMQUEUEEXT(). */
|
---|
130 | typedef FNPDMQUEUEEXT *PFNPDMQUEUEEXT;
|
---|
131 |
|
---|
132 | #ifdef VBOX_IN_VMM
|
---|
133 | VMMR3_INT_DECL(int) PDMR3QueueCreateDevice(PVM pVM, PPDMDEVINS pDevIns, size_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
|
---|
134 | PFNPDMQUEUEDEV pfnCallback, bool fRZEnabled, const char *pszName, PPDMQUEUE *ppQueue);
|
---|
135 | VMMR3_INT_DECL(int) PDMR3QueueCreateDriver(PVM pVM, PPDMDRVINS pDrvIns, size_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
|
---|
136 | PFNPDMQUEUEDRV pfnCallback, const char *pszName, PPDMQUEUE *ppQueue);
|
---|
137 | VMMR3_INT_DECL(int) PDMR3QueueCreateInternal(PVM pVM, size_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
|
---|
138 | PFNPDMQUEUEINT pfnCallback, bool fGCEnabled, const char *pszName, PPDMQUEUE *ppQueue);
|
---|
139 | VMMR3_INT_DECL(int) PDMR3QueueCreateExternal(PVM pVM, size_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
|
---|
140 | PFNPDMQUEUEEXT pfnCallback, void *pvUser, const char *pszName, PPDMQUEUE *ppQueue);
|
---|
141 | VMMR3_INT_DECL(int) PDMR3QueueDestroy(PPDMQUEUE pQueue);
|
---|
142 | VMMR3_INT_DECL(int) PDMR3QueueDestroyDevice(PVM pVM, PPDMDEVINS pDevIns);
|
---|
143 | VMMR3_INT_DECL(int) PDMR3QueueDestroyDriver(PVM pVM, PPDMDRVINS pDrvIns);
|
---|
144 | VMMR3_INT_DECL(void) PDMR3QueueFlushAll(PVM pVM);
|
---|
145 | #endif /* VBOX_IN_VMM */
|
---|
146 |
|
---|
147 | VMMDECL(PPDMQUEUEITEMCORE) PDMQueueAlloc(PPDMQUEUE pQueue);
|
---|
148 | VMMDECL(void) PDMQueueInsert(PPDMQUEUE pQueue, PPDMQUEUEITEMCORE pItem);
|
---|
149 | VMMDECL(void) PDMQueueInsertEx(PPDMQUEUE pQueue, PPDMQUEUEITEMCORE pItem, uint64_t NanoMaxDelay);
|
---|
150 | VMMDECL(RCPTRTYPE(PPDMQUEUE)) PDMQueueRCPtr(PPDMQUEUE pQueue);
|
---|
151 | VMMDECL(R0PTRTYPE(PPDMQUEUE)) PDMQueueR0Ptr(PPDMQUEUE pQueue);
|
---|
152 |
|
---|
153 | /** @} */
|
---|
154 |
|
---|
155 | RT_C_DECLS_END
|
---|
156 |
|
---|
157 | #endif
|
---|
158 |
|
---|