1 | /** @file
|
---|
2 | * PDM - Pluggable Device Manager, Tasks.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2019-2022 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_pdmtask_h
|
---|
27 | #define VBOX_INCLUDED_vmm_pdmtask_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_task The PDM Tasks API
|
---|
37 | * @ingroup grp_pdm
|
---|
38 | *
|
---|
39 | * A task is a predefined asynchronous procedure call that can be triggered from
|
---|
40 | * any context.
|
---|
41 | *
|
---|
42 | * @{
|
---|
43 | */
|
---|
44 |
|
---|
45 | /** PDM task handle. */
|
---|
46 | typedef uint64_t PDMTASKHANDLE;
|
---|
47 | /** NIL PDM task handle. */
|
---|
48 | #define NIL_PDMTASKHANDLE UINT64_MAX
|
---|
49 |
|
---|
50 |
|
---|
51 | /**
|
---|
52 | * Task worker callback for devices.
|
---|
53 | *
|
---|
54 | * @param pDevIns The device instance.
|
---|
55 | * @param pvUser The user parameter.
|
---|
56 | * @thread Task worker thread.
|
---|
57 | * @remarks The device critical section will NOT be entered before calling the
|
---|
58 | * callback. No other locks will be held either.
|
---|
59 | */
|
---|
60 | typedef DECLCALLBACKTYPE(void, FNPDMTASKDEV,(PPDMDEVINS pDevIns, void *pvUser));
|
---|
61 | /** Pointer to a FNPDMTASKDEV(). */
|
---|
62 | typedef FNPDMTASKDEV *PFNPDMTASKDEV;
|
---|
63 |
|
---|
64 | /**
|
---|
65 | * Task worker callback for drivers.
|
---|
66 | *
|
---|
67 | * @param pDrvIns The driver instance.
|
---|
68 | * @param pvUser The user parameter.
|
---|
69 | * @thread Task worker thread.
|
---|
70 | * @remarks No other locks will be held.
|
---|
71 | */
|
---|
72 | typedef DECLCALLBACKTYPE(void, FNPDMTASKDRV,(PPDMDRVINS pDrvIns, void *pvUser));
|
---|
73 | /** Pointer to a FNPDMTASKDRV(). */
|
---|
74 | typedef FNPDMTASKDRV *PFNPDMTASKDRV;
|
---|
75 |
|
---|
76 | /**
|
---|
77 | * Task worker callback for USB devices.
|
---|
78 | *
|
---|
79 | * @param pUsbIns The USB device instance.
|
---|
80 | * @param pvUser The user parameter.
|
---|
81 | * @thread Task worker thread.
|
---|
82 | * @remarks No other locks will be held.
|
---|
83 | */
|
---|
84 | typedef DECLCALLBACKTYPE(void, FNPDMTASKUSB,(PPDMUSBINS pUsbIns, void *pvUser));
|
---|
85 | /** Pointer to a FNPDMTASKUSB(). */
|
---|
86 | typedef FNPDMTASKUSB *PFNPDMTASKUSB;
|
---|
87 |
|
---|
88 | /**
|
---|
89 | * Task worker callback for internal components.
|
---|
90 | *
|
---|
91 | * @param pVM The cross context VM structure.
|
---|
92 | * @param pvUser The user parameter.
|
---|
93 | * @thread Task worker thread.
|
---|
94 | * @remarks No other locks will be held.
|
---|
95 | */
|
---|
96 | typedef DECLCALLBACKTYPE(void, FNPDMTASKINT,(PVM pVM, void *pvUser));
|
---|
97 | /** Pointer to a FNPDMTASKINT(). */
|
---|
98 | typedef FNPDMTASKINT *PFNPDMTASKINT;
|
---|
99 |
|
---|
100 |
|
---|
101 | /** @name PDMTASK_F_XXX - Task creation flags.
|
---|
102 | * @{ */
|
---|
103 | /** Create a ring-0 triggerable task. */
|
---|
104 | #define PDMTASK_F_R0 RT_BIT_32(0)
|
---|
105 | /** Create a raw-mode triggerable task. */
|
---|
106 | #define PDMTASK_F_RC RT_BIT_32(1)
|
---|
107 | /** Create a ring-0 and raw-mode triggerable task. */
|
---|
108 | #define PDMTASK_F_RZ (PDMTASK_F_R0 | PDMTASK_F_RC)
|
---|
109 | /** Valid flags. */
|
---|
110 | #define PDMTASK_F_VALID_MASK UINT32_C(0x00000003)
|
---|
111 | /** @} */
|
---|
112 |
|
---|
113 | #ifdef VBOX_IN_VMM
|
---|
114 | /**
|
---|
115 | * Task owner type.
|
---|
116 | */
|
---|
117 | typedef enum PDMTASKTYPE
|
---|
118 | {
|
---|
119 | /** Invalid zero value. */
|
---|
120 | PDMTASKTYPE_INVALID = 0,
|
---|
121 | /** Device consumer. */
|
---|
122 | PDMTASKTYPE_DEV,
|
---|
123 | /** Driver consumer. */
|
---|
124 | PDMTASKTYPE_DRV,
|
---|
125 | /** USB device consumer. */
|
---|
126 | PDMTASKTYPE_USB,
|
---|
127 | /** Internal consumer. */
|
---|
128 | PDMTASKTYPE_INTERNAL,
|
---|
129 | /** End of valid values. */
|
---|
130 | PDMTASKTYPE_END,
|
---|
131 | /** Typical 32-bit type blowup. */
|
---|
132 | PDMTASKTYPE_32BIT_HACK = 0x7fffffff
|
---|
133 | } PDMTASKTYPE;
|
---|
134 |
|
---|
135 | VMMR3_INT_DECL(int) PDMR3TaskCreate(PVM pVM, uint32_t fFlags, const char *pszName, PDMTASKTYPE enmType, void *pvOwner,
|
---|
136 | PFNRT pfnCallback, void *pvUser, PDMTASKHANDLE *phTask);
|
---|
137 | VMMR3_INT_DECL(int) PDMR3TaskCreateInternal(PVM pVM, uint32_t fFlags, const char *pszName,
|
---|
138 | PFNPDMTASKINT pfnCallback, void *pvUser, PDMTASKHANDLE *phTask);
|
---|
139 | VMMR3_INT_DECL(int) PDMR3TaskDestroyAllByOwner(PVM pVM, PDMTASKTYPE enmType, void *pvOwner);
|
---|
140 | VMMR3_INT_DECL(int) PDMR3TaskDestroySpecific(PVM pVM, PDMTASKTYPE enmType, void *pvOwner, PDMTASKHANDLE hTask);
|
---|
141 | VMMR3_INT_DECL(int) PDMR3TaskDestroyInternal(PVM pVM, PDMTASKHANDLE hTask);
|
---|
142 |
|
---|
143 | VMM_INT_DECL(int) PDMTaskTrigger(PVMCC pVM, PDMTASKTYPE enmType, RTR3PTR pvOwner, PDMTASKHANDLE hTask);
|
---|
144 | VMM_INT_DECL(int) PDMTaskTriggerInternal(PVMCC pVM, PDMTASKHANDLE hTask);
|
---|
145 | #endif /* VBOX_IN_VMM */
|
---|
146 |
|
---|
147 | /** @} */
|
---|
148 |
|
---|
149 | RT_C_DECLS_END
|
---|
150 |
|
---|
151 | #endif /* !VBOX_INCLUDED_vmm_pdmtask_h */
|
---|
152 |
|
---|