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