1 | /** @file
|
---|
2 | * VBoxGuest - VirtualBox Guest Additions interface.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2009 Sun Microsystems, Inc.
|
---|
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 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
26 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
27 | * additional information or have any questions.
|
---|
28 | */
|
---|
29 |
|
---|
30 | #ifndef ___VBox_VBoxGuest_h
|
---|
31 | #define ___VBox_VBoxGuest_h
|
---|
32 |
|
---|
33 | #include <iprt/cdefs.h>
|
---|
34 | #include <iprt/types.h>
|
---|
35 | #ifdef IN_RING3
|
---|
36 | # include <iprt/stdarg.h>
|
---|
37 | #endif
|
---|
38 | #include <iprt/assert.h>
|
---|
39 | #include <VBox/err.h>
|
---|
40 | #include <VBox/ostypes.h>
|
---|
41 |
|
---|
42 | /*******************************************************************************
|
---|
43 | * Defined Constants And Macros *
|
---|
44 | *******************************************************************************/
|
---|
45 |
|
---|
46 | /** @todo The following is a temporary fix for the problem of accessing
|
---|
47 | hypervisor pointers from within guest additions */
|
---|
48 |
|
---|
49 | /** Hypervisor linear pointer size type */
|
---|
50 | typedef RTGCPTR32 VMMDEVHYPPTR32;
|
---|
51 | typedef RTGCPTR64 VMMDEVHYPPTR64;
|
---|
52 | /** Hypervisor physical pointer size type */
|
---|
53 | typedef RTGCPHYS32 VMMDEVHYPPHYS32;
|
---|
54 | typedef RTGCPHYS64 VMMDEVHYPPHYS64;
|
---|
55 |
|
---|
56 | #if defined(VBOX_WITH_64_BITS_GUESTS) && ARCH_BITS == 64
|
---|
57 | # define VMMDEVHYPPTR VMMDEVHYPPTR64
|
---|
58 | # define VMMDEVHYPPHYS VMMDEVHYPPHYS64
|
---|
59 | # else
|
---|
60 | # define VMMDEVHYPPTR VMMDEVHYPPTR32
|
---|
61 | # define VMMDEVHYPPHYS VMMDEVHYPPHYS32
|
---|
62 | #endif
|
---|
63 |
|
---|
64 | #if defined(RT_OS_LINUX) && !defined(VBOX_WITH_COMMON_VBOXGUEST_ON_LINUX)
|
---|
65 | /** The support device name. */
|
---|
66 | # define VBOXGUEST_DEVICE_NAME "/dev/vboxadd"
|
---|
67 | /** The support device name of the user accessible device node. */
|
---|
68 | # define VBOXGUEST_USER_DEVICE_NAME "/dev/vboxuser"
|
---|
69 |
|
---|
70 | #elif defined(RT_OS_OS2)
|
---|
71 | /** The support device name. */
|
---|
72 | # define VBOXGUEST_DEVICE_NAME "\\Dev\\VBoxGst$"
|
---|
73 | /** The support device name of the user accessible device node. */
|
---|
74 | # define VBOXGUEST_USER_DEVICE_NAME "\\Dev\\VBoxGst$"
|
---|
75 |
|
---|
76 | #elif defined(RT_OS_WINDOWS)
|
---|
77 | /** The support service name. */
|
---|
78 | # define VBOXGUEST_SERVICE_NAME "VBoxGuest"
|
---|
79 | /** Win32 device name. */
|
---|
80 | # define VBOXGUEST_DEVICE_NAME "\\\\.\\VBoxGuest"
|
---|
81 | /** The support device name of the user accessible device node. */
|
---|
82 | # define VBOXGUEST_USER_DEVICE_NAME "\\\\.\\VBoxGuest"
|
---|
83 | /** Global name for Win2k+ */
|
---|
84 | # define VBOXGUEST_DEVICE_NAME_GLOBAL "\\\\.\\Global\\VBoxGuest"
|
---|
85 | /** Win32 driver name */
|
---|
86 | # define VBOXGUEST_DEVICE_NAME_NT L"\\Device\\VBoxGuest"
|
---|
87 | /** device name */
|
---|
88 | # define VBOXGUEST_DEVICE_NAME_DOS L"\\DosDevices\\VBoxGuest"
|
---|
89 |
|
---|
90 | #else /* PORTME */
|
---|
91 | /** The support device name. */
|
---|
92 | # define VBOXGUEST_DEVICE_NAME "/dev/vboxguest"
|
---|
93 | /** The support device name of the user accessible device node. */
|
---|
94 | # if defined(RT_OS_LINUX)
|
---|
95 | # define VBOXGUEST_USER_DEVICE_NAME "/dev/vboxuser"
|
---|
96 | # else
|
---|
97 | # define VBOXGUEST_USER_DEVICE_NAME "/dev/vboxguest"
|
---|
98 | # endif
|
---|
99 |
|
---|
100 | #endif
|
---|
101 |
|
---|
102 | /** VirtualBox vendor ID */
|
---|
103 | #define VBOX_PCI_VENDORID (0x80ee)
|
---|
104 |
|
---|
105 | /** VMMDev PCI card identifiers */
|
---|
106 | #define VMMDEV_VENDORID VBOX_PCI_VENDORID
|
---|
107 | #define VMMDEV_DEVICEID (0xcafe)
|
---|
108 |
|
---|
109 | /** VirtualBox graphics card identifiers */
|
---|
110 | #define VBOX_VENDORID VBOX_PCI_VENDORID
|
---|
111 | #define VBOX_VESA_VENDORID VBOX_PCI_VENDORID
|
---|
112 | #define VBOX_DEVICEID (0xbeef)
|
---|
113 | #define VBOX_VESA_DEVICEID (0xbeef)
|
---|
114 |
|
---|
115 | /**
|
---|
116 | * VBoxGuest port definitions
|
---|
117 | * @{
|
---|
118 | */
|
---|
119 |
|
---|
120 | /** guest can (== wants to) handle absolute coordinates */
|
---|
121 | #define VBOXGUEST_MOUSE_GUEST_CAN_ABSOLUTE RT_BIT(0)
|
---|
122 | /** host can (== wants to) send absolute coordinates */
|
---|
123 | #define VBOXGUEST_MOUSE_HOST_CAN_ABSOLUTE RT_BIT(1)
|
---|
124 | /** guest can *NOT* switch to software cursor and therefore depends on the host cursor */
|
---|
125 | #define VBOXGUEST_MOUSE_GUEST_NEEDS_HOST_CURSOR RT_BIT(2)
|
---|
126 | /** host does NOT provide support for drawing the cursor itself (e.g. L4 console) */
|
---|
127 | #define VBOXGUEST_MOUSE_HOST_CANNOT_HWPOINTER RT_BIT(3)
|
---|
128 | /** The guest can read VMMDev events to find out about pointer movement */
|
---|
129 | #define VBOXGUEST_MOUSE_GUEST_USES_VMMDEV RT_BIT(4)
|
---|
130 |
|
---|
131 | /** fictive start address of the hypervisor physical memory for MmMapIoSpace */
|
---|
132 | #define HYPERVISOR_PHYSICAL_START 0xf8000000
|
---|
133 |
|
---|
134 | /*
|
---|
135 | * VMMDev Generic Request Interface
|
---|
136 | */
|
---|
137 |
|
---|
138 | /** port for generic request interface */
|
---|
139 | #define PORT_VMMDEV_REQUEST_OFFSET 0
|
---|
140 |
|
---|
141 | /** Current version of the VMMDev interface.
|
---|
142 | *
|
---|
143 | * Additions are allowed to work only if
|
---|
144 | * additions_major == vmmdev_current && additions_minor <= vmmdev_current.
|
---|
145 | * Additions version is reported to host (VMMDev) by VMMDevReq_ReportGuestInfo.
|
---|
146 | *
|
---|
147 | * @remark These defines also live in the 16-bit and assembly versions of this header.
|
---|
148 | */
|
---|
149 | #define VMMDEV_VERSION 0x00010004
|
---|
150 | #define VMMDEV_VERSION_MAJOR (VMMDEV_VERSION >> 16)
|
---|
151 | #define VMMDEV_VERSION_MINOR (VMMDEV_VERSION & 0xffff)
|
---|
152 |
|
---|
153 | /* Maximum request packet size */
|
---|
154 | #define VMMDEV_MAX_VMMDEVREQ_SIZE _1M
|
---|
155 |
|
---|
156 | /**
|
---|
157 | * VMMDev request types.
|
---|
158 | * @note when updating this, adjust vmmdevGetRequestSize() as well
|
---|
159 | */
|
---|
160 | typedef enum
|
---|
161 | {
|
---|
162 | VMMDevReq_InvalidRequest = 0,
|
---|
163 | VMMDevReq_GetMouseStatus = 1,
|
---|
164 | VMMDevReq_SetMouseStatus = 2,
|
---|
165 | VMMDevReq_SetPointerShape = 3,
|
---|
166 | /** @todo implement on host side */
|
---|
167 | VMMDevReq_GetHostVersion = 4,
|
---|
168 | VMMDevReq_Idle = 5,
|
---|
169 | VMMDevReq_GetHostTime = 10,
|
---|
170 | VMMDevReq_GetHypervisorInfo = 20,
|
---|
171 | VMMDevReq_SetHypervisorInfo = 21,
|
---|
172 | VMMDevReq_SetPowerStatus = 30,
|
---|
173 | VMMDevReq_AcknowledgeEvents = 41,
|
---|
174 | VMMDevReq_CtlGuestFilterMask = 42,
|
---|
175 | VMMDevReq_ReportGuestInfo = 50,
|
---|
176 | VMMDevReq_GetDisplayChangeRequest = 51,
|
---|
177 | VMMDevReq_VideoModeSupported = 52,
|
---|
178 | VMMDevReq_GetHeightReduction = 53,
|
---|
179 | VMMDevReq_GetDisplayChangeRequest2 = 54,
|
---|
180 | VMMDevReq_ReportGuestCapabilities = 55,
|
---|
181 | VMMDevReq_SetGuestCapabilities = 56,
|
---|
182 | #ifdef VBOX_WITH_HGCM
|
---|
183 | VMMDevReq_HGCMConnect = 60,
|
---|
184 | VMMDevReq_HGCMDisconnect = 61,
|
---|
185 | #ifdef VBOX_WITH_64_BITS_GUESTS
|
---|
186 | VMMDevReq_HGCMCall32 = 62,
|
---|
187 | VMMDevReq_HGCMCall64 = 63,
|
---|
188 | #else
|
---|
189 | VMMDevReq_HGCMCall = 62,
|
---|
190 | #endif /* VBOX_WITH_64_BITS_GUESTS */
|
---|
191 | VMMDevReq_HGCMCancel = 64,
|
---|
192 | #endif
|
---|
193 | VMMDevReq_VideoAccelEnable = 70,
|
---|
194 | VMMDevReq_VideoAccelFlush = 71,
|
---|
195 | VMMDevReq_VideoSetVisibleRegion = 72,
|
---|
196 | VMMDevReq_GetSeamlessChangeRequest = 73,
|
---|
197 | VMMDevReq_QueryCredentials = 100,
|
---|
198 | VMMDevReq_ReportCredentialsJudgement = 101,
|
---|
199 | VMMDevReq_ReportGuestStats = 110,
|
---|
200 | VMMDevReq_GetMemBalloonChangeRequest = 111,
|
---|
201 | VMMDevReq_GetStatisticsChangeRequest = 112,
|
---|
202 | VMMDevReq_ChangeMemBalloon = 113,
|
---|
203 | VMMDevReq_GetVRDPChangeRequest = 150,
|
---|
204 | VMMDevReq_LogString = 200,
|
---|
205 | VMMDevReq_SizeHack = 0x7fffffff
|
---|
206 | } VMMDevRequestType;
|
---|
207 |
|
---|
208 | #ifdef VBOX_WITH_64_BITS_GUESTS
|
---|
209 | /*
|
---|
210 | * Constants and structures are redefined for the guest.
|
---|
211 | *
|
---|
212 | * Host code MUST always use either *32 or *64 variant explicitely.
|
---|
213 | * Host source code will use VBOX_HGCM_HOST_CODE define to catch undefined
|
---|
214 | * data types and constants.
|
---|
215 | *
|
---|
216 | * This redefinition means that the new additions builds will use
|
---|
217 | * the *64 or *32 variants depending on the current architecture bit count (ARCH_BITS).
|
---|
218 | */
|
---|
219 | # ifndef VBOX_HGCM_HOST_CODE
|
---|
220 | # if ARCH_BITS == 64
|
---|
221 | # define VMMDevReq_HGCMCall VMMDevReq_HGCMCall64
|
---|
222 | # elif ARCH_BITS == 32
|
---|
223 | # define VMMDevReq_HGCMCall VMMDevReq_HGCMCall32
|
---|
224 | # else
|
---|
225 | # error "Unsupported ARCH_BITS"
|
---|
226 | # endif
|
---|
227 | # endif /* !VBOX_HGCM_HOST_CODE */
|
---|
228 | #endif /* VBOX_WITH_64_BITS_GUESTS */
|
---|
229 |
|
---|
230 | /** Version of VMMDevRequestHeader structure. */
|
---|
231 | #define VMMDEV_REQUEST_HEADER_VERSION (0x10001)
|
---|
232 |
|
---|
233 | #pragma pack(4)
|
---|
234 | /** generic VMMDev request header */
|
---|
235 | typedef struct
|
---|
236 | {
|
---|
237 | /** size of the structure in bytes (including body). Filled by caller */
|
---|
238 | uint32_t size;
|
---|
239 | /** version of the structure. Filled by caller */
|
---|
240 | uint32_t version;
|
---|
241 | /** type of the request */
|
---|
242 | VMMDevRequestType requestType;
|
---|
243 | /** return code. Filled by VMMDev */
|
---|
244 | int32_t rc;
|
---|
245 | /** reserved fields */
|
---|
246 | uint32_t reserved1;
|
---|
247 | uint32_t reserved2;
|
---|
248 | } VMMDevRequestHeader;
|
---|
249 | AssertCompileSize(VMMDevRequestHeader, 24);
|
---|
250 |
|
---|
251 | /** mouse status request structure */
|
---|
252 | typedef struct
|
---|
253 | {
|
---|
254 | /** header */
|
---|
255 | VMMDevRequestHeader header;
|
---|
256 | /** mouse feature mask */
|
---|
257 | uint32_t mouseFeatures;
|
---|
258 | /** mouse x position */
|
---|
259 | uint32_t pointerXPos;
|
---|
260 | /** mouse y position */
|
---|
261 | uint32_t pointerYPos;
|
---|
262 | } VMMDevReqMouseStatus;
|
---|
263 |
|
---|
264 | /** Note VBOX_MOUSE_POINTER_* flags are used in guest video driver,
|
---|
265 | * values must be <= 0x8000 and must not be changed.
|
---|
266 | */
|
---|
267 |
|
---|
268 | /** pointer is visible */
|
---|
269 | #define VBOX_MOUSE_POINTER_VISIBLE (0x0001)
|
---|
270 | /** pointer has alpha channel */
|
---|
271 | #define VBOX_MOUSE_POINTER_ALPHA (0x0002)
|
---|
272 | /** pointerData contains new pointer shape */
|
---|
273 | #define VBOX_MOUSE_POINTER_SHAPE (0x0004)
|
---|
274 |
|
---|
275 | /** mouse pointer shape/visibility change request */
|
---|
276 | typedef struct
|
---|
277 | {
|
---|
278 | /** header */
|
---|
279 | VMMDevRequestHeader header;
|
---|
280 | /** VBOX_MOUSE_POINTER_* bit flags */
|
---|
281 | uint32_t fFlags;
|
---|
282 | /** x coordinate of hot spot */
|
---|
283 | uint32_t xHot;
|
---|
284 | /** y coordinate of hot spot */
|
---|
285 | uint32_t yHot;
|
---|
286 | /** width of the pointer in pixels */
|
---|
287 | uint32_t width;
|
---|
288 | /** height of the pointer in scanlines */
|
---|
289 | uint32_t height;
|
---|
290 | /** Pointer data.
|
---|
291 | *
|
---|
292 | ****
|
---|
293 | * The data consists of 1 bpp AND mask followed by 32 bpp XOR (color) mask.
|
---|
294 | *
|
---|
295 | * For pointers without alpha channel the XOR mask pixels are 32 bit values: (lsb)BGR0(msb).
|
---|
296 | * For pointers with alpha channel the XOR mask consists of (lsb)BGRA(msb) 32 bit values.
|
---|
297 | *
|
---|
298 | * Guest driver must create the AND mask for pointers with alpha channel, so if host does not
|
---|
299 | * support alpha, the pointer could be displayed as a normal color pointer. The AND mask can
|
---|
300 | * be constructed from alpha values. For example alpha value >= 0xf0 means bit 0 in the AND mask.
|
---|
301 | *
|
---|
302 | * The AND mask is 1 bpp bitmap with byte aligned scanlines. Size of AND mask,
|
---|
303 | * therefore, is cbAnd = (width + 7) / 8 * height. The padding bits at the
|
---|
304 | * end of any scanline are undefined.
|
---|
305 | *
|
---|
306 | * The XOR mask follows the AND mask on the next 4 bytes aligned offset:
|
---|
307 | * uint8_t *pXor = pAnd + (cbAnd + 3) & ~3
|
---|
308 | * Bytes in the gap between the AND and the XOR mask are undefined.
|
---|
309 | * XOR mask scanlines have no gap between them and size of XOR mask is:
|
---|
310 | * cXor = width * 4 * height.
|
---|
311 | ****
|
---|
312 | *
|
---|
313 | * Preallocate 4 bytes for accessing actual data as p->pointerData
|
---|
314 | */
|
---|
315 | char pointerData[4];
|
---|
316 | } VMMDevReqMousePointer;
|
---|
317 |
|
---|
318 | /** string log request structure */
|
---|
319 | typedef struct
|
---|
320 | {
|
---|
321 | /** header */
|
---|
322 | VMMDevRequestHeader header;
|
---|
323 | /** variable length string data */
|
---|
324 | char szString[1];
|
---|
325 | } VMMDevReqLogString;
|
---|
326 |
|
---|
327 | /** host version request structure */
|
---|
328 | typedef struct
|
---|
329 | {
|
---|
330 | /** header */
|
---|
331 | VMMDevRequestHeader header;
|
---|
332 | /** major version */
|
---|
333 | uint32_t major;
|
---|
334 | /** minor version */
|
---|
335 | uint32_t minor;
|
---|
336 | /** build number */
|
---|
337 | uint32_t build;
|
---|
338 | } VMMDevReqHostVersion;
|
---|
339 |
|
---|
340 | /** guest capabilites structure */
|
---|
341 | typedef struct
|
---|
342 | {
|
---|
343 | /** header */
|
---|
344 | VMMDevRequestHeader header;
|
---|
345 | /** capabilities (VMMDEV_GUEST_*) */
|
---|
346 | uint32_t caps;
|
---|
347 | } VMMDevReqGuestCapabilities;
|
---|
348 |
|
---|
349 | /** guest capabilites structure */
|
---|
350 | typedef struct
|
---|
351 | {
|
---|
352 | /** header */
|
---|
353 | VMMDevRequestHeader header;
|
---|
354 | /** mask of capabilities to be added */
|
---|
355 | uint32_t u32OrMask;
|
---|
356 | /** mask of capabilities to be removed */
|
---|
357 | uint32_t u32NotMask;
|
---|
358 | } VMMDevReqGuestCapabilities2;
|
---|
359 |
|
---|
360 | /** idle request structure */
|
---|
361 | typedef struct
|
---|
362 | {
|
---|
363 | /** header */
|
---|
364 | VMMDevRequestHeader header;
|
---|
365 | } VMMDevReqIdle;
|
---|
366 |
|
---|
367 | /** host time request structure */
|
---|
368 | typedef struct
|
---|
369 | {
|
---|
370 | /** header */
|
---|
371 | VMMDevRequestHeader header;
|
---|
372 | /** time in milliseconds since unix epoch. Filled by VMMDev. */
|
---|
373 | uint64_t time;
|
---|
374 | } VMMDevReqHostTime;
|
---|
375 |
|
---|
376 | /** hypervisor info structure */
|
---|
377 | typedef struct
|
---|
378 | {
|
---|
379 | /** header */
|
---|
380 | VMMDevRequestHeader header;
|
---|
381 | /** guest virtual address of proposed hypervisor start */
|
---|
382 | /** TODO: Make this 64-bit compatible */
|
---|
383 | VMMDEVHYPPTR32 hypervisorStart;
|
---|
384 | /** hypervisor size in bytes */
|
---|
385 | uint32_t hypervisorSize;
|
---|
386 | } VMMDevReqHypervisorInfo;
|
---|
387 |
|
---|
388 | /** system power requests */
|
---|
389 | typedef enum
|
---|
390 | {
|
---|
391 | VMMDevPowerState_Invalid = 0,
|
---|
392 | VMMDevPowerState_Pause = 1,
|
---|
393 | VMMDevPowerState_PowerOff = 2,
|
---|
394 | VMMDevPowerState_SaveState = 3,
|
---|
395 | VMMDevPowerState_SizeHack = 0x7fffffff
|
---|
396 | } VMMDevPowerState;
|
---|
397 |
|
---|
398 | /** system power status structure */
|
---|
399 | typedef struct
|
---|
400 | {
|
---|
401 | /** header */
|
---|
402 | VMMDevRequestHeader header;
|
---|
403 | /** power state request */
|
---|
404 | VMMDevPowerState powerState;
|
---|
405 | } VMMDevPowerStateRequest;
|
---|
406 |
|
---|
407 | /** pending events structure */
|
---|
408 | typedef struct
|
---|
409 | {
|
---|
410 | /** header */
|
---|
411 | VMMDevRequestHeader header;
|
---|
412 | /** pending event bitmap */
|
---|
413 | uint32_t events;
|
---|
414 | } VMMDevEvents;
|
---|
415 |
|
---|
416 | /** guest filter mask control */
|
---|
417 | typedef struct
|
---|
418 | {
|
---|
419 | /** header */
|
---|
420 | VMMDevRequestHeader header;
|
---|
421 | /** mask of events to be added to filter */
|
---|
422 | uint32_t u32OrMask;
|
---|
423 | /** mask of events to be removed from filter */
|
---|
424 | uint32_t u32NotMask;
|
---|
425 | } VMMDevCtlGuestFilterMask;
|
---|
426 |
|
---|
427 | /** guest information structure */
|
---|
428 | typedef struct VBoxGuestInfo
|
---|
429 | {
|
---|
430 | /** The VMMDev interface version expected by additions. */
|
---|
431 | uint32_t additionsVersion;
|
---|
432 | /** guest OS type */
|
---|
433 | VBOXOSTYPE osType;
|
---|
434 | /** @todo */
|
---|
435 | } VBoxGuestInfo;
|
---|
436 |
|
---|
437 | /** guest information structure */
|
---|
438 | typedef struct
|
---|
439 | {
|
---|
440 | /** header */
|
---|
441 | VMMDevRequestHeader header;
|
---|
442 | /** Guest information. */
|
---|
443 | VBoxGuestInfo guestInfo;
|
---|
444 | } VMMDevReportGuestInfo;
|
---|
445 |
|
---|
446 | /** guest statistics values */
|
---|
447 | #define VBOX_GUEST_STAT_CPU_LOAD_IDLE RT_BIT(0)
|
---|
448 | #define VBOX_GUEST_STAT_CPU_LOAD_KERNEL RT_BIT(1)
|
---|
449 | #define VBOX_GUEST_STAT_CPU_LOAD_USER RT_BIT(2)
|
---|
450 | #define VBOX_GUEST_STAT_THREADS RT_BIT(3)
|
---|
451 | #define VBOX_GUEST_STAT_PROCESSES RT_BIT(4)
|
---|
452 | #define VBOX_GUEST_STAT_HANDLES RT_BIT(5)
|
---|
453 | #define VBOX_GUEST_STAT_MEMORY_LOAD RT_BIT(6)
|
---|
454 | #define VBOX_GUEST_STAT_PHYS_MEM_TOTAL RT_BIT(7)
|
---|
455 | #define VBOX_GUEST_STAT_PHYS_MEM_AVAIL RT_BIT(8)
|
---|
456 | #define VBOX_GUEST_STAT_PHYS_MEM_BALLOON RT_BIT(9)
|
---|
457 | #define VBOX_GUEST_STAT_MEM_COMMIT_TOTAL RT_BIT(10)
|
---|
458 | #define VBOX_GUEST_STAT_MEM_KERNEL_TOTAL RT_BIT(11)
|
---|
459 | #define VBOX_GUEST_STAT_MEM_KERNEL_PAGED RT_BIT(12)
|
---|
460 | #define VBOX_GUEST_STAT_MEM_KERNEL_NONPAGED RT_BIT(13)
|
---|
461 | #define VBOX_GUEST_STAT_MEM_SYSTEM_CACHE RT_BIT(14)
|
---|
462 | #define VBOX_GUEST_STAT_PAGE_FILE_SIZE RT_BIT(15)
|
---|
463 |
|
---|
464 |
|
---|
465 | /** guest statistics structure */
|
---|
466 | typedef struct VBoxGuestStatistics
|
---|
467 | {
|
---|
468 | /** Virtual CPU id */
|
---|
469 | uint32_t u32CpuId;
|
---|
470 | /** Reported statistics */
|
---|
471 | uint32_t u32StatCaps;
|
---|
472 | /** Idle CPU load (0-100) for last interval */
|
---|
473 | uint32_t u32CpuLoad_Idle;
|
---|
474 | /** Kernel CPU load (0-100) for last interval */
|
---|
475 | uint32_t u32CpuLoad_Kernel;
|
---|
476 | /** User CPU load (0-100) for last interval */
|
---|
477 | uint32_t u32CpuLoad_User;
|
---|
478 | /** Nr of threads */
|
---|
479 | uint32_t u32Threads;
|
---|
480 | /** Nr of processes */
|
---|
481 | uint32_t u32Processes;
|
---|
482 | /** Nr of handles */
|
---|
483 | uint32_t u32Handles;
|
---|
484 | /** Memory load (0-100) */
|
---|
485 | uint32_t u32MemoryLoad;
|
---|
486 | /** Page size of guest system */
|
---|
487 | uint32_t u32PageSize;
|
---|
488 | /** Total physical memory (in 4kb pages) */
|
---|
489 | uint32_t u32PhysMemTotal;
|
---|
490 | /** Available physical memory (in 4kb pages) */
|
---|
491 | uint32_t u32PhysMemAvail;
|
---|
492 | /** Ballooned physical memory (in 4kb pages) */
|
---|
493 | uint32_t u32PhysMemBalloon;
|
---|
494 | /** Total number of committed memory (which is not necessarily in-use) (in 4kb pages) */
|
---|
495 | uint32_t u32MemCommitTotal;
|
---|
496 | /** Total amount of memory used by the kernel (in 4kb pages) */
|
---|
497 | uint32_t u32MemKernelTotal;
|
---|
498 | /** Total amount of paged memory used by the kernel (in 4kb pages) */
|
---|
499 | uint32_t u32MemKernelPaged;
|
---|
500 | /** Total amount of nonpaged memory used by the kernel (in 4kb pages) */
|
---|
501 | uint32_t u32MemKernelNonPaged;
|
---|
502 | /** Total amount of memory used for the system cache (in 4kb pages) */
|
---|
503 | uint32_t u32MemSystemCache;
|
---|
504 | /** Pagefile size (in 4kb pages) */
|
---|
505 | uint32_t u32PageFileSize;
|
---|
506 | } VBoxGuestStatistics;
|
---|
507 |
|
---|
508 | /** guest statistics command structure */
|
---|
509 | typedef struct
|
---|
510 | {
|
---|
511 | /** header */
|
---|
512 | VMMDevRequestHeader header;
|
---|
513 | /** Guest information. */
|
---|
514 | VBoxGuestStatistics guestStats;
|
---|
515 | } VMMDevReportGuestStats;
|
---|
516 |
|
---|
517 | /** memory balloon change request structure */
|
---|
518 | #define VMMDEV_MAX_MEMORY_BALLOON(PhysMemTotal) ((90*PhysMemTotal)/100)
|
---|
519 |
|
---|
520 | typedef struct
|
---|
521 | {
|
---|
522 | /** header */
|
---|
523 | VMMDevRequestHeader header;
|
---|
524 | uint32_t u32BalloonSize; /* balloon size in megabytes */
|
---|
525 | uint32_t u32PhysMemSize; /* guest ram size in megabytes */
|
---|
526 | uint32_t eventAck;
|
---|
527 | } VMMDevGetMemBalloonChangeRequest;
|
---|
528 |
|
---|
529 | /** inflate/deflate memory balloon structure */
|
---|
530 | #define VMMDEV_MEMORY_BALLOON_CHUNK_PAGES (_1M/4096)
|
---|
531 | #define VMMDEV_MEMORY_BALLOON_CHUNK_SIZE (VMMDEV_MEMORY_BALLOON_CHUNK_PAGES*4096)
|
---|
532 |
|
---|
533 | typedef struct
|
---|
534 | {
|
---|
535 | /** header */
|
---|
536 | VMMDevRequestHeader header;
|
---|
537 | uint32_t cPages;
|
---|
538 | uint32_t fInflate; /* true = inflate, false = defalte */
|
---|
539 | /** Physical address (RTGCPHYS) of each page, variable size. */
|
---|
540 | RTGCPHYS aPhysPage[1];
|
---|
541 | } VMMDevChangeMemBalloon;
|
---|
542 |
|
---|
543 | /** guest statistics interval change request structure */
|
---|
544 | typedef struct
|
---|
545 | {
|
---|
546 | /** header */
|
---|
547 | VMMDevRequestHeader header;
|
---|
548 | uint32_t u32StatInterval; /* interval in seconds */
|
---|
549 | uint32_t eventAck;
|
---|
550 | } VMMDevGetStatisticsChangeRequest;
|
---|
551 |
|
---|
552 | /** display change request structure */
|
---|
553 | typedef struct
|
---|
554 | {
|
---|
555 | /** header */
|
---|
556 | VMMDevRequestHeader header;
|
---|
557 | /** horizontal pixel resolution (0 = do not change) */
|
---|
558 | uint32_t xres;
|
---|
559 | /** vertical pixel resolution (0 = do not change) */
|
---|
560 | uint32_t yres;
|
---|
561 | /** bits per pixel (0 = do not change) */
|
---|
562 | uint32_t bpp;
|
---|
563 | /** Flag that the request is an acknowlegement for the VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST.
|
---|
564 | * Values: 0 - just querying, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST - event acknowledged.
|
---|
565 | */
|
---|
566 | uint32_t eventAck;
|
---|
567 | } VMMDevDisplayChangeRequest;
|
---|
568 |
|
---|
569 | typedef struct
|
---|
570 | {
|
---|
571 | /** header */
|
---|
572 | VMMDevRequestHeader header;
|
---|
573 | /** horizontal pixel resolution (0 = do not change) */
|
---|
574 | uint32_t xres;
|
---|
575 | /** vertical pixel resolution (0 = do not change) */
|
---|
576 | uint32_t yres;
|
---|
577 | /** bits per pixel (0 = do not change) */
|
---|
578 | uint32_t bpp;
|
---|
579 | /** Flag that the request is an acknowlegement for the VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST.
|
---|
580 | * Values: 0 - just querying, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST - event acknowledged.
|
---|
581 | */
|
---|
582 | uint32_t eventAck;
|
---|
583 | /** 0 for primary display, 1 for the first secondary, etc. */
|
---|
584 | uint32_t display;
|
---|
585 | } VMMDevDisplayChangeRequest2;
|
---|
586 |
|
---|
587 | /** video mode supported request structure */
|
---|
588 | typedef struct
|
---|
589 | {
|
---|
590 | /** header */
|
---|
591 | VMMDevRequestHeader header;
|
---|
592 | /** horizontal pixel resolution (input) */
|
---|
593 | uint32_t width;
|
---|
594 | /** vertical pixel resolution (input) */
|
---|
595 | uint32_t height;
|
---|
596 | /** bits per pixel (input) */
|
---|
597 | uint32_t bpp;
|
---|
598 | /** supported flag (output) */
|
---|
599 | bool fSupported;
|
---|
600 | } VMMDevVideoModeSupportedRequest;
|
---|
601 |
|
---|
602 | /** video modes height reduction request structure */
|
---|
603 | typedef struct
|
---|
604 | {
|
---|
605 | /** header */
|
---|
606 | VMMDevRequestHeader header;
|
---|
607 | /** height reduction in pixels (output) */
|
---|
608 | uint32_t heightReduction;
|
---|
609 | } VMMDevGetHeightReductionRequest;
|
---|
610 |
|
---|
611 | #define VRDP_EXPERIENCE_LEVEL_ZERO 0 /* Theming disabled. */
|
---|
612 | #define VRDP_EXPERIENCE_LEVEL_LOW 1 /* Full window dragging and desktop wallpaper disabled. */
|
---|
613 | #define VRDP_EXPERIENCE_LEVEL_MEDIUM 2 /* Font smoothing, gradients. */
|
---|
614 | #define VRDP_EXPERIENCE_LEVEL_HIGH 3 /* Animation effects disabled. */
|
---|
615 | #define VRDP_EXPERIENCE_LEVEL_FULL 4 /* Everything enabled. */
|
---|
616 |
|
---|
617 | typedef struct
|
---|
618 | {
|
---|
619 | /** header */
|
---|
620 | VMMDevRequestHeader header;
|
---|
621 | /** Whether VRDP is active or not */
|
---|
622 | uint8_t u8VRDPActive;
|
---|
623 | /** The configured experience level for active VRDP. */
|
---|
624 | uint32_t u32VRDPExperienceLevel;
|
---|
625 | } VMMDevVRDPChangeRequest;
|
---|
626 |
|
---|
627 |
|
---|
628 |
|
---|
629 | #pragma pack()
|
---|
630 |
|
---|
631 | #ifdef VBOX_WITH_HGCM
|
---|
632 |
|
---|
633 | /** HGCM flags.
|
---|
634 | * @{
|
---|
635 | */
|
---|
636 | #define VBOX_HGCM_REQ_DONE (0x1)
|
---|
637 | #define VBOX_HGCM_REQ_CANCELLED (0x2)
|
---|
638 | /** @} */
|
---|
639 |
|
---|
640 | #pragma pack(4)
|
---|
641 | typedef struct _VMMDevHGCMRequestHeader
|
---|
642 | {
|
---|
643 | /** Request header. */
|
---|
644 | VMMDevRequestHeader header;
|
---|
645 |
|
---|
646 | /** HGCM flags. */
|
---|
647 | uint32_t fu32Flags;
|
---|
648 |
|
---|
649 | /** Result code. */
|
---|
650 | int32_t result;
|
---|
651 | } VMMDevHGCMRequestHeader;
|
---|
652 | AssertCompileSize(VMMDevHGCMRequestHeader, 24+8);
|
---|
653 |
|
---|
654 | /** HGCM service location types. */
|
---|
655 | typedef enum
|
---|
656 | {
|
---|
657 | VMMDevHGCMLoc_Invalid = 0,
|
---|
658 | VMMDevHGCMLoc_LocalHost = 1,
|
---|
659 | VMMDevHGCMLoc_LocalHost_Existing = 2,
|
---|
660 | VMMDevHGCMLoc_SizeHack = 0x7fffffff
|
---|
661 | } HGCMServiceLocationType;
|
---|
662 |
|
---|
663 | typedef struct
|
---|
664 | {
|
---|
665 | char achName[128]; /**< This is really szName. */
|
---|
666 | } HGCMServiceLocationHost;
|
---|
667 |
|
---|
668 | typedef struct HGCMSERVICELOCATION
|
---|
669 | {
|
---|
670 | /** Type of the location. */
|
---|
671 | HGCMServiceLocationType type;
|
---|
672 |
|
---|
673 | union
|
---|
674 | {
|
---|
675 | HGCMServiceLocationHost host;
|
---|
676 | } u;
|
---|
677 | } HGCMServiceLocation;
|
---|
678 |
|
---|
679 | typedef struct
|
---|
680 | {
|
---|
681 | /* request header */
|
---|
682 | VMMDevHGCMRequestHeader header;
|
---|
683 |
|
---|
684 | /** IN: Description of service to connect to. */
|
---|
685 | HGCMServiceLocation loc;
|
---|
686 |
|
---|
687 | /** OUT: Client identifier assigned by local instance of HGCM. */
|
---|
688 | uint32_t u32ClientID;
|
---|
689 | } VMMDevHGCMConnect;
|
---|
690 |
|
---|
691 | typedef struct
|
---|
692 | {
|
---|
693 | /* request header */
|
---|
694 | VMMDevHGCMRequestHeader header;
|
---|
695 |
|
---|
696 | /** IN: Client identifier. */
|
---|
697 | uint32_t u32ClientID;
|
---|
698 | } VMMDevHGCMDisconnect;
|
---|
699 |
|
---|
700 | typedef enum
|
---|
701 | {
|
---|
702 | VMMDevHGCMParmType_Invalid = 0,
|
---|
703 | VMMDevHGCMParmType_32bit = 1,
|
---|
704 | VMMDevHGCMParmType_64bit = 2,
|
---|
705 | VMMDevHGCMParmType_PhysAddr = 3,
|
---|
706 | VMMDevHGCMParmType_LinAddr = 4, /**< In and Out */
|
---|
707 | VMMDevHGCMParmType_LinAddr_In = 5, /**< In (read; host<-guest) */
|
---|
708 | VMMDevHGCMParmType_LinAddr_Out = 6, /**< Out (write; host->guest) */
|
---|
709 | VMMDevHGCMParmType_LinAddr_Locked = 7, /**< Locked In and Out */
|
---|
710 | VMMDevHGCMParmType_LinAddr_Locked_In = 8, /**< Locked In (read; host<-guest) */
|
---|
711 | VMMDevHGCMParmType_LinAddr_Locked_Out = 9, /**< Locked Out (write; host->guest) */
|
---|
712 | VMMDevHGCMParmType_SizeHack = 0x7fffffff
|
---|
713 | } HGCMFunctionParameterType;
|
---|
714 |
|
---|
715 | #ifdef VBOX_WITH_64_BITS_GUESTS
|
---|
716 | typedef struct _HGCMFUNCTIONPARAMETER32
|
---|
717 | {
|
---|
718 | HGCMFunctionParameterType type;
|
---|
719 | union
|
---|
720 | {
|
---|
721 | uint32_t value32;
|
---|
722 | uint64_t value64;
|
---|
723 | struct
|
---|
724 | {
|
---|
725 | uint32_t size;
|
---|
726 |
|
---|
727 | union
|
---|
728 | {
|
---|
729 | VMMDEVHYPPHYS32 physAddr;
|
---|
730 | VMMDEVHYPPTR32 linearAddr;
|
---|
731 | } u;
|
---|
732 | } Pointer;
|
---|
733 | } u;
|
---|
734 | #ifdef __cplusplus
|
---|
735 | void SetUInt32(uint32_t u32)
|
---|
736 | {
|
---|
737 | type = VMMDevHGCMParmType_32bit;
|
---|
738 | u.value64 = 0; /* init unused bits to 0 */
|
---|
739 | u.value32 = u32;
|
---|
740 | }
|
---|
741 |
|
---|
742 | int GetUInt32(uint32_t *pu32)
|
---|
743 | {
|
---|
744 | if (type == VMMDevHGCMParmType_32bit)
|
---|
745 | {
|
---|
746 | *pu32 = u.value32;
|
---|
747 | return VINF_SUCCESS;
|
---|
748 | }
|
---|
749 | return VERR_INVALID_PARAMETER;
|
---|
750 | }
|
---|
751 |
|
---|
752 | void SetUInt64(uint64_t u64)
|
---|
753 | {
|
---|
754 | type = VMMDevHGCMParmType_64bit;
|
---|
755 | u.value64 = u64;
|
---|
756 | }
|
---|
757 |
|
---|
758 | int GetUInt64(uint64_t *pu64)
|
---|
759 | {
|
---|
760 | if (type == VMMDevHGCMParmType_64bit)
|
---|
761 | {
|
---|
762 | *pu64 = u.value64;
|
---|
763 | return VINF_SUCCESS;
|
---|
764 | }
|
---|
765 | return VERR_INVALID_PARAMETER;
|
---|
766 | }
|
---|
767 |
|
---|
768 | void SetPtr(void *pv, uint32_t cb)
|
---|
769 | {
|
---|
770 | type = VMMDevHGCMParmType_LinAddr;
|
---|
771 | u.Pointer.size = cb;
|
---|
772 | u.Pointer.u.linearAddr = (VMMDEVHYPPTR32)(uintptr_t)pv;
|
---|
773 | }
|
---|
774 | #endif
|
---|
775 | } HGCMFunctionParameter32;
|
---|
776 |
|
---|
777 | typedef struct _HGCMFUNCTIONPARAMETER64
|
---|
778 | {
|
---|
779 | HGCMFunctionParameterType type;
|
---|
780 | union
|
---|
781 | {
|
---|
782 | uint32_t value32;
|
---|
783 | uint64_t value64;
|
---|
784 | struct
|
---|
785 | {
|
---|
786 | uint32_t size;
|
---|
787 |
|
---|
788 | union
|
---|
789 | {
|
---|
790 | VMMDEVHYPPHYS64 physAddr;
|
---|
791 | VMMDEVHYPPTR64 linearAddr;
|
---|
792 | } u;
|
---|
793 | } Pointer;
|
---|
794 | } u;
|
---|
795 | #ifdef __cplusplus
|
---|
796 | void SetUInt32(uint32_t u32)
|
---|
797 | {
|
---|
798 | type = VMMDevHGCMParmType_32bit;
|
---|
799 | u.value64 = 0; /* init unused bits to 0 */
|
---|
800 | u.value32 = u32;
|
---|
801 | }
|
---|
802 |
|
---|
803 | int GetUInt32(uint32_t *pu32)
|
---|
804 | {
|
---|
805 | if (type == VMMDevHGCMParmType_32bit)
|
---|
806 | {
|
---|
807 | *pu32 = u.value32;
|
---|
808 | return VINF_SUCCESS;
|
---|
809 | }
|
---|
810 | return VERR_INVALID_PARAMETER;
|
---|
811 | }
|
---|
812 |
|
---|
813 | void SetUInt64(uint64_t u64)
|
---|
814 | {
|
---|
815 | type = VMMDevHGCMParmType_64bit;
|
---|
816 | u.value64 = u64;
|
---|
817 | }
|
---|
818 |
|
---|
819 | int GetUInt64(uint64_t *pu64)
|
---|
820 | {
|
---|
821 | if (type == VMMDevHGCMParmType_64bit)
|
---|
822 | {
|
---|
823 | *pu64 = u.value64;
|
---|
824 | return VINF_SUCCESS;
|
---|
825 | }
|
---|
826 | return VERR_INVALID_PARAMETER;
|
---|
827 | }
|
---|
828 |
|
---|
829 | void SetPtr(void *pv, uint32_t cb)
|
---|
830 | {
|
---|
831 | type = VMMDevHGCMParmType_LinAddr;
|
---|
832 | u.Pointer.size = cb;
|
---|
833 | u.Pointer.u.linearAddr = (uintptr_t)pv;
|
---|
834 | }
|
---|
835 | #endif
|
---|
836 | } HGCMFunctionParameter64;
|
---|
837 | #else /* !VBOX_WITH_64_BITS_GUESTS */
|
---|
838 | typedef struct _HGCMFUNCTIONPARAMETER
|
---|
839 | {
|
---|
840 | HGCMFunctionParameterType type;
|
---|
841 | union
|
---|
842 | {
|
---|
843 | uint32_t value32;
|
---|
844 | uint64_t value64;
|
---|
845 | struct
|
---|
846 | {
|
---|
847 | uint32_t size;
|
---|
848 |
|
---|
849 | union
|
---|
850 | {
|
---|
851 | VMMDEVHYPPHYS32 physAddr;
|
---|
852 | VMMDEVHYPPTR32 linearAddr;
|
---|
853 | } u;
|
---|
854 | } Pointer;
|
---|
855 | } u;
|
---|
856 | #ifdef __cplusplus
|
---|
857 | void SetUInt32(uint32_t u32)
|
---|
858 | {
|
---|
859 | type = VMMDevHGCMParmType_32bit;
|
---|
860 | u.value64 = 0; /* init unused bits to 0 */
|
---|
861 | u.value32 = u32;
|
---|
862 | }
|
---|
863 |
|
---|
864 | int GetUInt32(uint32_t *pu32)
|
---|
865 | {
|
---|
866 | if (type == VMMDevHGCMParmType_32bit)
|
---|
867 | {
|
---|
868 | *pu32 = u.value32;
|
---|
869 | return VINF_SUCCESS;
|
---|
870 | }
|
---|
871 | return VERR_INVALID_PARAMETER;
|
---|
872 | }
|
---|
873 |
|
---|
874 | void SetUInt64(uint64_t u64)
|
---|
875 | {
|
---|
876 | type = VMMDevHGCMParmType_64bit;
|
---|
877 | u.value64 = u64;
|
---|
878 | }
|
---|
879 |
|
---|
880 | int GetUInt64(uint64_t *pu64)
|
---|
881 | {
|
---|
882 | if (type == VMMDevHGCMParmType_64bit)
|
---|
883 | {
|
---|
884 | *pu64 = u.value64;
|
---|
885 | return VINF_SUCCESS;
|
---|
886 | }
|
---|
887 | return VERR_INVALID_PARAMETER;
|
---|
888 | }
|
---|
889 |
|
---|
890 | void SetPtr(void *pv, uint32_t cb)
|
---|
891 | {
|
---|
892 | type = VMMDevHGCMParmType_LinAddr;
|
---|
893 | u.Pointer.size = cb;
|
---|
894 | u.Pointer.u.linearAddr = (uintptr_t)pv;
|
---|
895 | }
|
---|
896 | #endif
|
---|
897 | } HGCMFunctionParameter;
|
---|
898 | #endif /* !VBOX_WITH_64_BITS_GUESTS */
|
---|
899 |
|
---|
900 |
|
---|
901 | #ifdef VBOX_WITH_64_BITS_GUESTS
|
---|
902 | /* Redefine the structure type for the guest code. */
|
---|
903 | # ifndef VBOX_HGCM_HOST_CODE
|
---|
904 | # if ARCH_BITS == 64
|
---|
905 | # define HGCMFunctionParameter HGCMFunctionParameter64
|
---|
906 | # elif ARCH_BITS == 32
|
---|
907 | # define HGCMFunctionParameter HGCMFunctionParameter32
|
---|
908 | # else
|
---|
909 | # error "Unsupported sizeof (void *)"
|
---|
910 | # endif
|
---|
911 | # endif /* !VBOX_HGCM_HOST_CODE */
|
---|
912 | #endif /* VBOX_WITH_64_BITS_GUESTS */
|
---|
913 |
|
---|
914 | typedef struct
|
---|
915 | {
|
---|
916 | /* request header */
|
---|
917 | VMMDevHGCMRequestHeader header;
|
---|
918 |
|
---|
919 | /** IN: Client identifier. */
|
---|
920 | uint32_t u32ClientID;
|
---|
921 | /** IN: Service function number. */
|
---|
922 | uint32_t u32Function;
|
---|
923 | /** IN: Number of parameters. */
|
---|
924 | uint32_t cParms;
|
---|
925 | /** Parameters follow in form: HGCMFunctionParameter aParms[X]; */
|
---|
926 | } VMMDevHGCMCall;
|
---|
927 | #pragma pack()
|
---|
928 |
|
---|
929 | #define VMMDEV_HGCM_CALL_PARMS(a) ((HGCMFunctionParameter *)((uint8_t *)a + sizeof (VMMDevHGCMCall)))
|
---|
930 | #define VMMDEV_HGCM_CALL_PARMS32(a) ((HGCMFunctionParameter32 *)((uint8_t *)a + sizeof (VMMDevHGCMCall)))
|
---|
931 |
|
---|
932 | #ifdef VBOX_WITH_64_BITS_GUESTS
|
---|
933 | /* Explicit defines for the host code. */
|
---|
934 | # ifdef VBOX_HGCM_HOST_CODE
|
---|
935 | # define VMMDEV_HGCM_CALL_PARMS32(a) ((HGCMFunctionParameter32 *)((uint8_t *)a + sizeof (VMMDevHGCMCall)))
|
---|
936 | # define VMMDEV_HGCM_CALL_PARMS64(a) ((HGCMFunctionParameter64 *)((uint8_t *)a + sizeof (VMMDevHGCMCall)))
|
---|
937 | # endif /* VBOX_HGCM_HOST_CODE */
|
---|
938 | #endif /* VBOX_WITH_64_BITS_GUESTS */
|
---|
939 |
|
---|
940 | #define VBOX_HGCM_MAX_PARMS 32
|
---|
941 |
|
---|
942 | /* The Cancel request is issued using the same physical memory address
|
---|
943 | * as was used for the corresponding initial HGCMCall.
|
---|
944 | */
|
---|
945 | typedef struct
|
---|
946 | {
|
---|
947 | /* request header */
|
---|
948 | VMMDevHGCMRequestHeader header;
|
---|
949 | } VMMDevHGCMCancel;
|
---|
950 |
|
---|
951 | #endif /* VBOX_WITH_HGCM */
|
---|
952 |
|
---|
953 |
|
---|
954 | #define VBVA_F_STATUS_ACCEPTED (0x01)
|
---|
955 | #define VBVA_F_STATUS_ENABLED (0x02)
|
---|
956 |
|
---|
957 | #pragma pack(4)
|
---|
958 |
|
---|
959 | typedef struct _VMMDevVideoAccelEnable
|
---|
960 | {
|
---|
961 | /* request header */
|
---|
962 | VMMDevRequestHeader header;
|
---|
963 |
|
---|
964 | /** 0 - disable, !0 - enable. */
|
---|
965 | uint32_t u32Enable;
|
---|
966 |
|
---|
967 | /** The size of VBVAMEMORY::au8RingBuffer expected by driver.
|
---|
968 | * The host will refuse to enable VBVA if the size is not equal to
|
---|
969 | * VBVA_RING_BUFFER_SIZE.
|
---|
970 | */
|
---|
971 | uint32_t cbRingBuffer;
|
---|
972 |
|
---|
973 | /** Guest initializes the status to 0. Host sets appropriate VBVA_F_STATUS_ flags. */
|
---|
974 | uint32_t fu32Status;
|
---|
975 |
|
---|
976 | } VMMDevVideoAccelEnable;
|
---|
977 |
|
---|
978 | typedef struct _VMMDevVideoAccelFlush
|
---|
979 | {
|
---|
980 | /* request header */
|
---|
981 | VMMDevRequestHeader header;
|
---|
982 |
|
---|
983 | } VMMDevVideoAccelFlush;
|
---|
984 |
|
---|
985 |
|
---|
986 | typedef struct _VMMDevVideoSetVisibleRegion
|
---|
987 | {
|
---|
988 | /* request header */
|
---|
989 | VMMDevRequestHeader header;
|
---|
990 |
|
---|
991 | /** Number of rectangles */
|
---|
992 | uint32_t cRect;
|
---|
993 |
|
---|
994 | /** Rectangle array */
|
---|
995 | RTRECT Rect;
|
---|
996 | } VMMDevVideoSetVisibleRegion;
|
---|
997 |
|
---|
998 |
|
---|
999 | /** Seamless mode */
|
---|
1000 | typedef enum
|
---|
1001 | {
|
---|
1002 | VMMDev_Seamless_Disabled = 0, /* normal mode; entire guest desktop displayed */
|
---|
1003 | VMMDev_Seamless_Visible_Region = 1, /* visible region mode; only top-level guest windows displayed */
|
---|
1004 | VMMDev_Seamless_Host_Window = 2 /* windowed mode; each top-level guest window is represented in a host window */
|
---|
1005 | } VMMDevSeamlessMode;
|
---|
1006 |
|
---|
1007 | typedef struct
|
---|
1008 | {
|
---|
1009 | /** header */
|
---|
1010 | VMMDevRequestHeader header;
|
---|
1011 |
|
---|
1012 | /** New seamless mode */
|
---|
1013 | VMMDevSeamlessMode mode;
|
---|
1014 | /** Flag that the request is an acknowlegement for the VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST.
|
---|
1015 | * Values: 0 - just querying, VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST - event acknowledged.
|
---|
1016 | */
|
---|
1017 | uint32_t eventAck;
|
---|
1018 | } VMMDevSeamlessChangeRequest;
|
---|
1019 |
|
---|
1020 | #pragma pack()
|
---|
1021 |
|
---|
1022 | #pragma pack(1)
|
---|
1023 | /** VBVA command header. */
|
---|
1024 | typedef struct _VBVACMDHDR
|
---|
1025 | {
|
---|
1026 | /** Coordinates of affected rectangle. */
|
---|
1027 | int16_t x;
|
---|
1028 | int16_t y;
|
---|
1029 | uint16_t w;
|
---|
1030 | uint16_t h;
|
---|
1031 | } VBVACMDHDR;
|
---|
1032 | #pragma pack()
|
---|
1033 |
|
---|
1034 | /* The VBVA ring buffer is suitable for transferring large (< 2gb) amount of data.
|
---|
1035 | * For example big bitmaps which do not fit to the buffer.
|
---|
1036 | *
|
---|
1037 | * Guest starts writing to the buffer by initializing a record entry in the
|
---|
1038 | * aRecords queue. VBVA_F_RECORD_PARTIAL indicates that the record is being
|
---|
1039 | * written. As data is written to the ring buffer, the guest increases off32End
|
---|
1040 | * for the record.
|
---|
1041 | *
|
---|
1042 | * The host reads the aRecords on flushes and processes all completed records.
|
---|
1043 | * When host encounters situation when only a partial record presents and
|
---|
1044 | * cbRecord & ~VBVA_F_RECORD_PARTIAL >= VBVA_RING_BUFFER_SIZE - VBVA_RING_BUFFER_THRESHOLD,
|
---|
1045 | * the host fetched all record data and updates off32Head. After that on each flush
|
---|
1046 | * the host continues fetching the data until the record is completed.
|
---|
1047 | *
|
---|
1048 | */
|
---|
1049 |
|
---|
1050 | #define VBVA_RING_BUFFER_SIZE (_4M - _1K)
|
---|
1051 | #define VBVA_RING_BUFFER_THRESHOLD (4 * _1K)
|
---|
1052 |
|
---|
1053 | #define VBVA_MAX_RECORDS (64)
|
---|
1054 |
|
---|
1055 | #define VBVA_F_MODE_ENABLED (0x00000001)
|
---|
1056 | #define VBVA_F_MODE_VRDP (0x00000002)
|
---|
1057 | #define VBVA_F_MODE_VRDP_RESET (0x00000004)
|
---|
1058 | #define VBVA_F_MODE_VRDP_ORDER_MASK (0x00000008)
|
---|
1059 |
|
---|
1060 | #define VBVA_F_RECORD_PARTIAL (0x80000000)
|
---|
1061 |
|
---|
1062 | #pragma pack(1)
|
---|
1063 | typedef struct _VBVARECORD
|
---|
1064 | {
|
---|
1065 | /** The length of the record. Changed by guest. */
|
---|
1066 | uint32_t cbRecord;
|
---|
1067 | } VBVARECORD;
|
---|
1068 |
|
---|
1069 | typedef struct _VBVAMEMORY
|
---|
1070 | {
|
---|
1071 | /** VBVA_F_MODE_* */
|
---|
1072 | uint32_t fu32ModeFlags;
|
---|
1073 |
|
---|
1074 | /** The offset where the data start in the buffer. */
|
---|
1075 | uint32_t off32Data;
|
---|
1076 | /** The offset where next data must be placed in the buffer. */
|
---|
1077 | uint32_t off32Free;
|
---|
1078 |
|
---|
1079 | /** The ring buffer for data. */
|
---|
1080 | uint8_t au8RingBuffer[VBVA_RING_BUFFER_SIZE];
|
---|
1081 |
|
---|
1082 | /** The queue of record descriptions. */
|
---|
1083 | VBVARECORD aRecords[VBVA_MAX_RECORDS];
|
---|
1084 | uint32_t indexRecordFirst;
|
---|
1085 | uint32_t indexRecordFree;
|
---|
1086 |
|
---|
1087 | /* RDP orders supported by the client. The guest reports only them
|
---|
1088 | * and falls back to DIRTY rects for not supported ones.
|
---|
1089 | *
|
---|
1090 | * (1 << VBVA_VRDP_*)
|
---|
1091 | */
|
---|
1092 | uint32_t fu32SupportedOrders;
|
---|
1093 |
|
---|
1094 | } VBVAMEMORY;
|
---|
1095 | #pragma pack()
|
---|
1096 |
|
---|
1097 | /** @} */
|
---|
1098 |
|
---|
1099 |
|
---|
1100 | /**
|
---|
1101 | * VMMDev RAM
|
---|
1102 | * @{
|
---|
1103 | */
|
---|
1104 |
|
---|
1105 | #pragma pack(1)
|
---|
1106 | /** Layout of VMMDEV RAM region that contains information for guest */
|
---|
1107 | typedef struct
|
---|
1108 | {
|
---|
1109 | /** size */
|
---|
1110 | uint32_t u32Size;
|
---|
1111 | /** version */
|
---|
1112 | uint32_t u32Version;
|
---|
1113 |
|
---|
1114 | union {
|
---|
1115 | /** Flag telling that VMMDev set the IRQ and acknowlegment is required */
|
---|
1116 | struct {
|
---|
1117 | bool fHaveEvents;
|
---|
1118 | } V1_04;
|
---|
1119 |
|
---|
1120 | struct {
|
---|
1121 | /** Pending events flags, set by host. */
|
---|
1122 | uint32_t u32HostEvents;
|
---|
1123 | /** Mask of events the guest wants to see, set by guest. */
|
---|
1124 | uint32_t u32GuestEventMask;
|
---|
1125 | } V1_03;
|
---|
1126 | } V;
|
---|
1127 |
|
---|
1128 | VBVAMEMORY vbvaMemory;
|
---|
1129 |
|
---|
1130 | } VMMDevMemory;
|
---|
1131 | #pragma pack()
|
---|
1132 |
|
---|
1133 | /** Version of VMMDevMemory structure. */
|
---|
1134 | #define VMMDEV_MEMORY_VERSION (1)
|
---|
1135 |
|
---|
1136 | /** @} */
|
---|
1137 |
|
---|
1138 |
|
---|
1139 | /**
|
---|
1140 | * VMMDev events.
|
---|
1141 | * @{
|
---|
1142 | */
|
---|
1143 |
|
---|
1144 | /** Host mouse capabilities has been changed. */
|
---|
1145 | #define VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED RT_BIT(0)
|
---|
1146 | /** HGCM event. */
|
---|
1147 | #define VMMDEV_EVENT_HGCM RT_BIT(1)
|
---|
1148 | /** A display change request has been issued. */
|
---|
1149 | #define VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST RT_BIT(2)
|
---|
1150 | /** Credentials are available for judgement. */
|
---|
1151 | #define VMMDEV_EVENT_JUDGE_CREDENTIALS RT_BIT(3)
|
---|
1152 | /** The guest has been restored. */
|
---|
1153 | #define VMMDEV_EVENT_RESTORED RT_BIT(4)
|
---|
1154 | /** Seamless mode state changed */
|
---|
1155 | #define VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST RT_BIT(5)
|
---|
1156 | /** Memory balloon size changed */
|
---|
1157 | #define VMMDEV_EVENT_BALLOON_CHANGE_REQUEST RT_BIT(6)
|
---|
1158 | /** Statistics interval changed */
|
---|
1159 | #define VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST RT_BIT(7)
|
---|
1160 | /** VRDP status changed. */
|
---|
1161 | #define VMMDEV_EVENT_VRDP RT_BIT(8)
|
---|
1162 | /** New mouse position data available */
|
---|
1163 | #define VMMDEV_EVENT_MOUSE_POSITION_CHANGED RT_BIT(9)
|
---|
1164 |
|
---|
1165 | /** @} */
|
---|
1166 |
|
---|
1167 |
|
---|
1168 | #if !defined(IN_RC) && !defined(IN_RING0_AGNOSTIC) && !defined(IPRT_NO_CRT)
|
---|
1169 | /** @name VBoxGuest IOCTL codes and structures.
|
---|
1170 | *
|
---|
1171 | * The range 0..15 is for basic driver communication.
|
---|
1172 | * The range 16..31 is for HGCM communcation.
|
---|
1173 | * The range 32..47 is reserved for future use.
|
---|
1174 | * The range 48..63 is for OS specific communcation.
|
---|
1175 | * The 7th bit is reserved for future hacks.
|
---|
1176 | * The 8th bit is reserved for distinguishing between 32-bit and 64-bit
|
---|
1177 | * processes in future 64-bit guest additions.
|
---|
1178 | *
|
---|
1179 | * While windows IOCTL function number has to start at 2048 and stop at 4096 there
|
---|
1180 | * never was any need to do this for everyone. A simple ((Function) | 0x800) would
|
---|
1181 | * have sufficed. On Linux we're now intruding upon the type field. Fortunately
|
---|
1182 | * this hasn't caused any trouble because the FILE_DEVICE_UNKNOWN value was set
|
---|
1183 | * to 0x22 (if it were 0x2C it would not have worked soo smoothly). The situation
|
---|
1184 | * would've been the same for *BSD and Darwin since they seems to share common
|
---|
1185 | * _IOC() heritage.
|
---|
1186 | *
|
---|
1187 | * However, on good old OS/2 we only have 8-bit handy for the function number. The
|
---|
1188 | * result from using the old IOCTL function numbers her would've been overlapping
|
---|
1189 | * between the two ranges.
|
---|
1190 | *
|
---|
1191 | * To fix this problem and get rid of all the unnecessary windowsy crap that I
|
---|
1192 | * bet was copied from my SUPDRVIOC.h once upon a time (although the concept of
|
---|
1193 | * prefixing macros with the purpose of avoid clashes with system stuff and
|
---|
1194 | * to indicate exactly how owns them seems to have been lost somewhere along
|
---|
1195 | * the way), I've introduced a VBOXGUEST_IOCTL_CODE for defining generic IN/OUT
|
---|
1196 | * IOCtls on new ports of the additions.
|
---|
1197 | *
|
---|
1198 | * @remarks When creating new IOCtl interfaces keep in mind that not all OSes supports
|
---|
1199 | * reporting back the output size. (This got messed up a little bit in VBoxDrv.)
|
---|
1200 | *
|
---|
1201 | * The request size is also a little bit tricky as it's passed as part of the
|
---|
1202 | * request code on unix. The size field is 14 bits on Linux, 12 bits on *BSD,
|
---|
1203 | * 13 bits Darwin, and 8-bits on Solaris. All the BSDs and Darwin kernels
|
---|
1204 | * will make use of the size field, while Linux and Solaris will not. We're of
|
---|
1205 | * course using the size to validate and/or map/lock the request, so it has
|
---|
1206 | * to be valid.
|
---|
1207 | *
|
---|
1208 | * For Solaris we will have to do something special though, 255 isn't
|
---|
1209 | * sufficent for all we need. A 4KB restriction (BSD) is probably not
|
---|
1210 | * too problematic (yet) as a general one.
|
---|
1211 | *
|
---|
1212 | * More info can be found in SUPDRVIOC.h and related sources.
|
---|
1213 | *
|
---|
1214 | * @remarks If adding interfaces that only has input or only has output, some new macros
|
---|
1215 | * needs to be created so the most efficient IOCtl data buffering method can be
|
---|
1216 | * used.
|
---|
1217 | * @{
|
---|
1218 | */
|
---|
1219 | #ifdef RT_ARCH_AMD64
|
---|
1220 | # define VBOXGUEST_IOCTL_FLAG 128
|
---|
1221 | #elif defined(RT_ARCH_X86)
|
---|
1222 | # define VBOXGUEST_IOCTL_FLAG 0
|
---|
1223 | #else
|
---|
1224 | # error "dunno which arch this is!"
|
---|
1225 | #endif
|
---|
1226 |
|
---|
1227 | /** Ring-3 request wrapper for big requests.
|
---|
1228 | *
|
---|
1229 | * This is necessary because the ioctl number scheme on many Unixy OSes (esp. Solaris)
|
---|
1230 | * only allows a relatively small size to be encoded into the request. So, for big
|
---|
1231 | * request this generic form is used instead. */
|
---|
1232 | typedef struct VBGLBIGREQ
|
---|
1233 | {
|
---|
1234 | /** Magic value (VBGLBIGREQ_MAGIC). */
|
---|
1235 | uint32_t u32Magic;
|
---|
1236 | /** The size of the data buffer. */
|
---|
1237 | uint32_t cbData;
|
---|
1238 | /** The user address of the data buffer. */
|
---|
1239 | RTR3PTR pvDataR3;
|
---|
1240 | #if HC_ARCH_BITS == 32
|
---|
1241 | uint32_t u32Padding;
|
---|
1242 | #endif
|
---|
1243 | } VBGLBIGREQ;
|
---|
1244 | /** Pointer to a request wrapper for solaris guests. */
|
---|
1245 | typedef VBGLBIGREQ *PVBGLBIGREQ;
|
---|
1246 | /** Pointer to a const request wrapper for solaris guests. */
|
---|
1247 | typedef const VBGLBIGREQ *PCVBGLBIGREQ;
|
---|
1248 |
|
---|
1249 | /** The VBGLBIGREQ::u32Magic value (Ryuu Murakami). */
|
---|
1250 | #define VBGLBIGREQ_MAGIC 0x19520219
|
---|
1251 |
|
---|
1252 |
|
---|
1253 | #if defined(RT_OS_WINDOWS)
|
---|
1254 | /* @todo Remove IOCTL_CODE later! Integrate it in VBOXGUEST_IOCTL_CODE below. */
|
---|
1255 | /** @todo r=bird: IOCTL_CODE is supposedly defined in some header included by Windows.h or ntddk.h, which is why it wasn't in the #if 0 earlier. See HostDrivers/Support/SUPDrvIOC.h... */
|
---|
1256 | # define IOCTL_CODE(DeviceType, Function, Method, Access, DataSize_ignored) \
|
---|
1257 | ( ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method))
|
---|
1258 | # define VBOXGUEST_IOCTL_CODE_(Function, Size) IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2048 + (Function), METHOD_BUFFERED, FILE_WRITE_ACCESS, 0)
|
---|
1259 | # define VBOXGUEST_IOCTL_STRIP_SIZE_(Code) (Code)
|
---|
1260 |
|
---|
1261 | #elif defined(RT_OS_OS2)
|
---|
1262 | /* No automatic buffering, size not encoded. */
|
---|
1263 | # define VBOXGUEST_IOCTL_CATEGORY 0xc2
|
---|
1264 | # define VBOXGUEST_IOCTL_CODE_(Function, Size) ((unsigned char)(Function))
|
---|
1265 | # define VBOXGUEST_IOCTL_CATEGORY_FAST 0xc3 /**< Also defined in VBoxGuestA-os2.asm. */
|
---|
1266 | # define VBOXGUEST_IOCTL_CODE_FAST_(Function) ((unsigned char)(Function))
|
---|
1267 | # define VBOXGUEST_IOCTL_STRIP_SIZE(Code) (Code)
|
---|
1268 |
|
---|
1269 | #elif defined(RT_OS_SOLARIS)
|
---|
1270 | /* No automatic buffering, size limited to 255 bytes => use VBGLBIGREQ for everything. */
|
---|
1271 | # include <sys/ioccom.h>
|
---|
1272 | # define VBOXGUEST_IOCTL_CODE_(Function, Size) _IOWRN('V', (Function), sizeof(VBGLBIGREQ))
|
---|
1273 | # define VBOXGUEST_IOCTL_CODE_FAST_(Function) _IO( 'V', (Function))
|
---|
1274 | # define VBOXGUEST_IOCTL_STRIP_SIZE(Code) (Code)
|
---|
1275 |
|
---|
1276 | #elif defined(RT_OS_LINUX)
|
---|
1277 | /* No automatic buffering, size limited to 16KB. */
|
---|
1278 | # include <linux/ioctl.h>
|
---|
1279 | # define VBOXGUEST_IOCTL_CODE_(Function, Size) _IOC(_IOC_READ|_IOC_WRITE, 'V', (Function), (Size))
|
---|
1280 | # define VBOXGUEST_IOCTL_CODE_FAST_(Function) _IO( 'V', (Function))
|
---|
1281 | # define VBOXGUEST_IOCTL_STRIP_SIZE(Code) VBOXGUEST_IOCTL_CODE_(_IOC_NR((Code)), 0)
|
---|
1282 |
|
---|
1283 | #elif defined(RT_OS_FREEBSD) /** @todo r=bird: Please do it like SUPDRVIOC to keep it as similar as possible. */
|
---|
1284 | # include <sys/ioccom.h>
|
---|
1285 |
|
---|
1286 | # define VBOXGUEST_IOCTL_CODE_(Function, Size) _IOWR('V', (Function), VBGLBIGREQ)
|
---|
1287 | # define VBOXGUEST_IOCTL_CODE_FAST_(Function) _IO( 'V', (Function))
|
---|
1288 | # define VBOXGUEST_IOCTL_STRIP_SIZE(Code) IOCBASECMD(Code)
|
---|
1289 |
|
---|
1290 | #else
|
---|
1291 | /* PORTME */
|
---|
1292 | #endif
|
---|
1293 |
|
---|
1294 | #define VBOXGUEST_IOCTL_CODE(Function, Size) VBOXGUEST_IOCTL_CODE_((Function) | VBOXGUEST_IOCTL_FLAG, Size)
|
---|
1295 | #define VBOXGUEST_IOCTL_CODE_FAST(Function) VBOXGUEST_IOCTL_CODE_FAST_((Function) | VBOXGUEST_IOCTL_FLAG)
|
---|
1296 |
|
---|
1297 | /* Define 32 bit codes to support 32 bit applications requests in the 64 bit guest driver. */
|
---|
1298 | #ifdef RT_ARCH_AMD64
|
---|
1299 | # define VBOXGUEST_IOCTL_CODE_32(Function, Size) VBOXGUEST_IOCTL_CODE_(Function, Size)
|
---|
1300 | # define VBOXGUEST_IOCTL_CODE_FAST_32(Function) VBOXGUEST_IOCTL_CODE_FAST_(Function)
|
---|
1301 | #endif /* RT_ARCH_AMD64 */
|
---|
1302 |
|
---|
1303 | /** IOCTL to VBoxGuest to query the VMMDev IO port region start.
|
---|
1304 | * @remarks Ring-0 only. */
|
---|
1305 | #define VBOXGUEST_IOCTL_GETVMMDEVPORT VBOXGUEST_IOCTL_CODE(1, sizeof(VBoxGuestPortInfo))
|
---|
1306 |
|
---|
1307 | #pragma pack(4)
|
---|
1308 | typedef struct _VBoxGuestPortInfo
|
---|
1309 | {
|
---|
1310 | uint32_t portAddress;
|
---|
1311 | VMMDevMemory *pVMMDevMemory;
|
---|
1312 | } VBoxGuestPortInfo;
|
---|
1313 |
|
---|
1314 | /** IOCTL to VBoxGuest to wait for a VMMDev host notification */
|
---|
1315 | #define VBOXGUEST_IOCTL_WAITEVENT VBOXGUEST_IOCTL_CODE_(2, sizeof(VBoxGuestWaitEventInfo))
|
---|
1316 |
|
---|
1317 | /** IOCTL to VBoxGuest to interrupt (cancel) any pending WAITEVENTs and return.
|
---|
1318 | * Handled inside the guest additions and not seen by the host at all.
|
---|
1319 | * @see VBOXGUEST_IOCTL_WAITEVENT */
|
---|
1320 | #define VBOXGUEST_IOCTL_CANCEL_ALL_WAITEVENTS VBOXGUEST_IOCTL_CODE_(5, 0)
|
---|
1321 |
|
---|
1322 | /** @name Result codes for VBoxGuestWaitEventInfo::u32Result
|
---|
1323 | * @{
|
---|
1324 | */
|
---|
1325 | /** Successful completion, an event occured. */
|
---|
1326 | #define VBOXGUEST_WAITEVENT_OK (0)
|
---|
1327 | /** Successful completion, timed out. */
|
---|
1328 | #define VBOXGUEST_WAITEVENT_TIMEOUT (1)
|
---|
1329 | /** Wait was interrupted. */
|
---|
1330 | #define VBOXGUEST_WAITEVENT_INTERRUPTED (2)
|
---|
1331 | /** An error occured while processing the request. */
|
---|
1332 | #define VBOXGUEST_WAITEVENT_ERROR (3)
|
---|
1333 | /** @} */
|
---|
1334 |
|
---|
1335 | /** Input and output buffers layout of the IOCTL_VBOXGUEST_WAITEVENT */
|
---|
1336 | typedef struct _VBoxGuestWaitEventInfo
|
---|
1337 | {
|
---|
1338 | /** timeout in milliseconds */
|
---|
1339 | uint32_t u32TimeoutIn;
|
---|
1340 | /** events to wait for */
|
---|
1341 | uint32_t u32EventMaskIn;
|
---|
1342 | /** result code */
|
---|
1343 | uint32_t u32Result;
|
---|
1344 | /** events occured */
|
---|
1345 | uint32_t u32EventFlagsOut;
|
---|
1346 | } VBoxGuestWaitEventInfo;
|
---|
1347 | AssertCompileSize(VBoxGuestWaitEventInfo, 16);
|
---|
1348 |
|
---|
1349 | /** IOCTL to VBoxGuest to perform a VMM request
|
---|
1350 | * @remark The data buffer for this IOCtl has an variable size, keep this in mind
|
---|
1351 | * on systems where this matters. */
|
---|
1352 | #define VBOXGUEST_IOCTL_VMMREQUEST(Size) VBOXGUEST_IOCTL_CODE_(3, (Size))
|
---|
1353 |
|
---|
1354 | /** Input and output buffer layout of the IOCTL_VBOXGUEST_CTL_FILTER_MASK. */
|
---|
1355 | typedef struct _VBoxGuestFilterMaskInfo
|
---|
1356 | {
|
---|
1357 | uint32_t u32OrMask;
|
---|
1358 | uint32_t u32NotMask;
|
---|
1359 | } VBoxGuestFilterMaskInfo;
|
---|
1360 | AssertCompileSize(VBoxGuestFilterMaskInfo, 8);
|
---|
1361 | #pragma pack()
|
---|
1362 |
|
---|
1363 | /** IOCTL to VBoxGuest to control event filter mask. */
|
---|
1364 | #define VBOXGUEST_IOCTL_CTL_FILTER_MASK VBOXGUEST_IOCTL_CODE_(4, sizeof(VBoxGuestFilterMaskInfo))
|
---|
1365 |
|
---|
1366 | /** IOCTL to VBoxGuest to check memory ballooning. */
|
---|
1367 | #define VBOXGUEST_IOCTL_CTL_CHECK_BALLOON_MASK VBOXGUEST_IOCTL_CODE_(7, 100)
|
---|
1368 |
|
---|
1369 | /** IOCTL to VBoxGuest to perform backdoor logging. */
|
---|
1370 | #define VBOXGUEST_IOCTL_LOG(Size) VBOXGUEST_IOCTL_CODE_(6, (Size))
|
---|
1371 |
|
---|
1372 |
|
---|
1373 | #ifdef VBOX_WITH_HGCM
|
---|
1374 | /* These structures are shared between the driver and other binaries,
|
---|
1375 | * therefore packing must be defined explicitely.
|
---|
1376 | */
|
---|
1377 | # pragma pack(1)
|
---|
1378 | typedef struct _VBoxGuestHGCMConnectInfo /**< @todo I think the usage of '_' in tags, like _VBoxGuestHGCMConnectInfo here, is trespassing on the system/compiler name space. Check+fix. */
|
---|
1379 | {
|
---|
1380 | int32_t result; /**< OUT */
|
---|
1381 | HGCMServiceLocation Loc; /**< IN */
|
---|
1382 | uint32_t u32ClientID; /**< OUT */
|
---|
1383 | } VBoxGuestHGCMConnectInfo;
|
---|
1384 | AssertCompileSize(VBoxGuestHGCMConnectInfo, 4+4+128+4);
|
---|
1385 |
|
---|
1386 | typedef struct _VBoxGuestHGCMDisconnectInfo
|
---|
1387 | {
|
---|
1388 | int32_t result; /**< OUT */
|
---|
1389 | uint32_t u32ClientID; /**< IN */
|
---|
1390 | } VBoxGuestHGCMDisconnectInfo;
|
---|
1391 | AssertCompileSize(VBoxGuestHGCMDisconnectInfo, 8);
|
---|
1392 |
|
---|
1393 | typedef struct _VBoxGuestHGCMCallInfo
|
---|
1394 | {
|
---|
1395 | int32_t result; /**< OUT Host HGCM return code.*/
|
---|
1396 | uint32_t u32ClientID; /**< IN The id of the caller. */
|
---|
1397 | uint32_t u32Function; /**< IN Function number. */
|
---|
1398 | uint32_t cParms; /**< IN How many parms. */
|
---|
1399 | /* Parameters follow in form HGCMFunctionParameter aParms[cParms] */
|
---|
1400 | } VBoxGuestHGCMCallInfo;
|
---|
1401 | AssertCompileSize(VBoxGuestHGCMCallInfo, 16);
|
---|
1402 |
|
---|
1403 | typedef struct _VBoxGuestHGCMCallInfoTimed
|
---|
1404 | {
|
---|
1405 | uint32_t u32Timeout; /**< IN How long to wait for completion before cancelling the call */
|
---|
1406 | uint32_t fInterruptible; /**< IN Is this request interruptible? */
|
---|
1407 | VBoxGuestHGCMCallInfo info; /**< IN/OUT The rest of the call information. Placed after the timeout
|
---|
1408 | * so that the parameters follow as they would for a normal call. */
|
---|
1409 | /* Parameters follow in form HGCMFunctionParameter aParms[cParms] */
|
---|
1410 | } VBoxGuestHGCMCallInfoTimed;
|
---|
1411 | AssertCompileSize(VBoxGuestHGCMCallInfoTimed, 8+16);
|
---|
1412 | # pragma pack()
|
---|
1413 |
|
---|
1414 | # define VBOXGUEST_IOCTL_HGCM_CONNECT VBOXGUEST_IOCTL_CODE(16, sizeof(VBoxGuestHGCMConnectInfo))
|
---|
1415 | # define VBOXGUEST_IOCTL_HGCM_DISCONNECT VBOXGUEST_IOCTL_CODE(17, sizeof(VBoxGuestHGCMDisconnectInfo))
|
---|
1416 | # define VBOXGUEST_IOCTL_HGCM_CALL(Size) VBOXGUEST_IOCTL_CODE(18, (Size))
|
---|
1417 | # define VBOXGUEST_IOCTL_HGCM_CALL_TIMED(Size) VBOXGUEST_IOCTL_CODE(20, (Size))
|
---|
1418 | # define VBOXGUEST_IOCTL_CLIPBOARD_CONNECT VBOXGUEST_IOCTL_CODE_(19, sizeof(uint32_t))
|
---|
1419 | # ifdef RT_ARCH_AMD64
|
---|
1420 | /* Following HGCM IOCtls can be used by a 32 bit application on a 64 bit guest (Windows OpenGL guest driver). */
|
---|
1421 | # define VBOXGUEST_IOCTL_HGCM_CONNECT_32 VBOXGUEST_IOCTL_CODE_32(16, sizeof(VBoxGuestHGCMConnectInfo))
|
---|
1422 | # define VBOXGUEST_IOCTL_HGCM_DISCONNECT_32 VBOXGUEST_IOCTL_CODE_32(17, sizeof(VBoxGuestHGCMDisconnectInfo))
|
---|
1423 | # define VBOXGUEST_IOCTL_HGCM_CALL_32(Size) VBOXGUEST_IOCTL_CODE_32(18, (Size))
|
---|
1424 | # define VBOXGUEST_IOCTL_HGCM_CALL_TIMED_32(Size) VBOXGUEST_IOCTL_CODE_32(20, (Size))
|
---|
1425 | # endif /* RT_ARCH_AMD64 */
|
---|
1426 |
|
---|
1427 | # define VBOXGUEST_HGCM_CALL_PARMS(a) ((HGCMFunctionParameter *)((uint8_t *)(a) + sizeof (VBoxGuestHGCMCallInfo)))
|
---|
1428 | # define VBOXGUEST_HGCM_CALL_PARMS32(a) ((HGCMFunctionParameter32 *)((uint8_t *)(a) + sizeof (VBoxGuestHGCMCallInfo)))
|
---|
1429 |
|
---|
1430 | #endif /* VBOX_WITH_HGCM */
|
---|
1431 |
|
---|
1432 | /*
|
---|
1433 | * Credentials request flags and structure
|
---|
1434 | */
|
---|
1435 |
|
---|
1436 | #define VMMDEV_CREDENTIALS_STRLEN 128
|
---|
1437 |
|
---|
1438 | /** query from host whether credentials are present */
|
---|
1439 | #define VMMDEV_CREDENTIALS_QUERYPRESENCE RT_BIT(1)
|
---|
1440 | /** read credentials from host (can be combined with clear) */
|
---|
1441 | #define VMMDEV_CREDENTIALS_READ RT_BIT(2)
|
---|
1442 | /** clear credentials on host (can be combined with read) */
|
---|
1443 | #define VMMDEV_CREDENTIALS_CLEAR RT_BIT(3)
|
---|
1444 | /** read credentials for judgement in the guest */
|
---|
1445 | #define VMMDEV_CREDENTIALS_READJUDGE RT_BIT(8)
|
---|
1446 | /** clear credentials for judegement on the host */
|
---|
1447 | #define VMMDEV_CREDENTIALS_CLEARJUDGE RT_BIT(9)
|
---|
1448 | /** report credentials acceptance by guest */
|
---|
1449 | #define VMMDEV_CREDENTIALS_JUDGE_OK RT_BIT(10)
|
---|
1450 | /** report credentials denial by guest */
|
---|
1451 | #define VMMDEV_CREDENTIALS_JUDGE_DENY RT_BIT(11)
|
---|
1452 | /** report that no judgement could be made by guest */
|
---|
1453 | #define VMMDEV_CREDENTIALS_JUDGE_NOJUDGEMENT RT_BIT(12)
|
---|
1454 |
|
---|
1455 | /** flag telling the guest that credentials are present */
|
---|
1456 | #define VMMDEV_CREDENTIALS_PRESENT RT_BIT(16)
|
---|
1457 | /** flag telling guest that local logons should be prohibited */
|
---|
1458 | #define VMMDEV_CREDENTIALS_NOLOCALLOGON RT_BIT(17)
|
---|
1459 |
|
---|
1460 | /** credentials request structure */
|
---|
1461 | #pragma pack(4)
|
---|
1462 | typedef struct _VMMDevCredentials
|
---|
1463 | {
|
---|
1464 | /* request header */
|
---|
1465 | VMMDevRequestHeader header;
|
---|
1466 | /* request flags (in/out) */
|
---|
1467 | uint32_t u32Flags;
|
---|
1468 | /* user name (UTF-8) (out) */
|
---|
1469 | char szUserName[VMMDEV_CREDENTIALS_STRLEN];
|
---|
1470 | /* password (UTF-8) (out) */
|
---|
1471 | char szPassword[VMMDEV_CREDENTIALS_STRLEN];
|
---|
1472 | /* domain name (UTF-8) (out) */
|
---|
1473 | char szDomain[VMMDEV_CREDENTIALS_STRLEN];
|
---|
1474 | } VMMDevCredentials;
|
---|
1475 | #pragma pack()
|
---|
1476 |
|
---|
1477 | /** inline helper to determine the request size for the given operation */
|
---|
1478 | DECLINLINE(size_t) vmmdevGetRequestSize(VMMDevRequestType requestType)
|
---|
1479 | {
|
---|
1480 | switch (requestType)
|
---|
1481 | {
|
---|
1482 | case VMMDevReq_GetMouseStatus:
|
---|
1483 | case VMMDevReq_SetMouseStatus:
|
---|
1484 | return sizeof(VMMDevReqMouseStatus);
|
---|
1485 | case VMMDevReq_SetPointerShape:
|
---|
1486 | return sizeof(VMMDevReqMousePointer);
|
---|
1487 | case VMMDevReq_GetHostVersion:
|
---|
1488 | return sizeof(VMMDevReqHostVersion);
|
---|
1489 | case VMMDevReq_Idle:
|
---|
1490 | return sizeof(VMMDevReqIdle);
|
---|
1491 | case VMMDevReq_GetHostTime:
|
---|
1492 | return sizeof(VMMDevReqHostTime);
|
---|
1493 | case VMMDevReq_GetHypervisorInfo:
|
---|
1494 | case VMMDevReq_SetHypervisorInfo:
|
---|
1495 | return sizeof(VMMDevReqHypervisorInfo);
|
---|
1496 | case VMMDevReq_SetPowerStatus:
|
---|
1497 | return sizeof(VMMDevPowerStateRequest);
|
---|
1498 | case VMMDevReq_AcknowledgeEvents:
|
---|
1499 | return sizeof(VMMDevEvents);
|
---|
1500 | case VMMDevReq_ReportGuestInfo:
|
---|
1501 | return sizeof(VMMDevReportGuestInfo);
|
---|
1502 | case VMMDevReq_GetDisplayChangeRequest:
|
---|
1503 | return sizeof(VMMDevDisplayChangeRequest);
|
---|
1504 | case VMMDevReq_GetDisplayChangeRequest2:
|
---|
1505 | return sizeof(VMMDevDisplayChangeRequest2);
|
---|
1506 | case VMMDevReq_VideoModeSupported:
|
---|
1507 | return sizeof(VMMDevVideoModeSupportedRequest);
|
---|
1508 | case VMMDevReq_GetHeightReduction:
|
---|
1509 | return sizeof(VMMDevGetHeightReductionRequest);
|
---|
1510 | case VMMDevReq_ReportGuestCapabilities:
|
---|
1511 | return sizeof(VMMDevReqGuestCapabilities);
|
---|
1512 | case VMMDevReq_SetGuestCapabilities:
|
---|
1513 | return sizeof(VMMDevReqGuestCapabilities2);
|
---|
1514 | #ifdef VBOX_WITH_HGCM
|
---|
1515 | case VMMDevReq_HGCMConnect:
|
---|
1516 | return sizeof(VMMDevHGCMConnect);
|
---|
1517 | case VMMDevReq_HGCMDisconnect:
|
---|
1518 | return sizeof(VMMDevHGCMDisconnect);
|
---|
1519 | #ifdef VBOX_WITH_64_BITS_GUESTS
|
---|
1520 | case VMMDevReq_HGCMCall32:
|
---|
1521 | return sizeof(VMMDevHGCMCall);
|
---|
1522 | case VMMDevReq_HGCMCall64:
|
---|
1523 | return sizeof(VMMDevHGCMCall);
|
---|
1524 | #else
|
---|
1525 | case VMMDevReq_HGCMCall:
|
---|
1526 | return sizeof(VMMDevHGCMCall);
|
---|
1527 | #endif /* VBOX_WITH_64_BITS_GUESTS */
|
---|
1528 | case VMMDevReq_HGCMCancel:
|
---|
1529 | return sizeof(VMMDevHGCMCancel);
|
---|
1530 | #endif /* VBOX_WITH_HGCM */
|
---|
1531 | case VMMDevReq_VideoAccelEnable:
|
---|
1532 | return sizeof(VMMDevVideoAccelEnable);
|
---|
1533 | case VMMDevReq_VideoAccelFlush:
|
---|
1534 | return sizeof(VMMDevVideoAccelFlush);
|
---|
1535 | case VMMDevReq_VideoSetVisibleRegion:
|
---|
1536 | return sizeof(VMMDevVideoSetVisibleRegion);
|
---|
1537 | case VMMDevReq_GetSeamlessChangeRequest:
|
---|
1538 | return sizeof(VMMDevSeamlessChangeRequest);
|
---|
1539 | case VMMDevReq_QueryCredentials:
|
---|
1540 | return sizeof(VMMDevCredentials);
|
---|
1541 | case VMMDevReq_ReportGuestStats:
|
---|
1542 | return sizeof(VMMDevReportGuestStats);
|
---|
1543 | case VMMDevReq_GetMemBalloonChangeRequest:
|
---|
1544 | return sizeof(VMMDevGetMemBalloonChangeRequest);
|
---|
1545 | case VMMDevReq_GetStatisticsChangeRequest:
|
---|
1546 | return sizeof(VMMDevGetStatisticsChangeRequest);
|
---|
1547 | case VMMDevReq_ChangeMemBalloon:
|
---|
1548 | return sizeof(VMMDevChangeMemBalloon);
|
---|
1549 | case VMMDevReq_GetVRDPChangeRequest:
|
---|
1550 | return sizeof(VMMDevVRDPChangeRequest);
|
---|
1551 | case VMMDevReq_LogString:
|
---|
1552 | return sizeof(VMMDevReqLogString);
|
---|
1553 | default:
|
---|
1554 | return 0;
|
---|
1555 | }
|
---|
1556 | }
|
---|
1557 |
|
---|
1558 | /**
|
---|
1559 | * Initializes a request structure.
|
---|
1560 | *
|
---|
1561 | */
|
---|
1562 | DECLINLINE(int) vmmdevInitRequest(VMMDevRequestHeader *req, VMMDevRequestType type)
|
---|
1563 | {
|
---|
1564 | uint32_t requestSize;
|
---|
1565 | if (!req)
|
---|
1566 | return VERR_INVALID_PARAMETER;
|
---|
1567 | requestSize = (uint32_t)vmmdevGetRequestSize(type);
|
---|
1568 | if (!requestSize)
|
---|
1569 | return VERR_INVALID_PARAMETER;
|
---|
1570 | req->size = requestSize;
|
---|
1571 | req->version = VMMDEV_REQUEST_HEADER_VERSION;
|
---|
1572 | req->requestType = type;
|
---|
1573 | req->rc = VERR_GENERAL_FAILURE;
|
---|
1574 | req->reserved1 = 0;
|
---|
1575 | req->reserved2 = 0;
|
---|
1576 | return VINF_SUCCESS;
|
---|
1577 | }
|
---|
1578 |
|
---|
1579 |
|
---|
1580 | #ifdef RT_OS_OS2
|
---|
1581 |
|
---|
1582 | /**
|
---|
1583 | * The data buffer layout for the IDC entry point (AttachDD).
|
---|
1584 | *
|
---|
1585 | * @remark This is defined in multiple 16-bit headers / sources.
|
---|
1586 | * Some places it's called VBGOS2IDC to short things a bit.
|
---|
1587 | */
|
---|
1588 | typedef struct VBOXGUESTOS2IDCCONNECT
|
---|
1589 | {
|
---|
1590 | /** VMMDEV_VERSION. */
|
---|
1591 | uint32_t u32Version;
|
---|
1592 | /** Opaque session handle. */
|
---|
1593 | uint32_t u32Session;
|
---|
1594 |
|
---|
1595 | /**
|
---|
1596 | * The 32-bit service entry point.
|
---|
1597 | *
|
---|
1598 | * @returns VBox status code.
|
---|
1599 | * @param u32Session The above session handle.
|
---|
1600 | * @param iFunction The requested function.
|
---|
1601 | * @param pvData The input/output data buffer. The caller ensures that this
|
---|
1602 | * cannot be swapped out, or that it's acceptable to take a
|
---|
1603 | * page in fault in the current context. If the request doesn't
|
---|
1604 | * take input or produces output, apssing NULL is okay.
|
---|
1605 | * @param cbData The size of the data buffer.
|
---|
1606 | * @param pcbDataReturned Where to store the amount of data that's returned.
|
---|
1607 | * This can be NULL if pvData is NULL.
|
---|
1608 | */
|
---|
1609 | DECLCALLBACKMEMBER(int, pfnServiceEP)(uint32_t u32Session, unsigned iFunction, void *pvData, size_t cbData, size_t *pcbDataReturned);
|
---|
1610 |
|
---|
1611 | /** The 16-bit service entry point for C code (cdecl).
|
---|
1612 | *
|
---|
1613 | * It's the same as the 32-bit entry point, but the types has
|
---|
1614 | * changed to 16-bit equivalents.
|
---|
1615 | *
|
---|
1616 | * @code
|
---|
1617 | * int far cdecl
|
---|
1618 | * VBoxGuestOs2IDCService16(uint32_t u32Session, uint16_t iFunction,
|
---|
1619 | * void far *fpvData, uint16_t cbData, uint16_t far *pcbDataReturned);
|
---|
1620 | * @endcode
|
---|
1621 | */
|
---|
1622 | RTFAR16 fpfnServiceEP;
|
---|
1623 |
|
---|
1624 | /** The 16-bit service entry point for Assembly code (register).
|
---|
1625 | *
|
---|
1626 | * This is just a wrapper around fpfnServiceEP to simplify calls
|
---|
1627 | * from 16-bit assembly code.
|
---|
1628 | *
|
---|
1629 | * @returns (e)ax: VBox status code; cx: The amount of data returned.
|
---|
1630 | *
|
---|
1631 | * @param u32Session eax - The above session handle.
|
---|
1632 | * @param iFunction dl - The requested function.
|
---|
1633 | * @param pvData es:bx - The input/output data buffer.
|
---|
1634 | * @param cbData cx - The size of the data buffer.
|
---|
1635 | */
|
---|
1636 | RTFAR16 fpfnServiceAsmEP;
|
---|
1637 | } VBOXGUESTOS2IDCCONNECT;
|
---|
1638 | /** Pointer to VBOXGUESTOS2IDCCONNECT buffer. */
|
---|
1639 | typedef VBOXGUESTOS2IDCCONNECT *PVBOXGUESTOS2IDCCONNECT;
|
---|
1640 |
|
---|
1641 | /** OS/2 specific: IDC client disconnect request.
|
---|
1642 | *
|
---|
1643 | * This takes no input and it doesn't return anything. Obviously this
|
---|
1644 | * is only recognized if it arrives thru the IDC service EP.
|
---|
1645 | */
|
---|
1646 | #define VBOXGUEST_IOCTL_OS2_IDC_DISCONNECT VBOXGUEST_IOCTL_CODE(48, sizeof(uint32_t))
|
---|
1647 |
|
---|
1648 | #endif /* RT_OS_OS2 */
|
---|
1649 |
|
---|
1650 | /** @} */
|
---|
1651 | #endif /* !defined(IN_RC) && !defined(IN_RING0_AGNOSTIC) && !defined(IPRT_NO_CRT) */
|
---|
1652 |
|
---|
1653 |
|
---|
1654 | #ifdef IN_RING3
|
---|
1655 | # include <VBox/VBoxGuestLib.h> /** @todo eliminate this. */
|
---|
1656 | #endif /* IN_RING3 */
|
---|
1657 |
|
---|
1658 | #endif
|
---|
1659 |
|
---|