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-2017 Oracle Corporation
|
---|
11 | *
|
---|
12 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
13 | * available from http://www.virtualbox.org. This file is free software;
|
---|
14 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
15 | * General Public License (GPL) as published by the Free Software
|
---|
16 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
17 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
18 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
19 | *
|
---|
20 | * The contents of this file may alternatively be used under the terms
|
---|
21 | * of the Common Development and Distribution License Version 1.0
|
---|
22 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
23 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
24 | * CDDL are applicable instead of those of the GPL.
|
---|
25 | *
|
---|
26 | * You may elect to license modified versions of this file under the
|
---|
27 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
28 | */
|
---|
29 |
|
---|
30 |
|
---|
31 | #ifndef ___VBoxGuestCoreTypes_h
|
---|
32 | #define ___VBoxGuestCoreTypes_h
|
---|
33 |
|
---|
34 | #include <iprt/types.h>
|
---|
35 | #include <iprt/assertcompile.h>
|
---|
36 |
|
---|
37 | /** @addtogroup grp_vboxguest
|
---|
38 | * @{ */
|
---|
39 |
|
---|
40 | /**
|
---|
41 | * Common in/out header.
|
---|
42 | *
|
---|
43 | * This is a copy/mirror of VMMDevRequestHeader to prevent duplicating data and
|
---|
44 | * needing to verify things multiple times. For that reason this differs a bit
|
---|
45 | * from SUPREQHDR.
|
---|
46 | *
|
---|
47 | * @sa VMMDevRequestHeader
|
---|
48 | */
|
---|
49 | typedef struct VBGLREQHDR
|
---|
50 | {
|
---|
51 | /** IN: The request input size, and output size if cbOut is zero.
|
---|
52 | * @sa VMMDevRequestHeader::size */
|
---|
53 | uint32_t cbIn;
|
---|
54 | /** IN: Structure version (VBGLREQHDR_VERSION)
|
---|
55 | * @sa VMMDevRequestHeader::version */
|
---|
56 | uint32_t uVersion;
|
---|
57 | /** IN: The VMMDev request type, set to VBGLREQHDR_TYPE_DEFAULT unless this is a
|
---|
58 | * kind of VMMDev request.
|
---|
59 | * @sa VMMDevRequestType, VMMDevRequestHeader::requestType */
|
---|
60 | uint32_t uType;
|
---|
61 | /** OUT: The VBox status code of the operation, out direction only. */
|
---|
62 | int32_t rc;
|
---|
63 | /** IN: The output size. This is optional - set to zero to use cbIn as the
|
---|
64 | * output size. */
|
---|
65 | uint32_t cbOut;
|
---|
66 | /** Reserved / filled in by kernel, MBZ.
|
---|
67 | * @sa VMMDevRequestHeader::fRequestor */
|
---|
68 | uint32_t uReserved;
|
---|
69 | } VBGLREQHDR;
|
---|
70 | AssertCompileSize(VBGLREQHDR, 24);
|
---|
71 | /** Pointer to a IOC header. */
|
---|
72 | typedef VBGLREQHDR RT_FAR *PVBGLREQHDR;
|
---|
73 |
|
---|
74 | /** Version of VMMDevRequestHeader structure. */
|
---|
75 | #define VBGLREQHDR_VERSION UINT32_C(0x10001)
|
---|
76 | /** Default request type. Use this for non-VMMDev requests. */
|
---|
77 | #define VBGLREQHDR_TYPE_DEFAULT UINT32_C(0)
|
---|
78 |
|
---|
79 | /** Initialize a VBGLREQHDR structure for a fixed size I/O control call.
|
---|
80 | * @param a_pHdr Pointer to the header to initialize.
|
---|
81 | * @param a_IOCtl The base I/O control name, no VBGL_IOCTL_ prefix. We
|
---|
82 | * have to skip the prefix to avoid it getting expanded
|
---|
83 | * before we append _SIZE_IN and _SIZE_OUT to it.
|
---|
84 | */
|
---|
85 | #define VBGLREQHDR_INIT(a_pHdr, a_IOCtl) \
|
---|
86 | VBGLREQHDR_INIT_EX(a_pHdr, RT_CONCAT3(VBGL_IOCTL_,a_IOCtl,_SIZE_IN), RT_CONCAT3(VBGL_IOCTL_,a_IOCtl,_SIZE_OUT))
|
---|
87 | /** Initialize a VBGLREQHDR structure, extended version. */
|
---|
88 | #define VBGLREQHDR_INIT_EX(a_pHdr, a_cbIn, a_cbOut) \
|
---|
89 | do { \
|
---|
90 | (a_pHdr)->cbIn = (uint32_t)(a_cbIn); \
|
---|
91 | (a_pHdr)->uVersion = VBGLREQHDR_VERSION; \
|
---|
92 | (a_pHdr)->uType = VBGLREQHDR_TYPE_DEFAULT; \
|
---|
93 | (a_pHdr)->rc = VERR_INTERNAL_ERROR; \
|
---|
94 | (a_pHdr)->cbOut = (uint32_t)(a_cbOut); \
|
---|
95 | (a_pHdr)->uReserved = 0; \
|
---|
96 | } while (0)
|
---|
97 | /** Initialize a VBGLREQHDR structure for a VMMDev request.
|
---|
98 | * Same as VMMDEV_REQ_HDR_INIT(). */
|
---|
99 | #define VBGLREQHDR_INIT_VMMDEV(a_pHdr, a_cb, a_enmType) \
|
---|
100 | do { \
|
---|
101 | (a_pHdr)->cbIn = (a_cb); \
|
---|
102 | (a_pHdr)->uVersion = VBGLREQHDR_VERSION; \
|
---|
103 | (a_pHdr)->uType = (a_enmType); \
|
---|
104 | (a_pHdr)->rc = VERR_INTERNAL_ERROR; \
|
---|
105 | (a_pHdr)->cbOut = 0; \
|
---|
106 | (a_pHdr)->uReserved = 0; \
|
---|
107 | } while (0)
|
---|
108 |
|
---|
109 |
|
---|
110 | /**
|
---|
111 | * For VBGL_IOCTL_HGCM_CALL and VBGL_IOCTL_HGCM_CALL_WITH_USER_DATA.
|
---|
112 | *
|
---|
113 | * @note This is used by alot of HGCM call structures.
|
---|
114 | */
|
---|
115 | typedef struct VBGLIOCHGCMCALL
|
---|
116 | {
|
---|
117 | /** Common header. */
|
---|
118 | VBGLREQHDR Hdr;
|
---|
119 | /** Input: The id of the caller. */
|
---|
120 | uint32_t u32ClientID;
|
---|
121 | /** Input: Function number. */
|
---|
122 | uint32_t u32Function;
|
---|
123 | /** Input: How long to wait (milliseconds) for completion before cancelling the
|
---|
124 | * call. This is ignored if not a VBGL_IOCTL_HGCM_CALL_TIMED or
|
---|
125 | * VBGL_IOCTL_HGCM_CALL_TIMED_32 request. */
|
---|
126 | uint32_t cMsTimeout;
|
---|
127 | /** Input: Whether a timed call is interruptible (ring-0 only). This is ignored
|
---|
128 | * if not a VBGL_IOCTL_HGCM_CALL_TIMED or VBGL_IOCTL_HGCM_CALL_TIMED_32
|
---|
129 | * request, or if made from user land. */
|
---|
130 | bool fInterruptible;
|
---|
131 | /** Explicit padding, MBZ. */
|
---|
132 | uint8_t bReserved;
|
---|
133 | /** Input: How many parameters following this structure.
|
---|
134 | *
|
---|
135 | * The parameters are either HGCMFunctionParameter64 or HGCMFunctionParameter32,
|
---|
136 | * depending on whether we're receiving a 64-bit or 32-bit request.
|
---|
137 | *
|
---|
138 | * The current maximum is 61 parameters (given a 1KB max request size,
|
---|
139 | * and a 64-bit parameter size of 16 bytes).
|
---|
140 | *
|
---|
141 | * @note This information is duplicated by Hdr.cbIn, but it's currently too much
|
---|
142 | * work to eliminate this. */
|
---|
143 | uint16_t cParms;
|
---|
144 | /* Parameters follow in form HGCMFunctionParameter aParms[cParms] */
|
---|
145 | } VBGLIOCHGCMCALL, RT_FAR *PVBGLIOCHGCMCALL;
|
---|
146 | AssertCompileSize(VBGLIOCHGCMCALL, 24 + 16);
|
---|
147 | typedef VBGLIOCHGCMCALL const RT_FAR *PCVBGLIOCHGCMCALL;
|
---|
148 |
|
---|
149 | /**
|
---|
150 | * Initialize a HGCM header (VBGLIOCHGCMCALL) for a non-timed call.
|
---|
151 | *
|
---|
152 | * @param a_pHdr The header to initalize.
|
---|
153 | * @param a_idClient The client connection ID to call thru.
|
---|
154 | * @param a_idFunction The function we're calling
|
---|
155 | * @param a_cParameters Number of parameters.
|
---|
156 | */
|
---|
157 | # define VBGL_HGCM_HDR_INIT(a_pHdr, a_idClient, a_idFunction, a_cParameters) \
|
---|
158 | do { \
|
---|
159 | VBGLREQHDR_INIT_EX(&(a_pHdr)->Hdr, \
|
---|
160 | sizeof(VBGLIOCHGCMCALL) + (a_cParameters) * sizeof(HGCMFunctionParameter), \
|
---|
161 | sizeof(VBGLIOCHGCMCALL) + (a_cParameters) * sizeof(HGCMFunctionParameter)); \
|
---|
162 | (a_pHdr)->u32ClientID = (a_idClient); \
|
---|
163 | (a_pHdr)->u32Function = (a_idFunction); \
|
---|
164 | (a_pHdr)->cMsTimeout = RT_INDEFINITE_WAIT; \
|
---|
165 | (a_pHdr)->fInterruptible = true; \
|
---|
166 | (a_pHdr)->bReserved = 0; \
|
---|
167 | (a_pHdr)->cParms = (a_cParameters); \
|
---|
168 | } while (0)
|
---|
169 |
|
---|
170 | /**
|
---|
171 | * Initialize a HGCM header (VBGLIOCHGCMCALL) for a non-timed call, custom size.
|
---|
172 | *
|
---|
173 | * This is usually only needed when appending page lists to the call.
|
---|
174 | *
|
---|
175 | * @param a_pHdr The header to initalize.
|
---|
176 | * @param a_idClient The client connection ID to call thru.
|
---|
177 | * @param a_idFunction The function we're calling
|
---|
178 | * @param a_cParameters Number of parameters.
|
---|
179 | * @param a_cbReq The request size.
|
---|
180 | */
|
---|
181 | # define VBGL_HGCM_HDR_INIT_EX(a_pHdr, a_idClient, a_idFunction, a_cParameters, a_cbReq) \
|
---|
182 | do { \
|
---|
183 | Assert((a_cbReq) >= sizeof(VBGLIOCHGCMCALL) + (a_cParameters) * sizeof(HGCMFunctionParameter)); \
|
---|
184 | VBGLREQHDR_INIT_EX(&(a_pHdr)->Hdr, (a_cbReq), (a_cbReq)); \
|
---|
185 | (a_pHdr)->u32ClientID = (a_idClient); \
|
---|
186 | (a_pHdr)->u32Function = (a_idFunction); \
|
---|
187 | (a_pHdr)->cMsTimeout = RT_INDEFINITE_WAIT; \
|
---|
188 | (a_pHdr)->fInterruptible = true; \
|
---|
189 | (a_pHdr)->bReserved = 0; \
|
---|
190 | (a_pHdr)->cParms = (a_cParameters); \
|
---|
191 | } while (0)
|
---|
192 |
|
---|
193 | /**
|
---|
194 | * Initialize a HGCM header (VBGLIOCHGCMCALL), with timeout (interruptible).
|
---|
195 | *
|
---|
196 | * @param a_pHdr The header to initalize.
|
---|
197 | * @param a_idClient The client connection ID to call thru.
|
---|
198 | * @param a_idFunction The function we're calling
|
---|
199 | * @param a_cParameters Number of parameters.
|
---|
200 | * @param a_cMsTimeout The timeout in milliseconds.
|
---|
201 | */
|
---|
202 | # define VBGL_HGCM_HDR_INIT_TIMED(a_pHdr, a_idClient, a_idFunction, a_cParameters, a_cMsTimeout) \
|
---|
203 | do { \
|
---|
204 | VBGLREQHDR_INIT_EX(&(a_pHdr)->Hdr, \
|
---|
205 | sizeof(VBGLIOCHGCMCALL) + (a_cParameters) * sizeof(HGCMFunctionParameter), \
|
---|
206 | sizeof(VBGLIOCHGCMCALL) + (a_cParameters) * sizeof(HGCMFunctionParameter)); \
|
---|
207 | (a_pHdr)->u32ClientID = (a_idClient); \
|
---|
208 | (a_pHdr)->u32Function = (a_idFunction); \
|
---|
209 | (a_pHdr)->cMsTimeout = (a_cMsTimeout); \
|
---|
210 | (a_pHdr)->fInterruptible = true; \
|
---|
211 | (a_pHdr)->bReserved = 0; \
|
---|
212 | (a_pHdr)->cParms = (a_cParameters); \
|
---|
213 | } while (0)
|
---|
214 |
|
---|
215 | /** Get the pointer to the first HGCM parameter. */
|
---|
216 | # define VBGL_HGCM_GET_CALL_PARMS(a_pInfo) ( (HGCMFunctionParameter *)((uint8_t *)(a_pInfo) + sizeof(VBGLIOCHGCMCALL)) )
|
---|
217 | /** Get the pointer to the first HGCM parameter in a 32-bit request. */
|
---|
218 | # define VBGL_HGCM_GET_CALL_PARMS32(a_pInfo) ( (HGCMFunctionParameter32 *)((uint8_t *)(a_pInfo) + sizeof(VBGLIOCHGCMCALL)) )
|
---|
219 |
|
---|
220 |
|
---|
221 | /**
|
---|
222 | * Mouse event noticification callback function.
|
---|
223 | * @param pvUser Argument given when setting the callback.
|
---|
224 | */
|
---|
225 | typedef DECLCALLBACK(void) FNVBOXGUESTMOUSENOTIFY(void *pvUser);
|
---|
226 | /** Pointer to a mouse event notification callback function. */
|
---|
227 | typedef FNVBOXGUESTMOUSENOTIFY *PFNVBOXGUESTMOUSENOTIFY; /**< @todo fix type prefix */
|
---|
228 |
|
---|
229 | /** @} */
|
---|
230 |
|
---|
231 | #endif
|
---|
232 |
|
---|