1 | /** @file
|
---|
2 | * PDM - Pluggable Device Manager, Common Definitions & Types.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2016 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_pdmcommon_h
|
---|
27 | #define ___VBox_vmm_pdmcommon_h
|
---|
28 |
|
---|
29 | #include <VBox/types.h>
|
---|
30 |
|
---|
31 |
|
---|
32 | /** @defgroup grp_pdm_common Common Definitions & Types
|
---|
33 | * @ingroup grp_pdm
|
---|
34 | *
|
---|
35 | * Not all the types here are "common", they are here to work around header
|
---|
36 | * ordering issues.
|
---|
37 | *
|
---|
38 | * @{
|
---|
39 | */
|
---|
40 |
|
---|
41 | /** Makes a PDM structure version out of an unique magic value and major &
|
---|
42 | * minor version numbers.
|
---|
43 | *
|
---|
44 | * @returns 32-bit structure version number.
|
---|
45 | *
|
---|
46 | * @param uMagic 16-bit magic value. This must be unique.
|
---|
47 | * @param uMajor 12-bit major version number. Structures with different
|
---|
48 | * major numbers are not compatible.
|
---|
49 | * @param uMinor 4-bit minor version number. When only the minor version
|
---|
50 | * differs, the structures will be 100% backwards
|
---|
51 | * compatible.
|
---|
52 | */
|
---|
53 | #define PDM_VERSION_MAKE(uMagic, uMajor, uMinor) \
|
---|
54 | ( ((uint32_t)(uMagic) << 16) | ((uint32_t)((uMajor) & 0xff) << 4) | ((uint32_t)((uMinor) & 0xf) << 0) )
|
---|
55 |
|
---|
56 | /**
|
---|
57 | * Version of PDM_VERSION_MAKE that's compatible with the preprocessor.
|
---|
58 | *
|
---|
59 | * @returns 32-bit structure version number.
|
---|
60 | *
|
---|
61 | * @param uMagic 16-bit magic value, no suffix. This must be unique.
|
---|
62 | * @param uMajor 12-bit major version number, no suffix. Structures with
|
---|
63 | * different major numbers are not compatible.
|
---|
64 | * @param uMinor 4-bit minor version number, no suffix. When only the
|
---|
65 | * minor version differs, the structures will be 100%
|
---|
66 | * backwards compatible.
|
---|
67 | */
|
---|
68 | #define PDM_VERSION_MAKE_PP(uMagic, uMajor, uMinor) \
|
---|
69 | ( (UINT32_C(uMagic) << 16) | ((UINT32_C(uMajor) & UINT32_C(0xff)) << 4) | ((UINT32_C(uMinor) & UINT32_C(0xf)) << 0) )
|
---|
70 |
|
---|
71 | /** Checks if @a uVerMagic1 is compatible with @a uVerMagic2.
|
---|
72 | *
|
---|
73 | * @returns true / false.
|
---|
74 | * @param uVerMagic1 Typically the runtime version of the struct. This must
|
---|
75 | * have the same magic and major version as @a uVerMagic2
|
---|
76 | * and the minor version must be greater or equal to that
|
---|
77 | * of @a uVerMagic2.
|
---|
78 | * @param uVerMagic2 Typically the version the code was compiled against.
|
---|
79 | *
|
---|
80 | * @remarks The parameters will be referenced more than once.
|
---|
81 | */
|
---|
82 | #define PDM_VERSION_ARE_COMPATIBLE(uVerMagic1, uVerMagic2) \
|
---|
83 | ( (uVerMagic1) == (uVerMagic2) \
|
---|
84 | || ( (uVerMagic1) >= (uVerMagic2) \
|
---|
85 | && ((uVerMagic1) & UINT32_C(0xfffffff0)) == ((uVerMagic2) & UINT32_C(0xfffffff0)) ) \
|
---|
86 | )
|
---|
87 |
|
---|
88 |
|
---|
89 | /** PDM Attach/Detach Callback Flags.
|
---|
90 | * Used by PDMDeviceAttach, PDMDeviceDetach, PDMDriverAttach, PDMDriverDetach,
|
---|
91 | * FNPDMDEVATTACH, FNPDMDEVDETACH, FNPDMDRVATTACH, FNPDMDRVDETACH and
|
---|
92 | * FNPDMDRVCONSTRUCT.
|
---|
93 | @{ */
|
---|
94 | /** The attach/detach command is not a hotplug event. */
|
---|
95 | #define PDM_TACH_FLAGS_NOT_HOT_PLUG RT_BIT_32(0)
|
---|
96 | /** Indicates that no attach or detach callbacks should be made.
|
---|
97 | * This is mostly for internal use. */
|
---|
98 | #define PDM_TACH_FLAGS_NO_CALLBACKS RT_BIT_32(1)
|
---|
99 | /* @} */
|
---|
100 |
|
---|
101 |
|
---|
102 | /**
|
---|
103 | * Is asynchronous handling of suspend or power off notification completed?
|
---|
104 | *
|
---|
105 | * This is called to check whether the USB device has quiesced. Don't deadlock.
|
---|
106 | * Avoid blocking. Do NOT wait for anything.
|
---|
107 | *
|
---|
108 | * @returns true if done, false if more work to be done.
|
---|
109 | *
|
---|
110 | * @param pUsbIns The USB device instance.
|
---|
111 | *
|
---|
112 | * @thread EMT(0)
|
---|
113 | */
|
---|
114 | typedef DECLCALLBACK(bool) FNPDMUSBASYNCNOTIFY(PPDMUSBINS pUsbIns);
|
---|
115 | /** Pointer to a FNPDMUSBASYNCNOTIFY. */
|
---|
116 | typedef FNPDMUSBASYNCNOTIFY *PFNPDMUSBASYNCNOTIFY;
|
---|
117 |
|
---|
118 | /**
|
---|
119 | * Is asynchronous handling of suspend or power off notification completed?
|
---|
120 | *
|
---|
121 | * This is called to check whether the device has quiesced. Don't deadlock.
|
---|
122 | * Avoid blocking. Do NOT wait for anything.
|
---|
123 | *
|
---|
124 | * @returns true if done, false if more work to be done.
|
---|
125 | *
|
---|
126 | * @param pDevIns The device instance.
|
---|
127 | * @remarks The caller will enter the device critical section.
|
---|
128 | * @thread EMT(0)
|
---|
129 | */
|
---|
130 | typedef DECLCALLBACK(bool) FNPDMDEVASYNCNOTIFY(PPDMDEVINS pDevIns);
|
---|
131 | /** Pointer to a FNPDMDEVASYNCNOTIFY. */
|
---|
132 | typedef FNPDMDEVASYNCNOTIFY *PFNPDMDEVASYNCNOTIFY;
|
---|
133 |
|
---|
134 | /**
|
---|
135 | * Is asynchronous handling of suspend or power off notification completed?
|
---|
136 | *
|
---|
137 | * This is called to check whether the driver has quiesced. Don't deadlock.
|
---|
138 | * Avoid blocking. Do NOT wait for anything.
|
---|
139 | *
|
---|
140 | * @returns true if done, false if more work to be done.
|
---|
141 | *
|
---|
142 | * @param pDrvIns The driver instance.
|
---|
143 | *
|
---|
144 | * @thread EMT(0)
|
---|
145 | */
|
---|
146 | typedef DECLCALLBACK(bool) FNPDMDRVASYNCNOTIFY(PPDMDRVINS pDrvIns);
|
---|
147 | /** Pointer to a FNPDMDRVASYNCNOTIFY. */
|
---|
148 | typedef FNPDMDRVASYNCNOTIFY *PFNPDMDRVASYNCNOTIFY;
|
---|
149 |
|
---|
150 |
|
---|
151 | /**
|
---|
152 | * The ring-0 driver request handler.
|
---|
153 | *
|
---|
154 | * @returns VBox status code. PDMDevHlpCallR0 will return this.
|
---|
155 | * @param pDevIns The device instance (the ring-0 mapping).
|
---|
156 | * @param uOperation The operation.
|
---|
157 | * @param u64Arg Optional integer argument for the operation.
|
---|
158 | */
|
---|
159 | typedef DECLCALLBACK(int) FNPDMDEVREQHANDLERR0(PPDMDEVINS pDevIns, uint32_t uOperation, uint64_t u64Arg);
|
---|
160 | /** Ring-0 pointer to a FNPDMDEVREQHANDLERR0. */
|
---|
161 | typedef R0PTRTYPE(FNPDMDEVREQHANDLERR0 *) PFNPDMDEVREQHANDLERR0;
|
---|
162 |
|
---|
163 | /**
|
---|
164 | * The ring-0 driver request handler.
|
---|
165 | *
|
---|
166 | * @returns VBox status code. PDMDrvHlpCallR0 will return this.
|
---|
167 | * @param pDrvIns The driver instance (the ring-0 mapping).
|
---|
168 | * @param uOperation The operation.
|
---|
169 | * @param u64Arg Optional integer argument for the operation.
|
---|
170 | */
|
---|
171 | typedef DECLCALLBACK(int) FNPDMDRVREQHANDLERR0(PPDMDRVINS pDrvIns, uint32_t uOperation, uint64_t u64Arg);
|
---|
172 | /** Ring-0 pointer to a FNPDMDRVREQHANDLERR0. */
|
---|
173 | typedef R0PTRTYPE(FNPDMDRVREQHANDLERR0 *) PFNPDMDRVREQHANDLERR0;
|
---|
174 |
|
---|
175 |
|
---|
176 | /** @} */
|
---|
177 |
|
---|
178 | #endif
|
---|
179 |
|
---|