VirtualBox

source: vbox/trunk/include/VBox/vmm/pdmqueue.h@ 88534

Last change on this file since 88534 was 85121, checked in by vboxsync, 4 years ago

iprt/cdefs.h: Refactored the typedef use of DECLCALLBACK as well as DECLCALLBACKMEMBER to wrap the whole expression, similar to the DECLR?CALLBACKMEMBER macros. This allows adding a throw() at the end when compiling with the VC++ compiler to indicate that the callbacks won't throw anything, so we can stop supressing the C5039 warning about passing functions that can potential throw C++ exceptions to extern C code that can't necessarily cope with such (unwind,++). Introduced a few _EX variations that allows specifying different/no calling convention too, as that's handy when dynamically resolving host APIs. Fixed numerous places missing DECLCALLBACK and such. Left two angry @todos regarding use of CreateThread. bugref:9794

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 6.9 KB
Line 
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
34RT_C_DECLS_BEGIN
35
36/** @defgroup grp_pdm_queue The PDM Queues API
37 * @ingroup grp_pdm
38 * @{
39 */
40
41/** PDM queue handle. */
42typedef uint64_t PDMQUEUEHANDLE;
43/** NIL PDM queue handle. */
44#define NIL_PDMQUEUEHANDLE UINT64_MAX
45
46/** Pointer to a PDM queue. */
47typedef struct PDMQUEUE *PPDMQUEUE;
48
49/** Pointer to a PDM queue item core. */
50typedef struct PDMQUEUEITEMCORE *PPDMQUEUEITEMCORE;
51
52/**
53 * PDM queue item core.
54 */
55typedef 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 */
80typedef DECLCALLBACKTYPE(bool, FNPDMQUEUEDEV,(PPDMDEVINS pDevIns, PPDMQUEUEITEMCORE pItem));
81/** Pointer to a FNPDMQUEUEDEV(). */
82typedef 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 */
94typedef DECLCALLBACKTYPE(bool, FNPDMQUEUEUSB,(PPDMUSBINS pUsbIns, PPDMQUEUEITEMCORE pItem));
95/** Pointer to a FNPDMQUEUEUSB(). */
96typedef 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 */
108typedef DECLCALLBACKTYPE(bool, FNPDMQUEUEDRV,(PPDMDRVINS pDrvIns, PPDMQUEUEITEMCORE pItem));
109/** Pointer to a FNPDMQUEUEDRV(). */
110typedef 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 */
122typedef DECLCALLBACKTYPE(bool, FNPDMQUEUEINT,(PVM pVM, PPDMQUEUEITEMCORE pItem));
123/** Pointer to a FNPDMQUEUEINT(). */
124typedef 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 */
136typedef DECLCALLBACKTYPE(bool, FNPDMQUEUEEXT,(void *pvUser, PPDMQUEUEITEMCORE pItem));
137/** Pointer to a FNPDMQUEUEEXT(). */
138typedef FNPDMQUEUEEXT *PFNPDMQUEUEEXT;
139
140#ifdef VBOX_IN_VMM
141VMMR3_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);
143VMMR3_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);
145VMMR3_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);
147VMMR3_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);
149VMMR3_INT_DECL(int) PDMR3QueueDestroy(PPDMQUEUE pQueue);
150VMMR3_INT_DECL(int) PDMR3QueueDestroyDevice(PVM pVM, PPDMDEVINS pDevIns);
151VMMR3_INT_DECL(int) PDMR3QueueDestroyDriver(PVM pVM, PPDMDRVINS pDrvIns);
152VMMR3_INT_DECL(void) PDMR3QueueFlushAll(PVM pVM);
153#endif /* VBOX_IN_VMM */
154
155VMMDECL(PPDMQUEUEITEMCORE) PDMQueueAlloc(PPDMQUEUE pQueue);
156VMMDECL(void) PDMQueueInsert(PPDMQUEUE pQueue, PPDMQUEUEITEMCORE pItem);
157VMMDECL(void) PDMQueueInsertEx(PPDMQUEUE pQueue, PPDMQUEUEITEMCORE pItem, uint64_t NanoMaxDelay);
158VMMDECL(RCPTRTYPE(PPDMQUEUE)) PDMQueueRCPtr(PPDMQUEUE pQueue);
159VMMDECL(R0PTRTYPE(PPDMQUEUE)) PDMQueueR0Ptr(PPDMQUEUE pQueue);
160VMMDECL(bool) PDMQueueFlushIfNecessary(PPDMQUEUE pQueue);
161
162/** @} */
163
164RT_C_DECLS_END
165
166#endif /* !VBOX_INCLUDED_vmm_pdmqueue_h */
167
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