VirtualBox

source: vbox/trunk/include/VBox/VBoxGuestCoreTypes.h@ 103224

Last change on this file since 103224 was 98103, checked in by vboxsync, 21 months ago

Copyright year updates by scm.

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