1 | /** @file
|
---|
2 | * VBoxGuest - VirtualBox Guest Additions, Core Types.
|
---|
3 | *
|
---|
4 | * This contains types that are used both in the VBoxGuest I/O control interface
|
---|
5 | * and the VBoxGuestLib. The goal is to avoid having to include VBoxGuest.h
|
---|
6 | * everwhere VBoxGuestLib.h is used.
|
---|
7 | */
|
---|
8 |
|
---|
9 | /*
|
---|
10 | * Copyright (C) 2006-2018 Oracle Corporation
|
---|
11 | *
|
---|
12 | * Permission is hereby granted, free of charge, to any person
|
---|
13 | * obtaining a copy of this software and associated documentation
|
---|
14 | * files (the "Software"), to deal in the Software without
|
---|
15 | * restriction, including without limitation the rights to use,
|
---|
16 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
|
---|
17 | * copies of the Software, and to permit persons to whom the
|
---|
18 | * Software is furnished to do so, subject to the following
|
---|
19 | * conditions:
|
---|
20 | *
|
---|
21 | * The above copyright notice and this permission notice shall be
|
---|
22 | * included in all copies or substantial portions of the Software.
|
---|
23 | *
|
---|
24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
---|
25 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
---|
26 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
---|
27 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
---|
28 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
---|
29 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
---|
30 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
---|
31 | * OTHER DEALINGS IN THE SOFTWARE.
|
---|
32 | */
|
---|
33 |
|
---|
34 |
|
---|
35 | #ifndef ___VBoxGuestCoreTypes_h
|
---|
36 | #define ___VBoxGuestCoreTypes_h
|
---|
37 |
|
---|
38 | #include <iprt/types.h>
|
---|
39 | #include <iprt/assertcompile.h>
|
---|
40 |
|
---|
41 | /** @addtogroup grp_vboxguest
|
---|
42 | * @{ */
|
---|
43 |
|
---|
44 | /**
|
---|
45 | * Common in/out header.
|
---|
46 | *
|
---|
47 | * This is a copy/mirror of VMMDevRequestHeader to prevent duplicating data and
|
---|
48 | * needing to verify things multiple times. For that reason this differs a bit
|
---|
49 | * from SUPREQHDR.
|
---|
50 | *
|
---|
51 | * @sa VMMDevRequestHeader
|
---|
52 | */
|
---|
53 | typedef struct VBGLREQHDR
|
---|
54 | {
|
---|
55 | /** IN: The request input size, and output size if cbOut is zero.
|
---|
56 | * @sa VMMDevRequestHeader::size */
|
---|
57 | uint32_t cbIn;
|
---|
58 | /** IN: Structure version (VBGLREQHDR_VERSION)
|
---|
59 | * @sa VMMDevRequestHeader::version */
|
---|
60 | uint32_t uVersion;
|
---|
61 | /** IN: The VMMDev request type, set to VBGLREQHDR_TYPE_DEFAULT unless this is a
|
---|
62 | * kind of VMMDev request.
|
---|
63 | * @sa VMMDevRequestType, VMMDevRequestHeader::requestType */
|
---|
64 | uint32_t uType;
|
---|
65 | /** OUT: The VBox status code of the operation, out direction only. */
|
---|
66 | int32_t rc;
|
---|
67 | /** IN: The output size. This is optional - set to zero to use cbIn as the
|
---|
68 | * output size. */
|
---|
69 | uint32_t cbOut;
|
---|
70 | /** Reserved / filled in by kernel, MBZ.
|
---|
71 | * @sa VMMDevRequestHeader::fRequestor */
|
---|
72 | uint32_t uReserved;
|
---|
73 | } VBGLREQHDR;
|
---|
74 | AssertCompileSize(VBGLREQHDR, 24);
|
---|
75 | /** Pointer to a IOC header. */
|
---|
76 | typedef VBGLREQHDR RT_FAR *PVBGLREQHDR;
|
---|
77 |
|
---|
78 | /** Version of VMMDevRequestHeader structure. */
|
---|
79 | #define VBGLREQHDR_VERSION UINT32_C(0x10001)
|
---|
80 | /** Default request type. Use this for non-VMMDev requests. */
|
---|
81 | #define VBGLREQHDR_TYPE_DEFAULT UINT32_C(0)
|
---|
82 |
|
---|
83 | /** Initialize a VBGLREQHDR structure for a fixed size I/O control call.
|
---|
84 | * @param a_pHdr Pointer to the header to initialize.
|
---|
85 | * @param a_IOCtl The base I/O control name, no VBGL_IOCTL_ prefix. We
|
---|
86 | * have to skip the prefix to avoid it getting expanded
|
---|
87 | * before we append _SIZE_IN and _SIZE_OUT to it.
|
---|
88 | */
|
---|
89 | #define VBGLREQHDR_INIT(a_pHdr, a_IOCtl) \
|
---|
90 | VBGLREQHDR_INIT_EX(a_pHdr, RT_CONCAT3(VBGL_IOCTL_,a_IOCtl,_SIZE_IN), RT_CONCAT3(VBGL_IOCTL_,a_IOCtl,_SIZE_OUT))
|
---|
91 | /** Initialize a VBGLREQHDR structure, extended version. */
|
---|
92 | #define VBGLREQHDR_INIT_EX(a_pHdr, a_cbIn, a_cbOut) \
|
---|
93 | do { \
|
---|
94 | (a_pHdr)->cbIn = (uint32_t)(a_cbIn); \
|
---|
95 | (a_pHdr)->uVersion = VBGLREQHDR_VERSION; \
|
---|
96 | (a_pHdr)->uType = VBGLREQHDR_TYPE_DEFAULT; \
|
---|
97 | (a_pHdr)->rc = VERR_INTERNAL_ERROR; \
|
---|
98 | (a_pHdr)->cbOut = (uint32_t)(a_cbOut); \
|
---|
99 | (a_pHdr)->uReserved = 0; \
|
---|
100 | } while (0)
|
---|
101 | /** Initialize a VBGLREQHDR structure for a VMMDev request.
|
---|
102 | * Same as VMMDEV_REQ_HDR_INIT(). */
|
---|
103 | #define VBGLREQHDR_INIT_VMMDEV(a_pHdr, a_cb, a_enmType) \
|
---|
104 | do { \
|
---|
105 | (a_pHdr)->cbIn = (a_cb); \
|
---|
106 | (a_pHdr)->uVersion = VBGLREQHDR_VERSION; \
|
---|
107 | (a_pHdr)->uType = (a_enmType); \
|
---|
108 | (a_pHdr)->rc = VERR_INTERNAL_ERROR; \
|
---|
109 | (a_pHdr)->cbOut = 0; \
|
---|
110 | (a_pHdr)->uReserved = 0; \
|
---|
111 | } while (0)
|
---|
112 |
|
---|
113 |
|
---|
114 | /**
|
---|
115 | * For VBGL_IOCTL_HGCM_CALL and VBGL_IOCTL_HGCM_CALL_WITH_USER_DATA.
|
---|
116 | *
|
---|
117 | * @note This is used by alot of HGCM call structures.
|
---|
118 | */
|
---|
119 | typedef struct VBGLIOCHGCMCALL
|
---|
120 | {
|
---|
121 | /** Common header. */
|
---|
122 | VBGLREQHDR Hdr;
|
---|
123 | /** Input: The id of the caller. */
|
---|
124 | uint32_t u32ClientID;
|
---|
125 | /** Input: Function number. */
|
---|
126 | uint32_t u32Function;
|
---|
127 | /** Input: How long to wait (milliseconds) for completion before cancelling the
|
---|
128 | * call. This is ignored if not a VBGL_IOCTL_HGCM_CALL_TIMED or
|
---|
129 | * VBGL_IOCTL_HGCM_CALL_TIMED_32 request. */
|
---|
130 | uint32_t cMsTimeout;
|
---|
131 | /** Input: Whether a timed call is interruptible (ring-0 only). This is ignored
|
---|
132 | * if not a VBGL_IOCTL_HGCM_CALL_TIMED or VBGL_IOCTL_HGCM_CALL_TIMED_32
|
---|
133 | * request, or if made from user land. */
|
---|
134 | bool fInterruptible;
|
---|
135 | /** Explicit padding, MBZ. */
|
---|
136 | uint8_t bReserved;
|
---|
137 | /** Input: How many parameters following this structure.
|
---|
138 | *
|
---|
139 | * The parameters are either HGCMFunctionParameter64 or HGCMFunctionParameter32,
|
---|
140 | * depending on whether we're receiving a 64-bit or 32-bit request.
|
---|
141 | *
|
---|
142 | * The current maximum is 61 parameters (given a 1KB max request size,
|
---|
143 | * and a 64-bit parameter size of 16 bytes).
|
---|
144 | *
|
---|
145 | * @note This information is duplicated by Hdr.cbIn, but it's currently too much
|
---|
146 | * work to eliminate this. */
|
---|
147 | uint16_t cParms;
|
---|
148 | /* Parameters follow in form HGCMFunctionParameter aParms[cParms] */
|
---|
149 | } VBGLIOCHGCMCALL, RT_FAR *PVBGLIOCHGCMCALL;
|
---|
150 | AssertCompileSize(VBGLIOCHGCMCALL, 24 + 16);
|
---|
151 | typedef VBGLIOCHGCMCALL const RT_FAR *PCVBGLIOCHGCMCALL;
|
---|
152 |
|
---|
153 | /**
|
---|
154 | * Initialize a HGCM header (VBGLIOCHGCMCALL) for a non-timed call.
|
---|
155 | *
|
---|
156 | * @param a_pHdr The header to initalize.
|
---|
157 | * @param a_idClient The client connection ID to call thru.
|
---|
158 | * @param a_idFunction The function we're calling
|
---|
159 | * @param a_cParameters Number of parameters.
|
---|
160 | */
|
---|
161 | # define VBGL_HGCM_HDR_INIT(a_pHdr, a_idClient, a_idFunction, a_cParameters) \
|
---|
162 | do { \
|
---|
163 | VBGLREQHDR_INIT_EX(&(a_pHdr)->Hdr, \
|
---|
164 | sizeof(VBGLIOCHGCMCALL) + (a_cParameters) * sizeof(HGCMFunctionParameter), \
|
---|
165 | sizeof(VBGLIOCHGCMCALL) + (a_cParameters) * sizeof(HGCMFunctionParameter)); \
|
---|
166 | (a_pHdr)->u32ClientID = (a_idClient); \
|
---|
167 | (a_pHdr)->u32Function = (a_idFunction); \
|
---|
168 | (a_pHdr)->cMsTimeout = RT_INDEFINITE_WAIT; \
|
---|
169 | (a_pHdr)->fInterruptible = true; \
|
---|
170 | (a_pHdr)->bReserved = 0; \
|
---|
171 | (a_pHdr)->cParms = (a_cParameters); \
|
---|
172 | } while (0)
|
---|
173 |
|
---|
174 | /**
|
---|
175 | * Initialize a HGCM header (VBGLIOCHGCMCALL) for a non-timed call, custom size.
|
---|
176 | *
|
---|
177 | * This is usually only needed when appending page lists to the call.
|
---|
178 | *
|
---|
179 | * @param a_pHdr The header to initalize.
|
---|
180 | * @param a_idClient The client connection ID to call thru.
|
---|
181 | * @param a_idFunction The function we're calling
|
---|
182 | * @param a_cParameters Number of parameters.
|
---|
183 | * @param a_cbReq The request size.
|
---|
184 | */
|
---|
185 | # define VBGL_HGCM_HDR_INIT_EX(a_pHdr, a_idClient, a_idFunction, a_cParameters, a_cbReq) \
|
---|
186 | do { \
|
---|
187 | Assert((a_cbReq) >= sizeof(VBGLIOCHGCMCALL) + (a_cParameters) * sizeof(HGCMFunctionParameter)); \
|
---|
188 | VBGLREQHDR_INIT_EX(&(a_pHdr)->Hdr, (a_cbReq), (a_cbReq)); \
|
---|
189 | (a_pHdr)->u32ClientID = (a_idClient); \
|
---|
190 | (a_pHdr)->u32Function = (a_idFunction); \
|
---|
191 | (a_pHdr)->cMsTimeout = RT_INDEFINITE_WAIT; \
|
---|
192 | (a_pHdr)->fInterruptible = true; \
|
---|
193 | (a_pHdr)->bReserved = 0; \
|
---|
194 | (a_pHdr)->cParms = (a_cParameters); \
|
---|
195 | } while (0)
|
---|
196 |
|
---|
197 | /**
|
---|
198 | * Initialize a HGCM header (VBGLIOCHGCMCALL), with timeout (interruptible).
|
---|
199 | *
|
---|
200 | * @param a_pHdr The header to initalize.
|
---|
201 | * @param a_idClient The client connection ID to call thru.
|
---|
202 | * @param a_idFunction The function we're calling
|
---|
203 | * @param a_cParameters Number of parameters.
|
---|
204 | * @param a_cMsTimeout The timeout in milliseconds.
|
---|
205 | */
|
---|
206 | # define VBGL_HGCM_HDR_INIT_TIMED(a_pHdr, a_idClient, a_idFunction, a_cParameters, a_cMsTimeout) \
|
---|
207 | do { \
|
---|
208 | VBGLREQHDR_INIT_EX(&(a_pHdr)->Hdr, \
|
---|
209 | sizeof(VBGLIOCHGCMCALL) + (a_cParameters) * sizeof(HGCMFunctionParameter), \
|
---|
210 | sizeof(VBGLIOCHGCMCALL) + (a_cParameters) * sizeof(HGCMFunctionParameter)); \
|
---|
211 | (a_pHdr)->u32ClientID = (a_idClient); \
|
---|
212 | (a_pHdr)->u32Function = (a_idFunction); \
|
---|
213 | (a_pHdr)->cMsTimeout = (a_cMsTimeout); \
|
---|
214 | (a_pHdr)->fInterruptible = true; \
|
---|
215 | (a_pHdr)->bReserved = 0; \
|
---|
216 | (a_pHdr)->cParms = (a_cParameters); \
|
---|
217 | } while (0)
|
---|
218 |
|
---|
219 | /** Get the pointer to the first HGCM parameter. */
|
---|
220 | # define VBGL_HGCM_GET_CALL_PARMS(a_pInfo) ( (HGCMFunctionParameter *)((uint8_t *)(a_pInfo) + sizeof(VBGLIOCHGCMCALL)) )
|
---|
221 | /** Get the pointer to the first HGCM parameter in a 32-bit request. */
|
---|
222 | # define VBGL_HGCM_GET_CALL_PARMS32(a_pInfo) ( (HGCMFunctionParameter32 *)((uint8_t *)(a_pInfo) + sizeof(VBGLIOCHGCMCALL)) )
|
---|
223 |
|
---|
224 |
|
---|
225 | /**
|
---|
226 | * Mouse event noticification callback function.
|
---|
227 | * @param pvUser Argument given when setting the callback.
|
---|
228 | */
|
---|
229 | typedef DECLCALLBACK(void) FNVBOXGUESTMOUSENOTIFY(void *pvUser);
|
---|
230 | /** Pointer to a mouse event notification callback function. */
|
---|
231 | typedef FNVBOXGUESTMOUSENOTIFY *PFNVBOXGUESTMOUSENOTIFY; /**< @todo fix type prefix */
|
---|
232 |
|
---|
233 | /** @} */
|
---|
234 |
|
---|
235 | #endif
|
---|
236 |
|
---|