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