1 | /** @file
|
---|
2 | * VBoxGuest - VirtualBox Guest Additions interface
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2007 innotek GmbH
|
---|
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 as published by the Free Software Foundation,
|
---|
12 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
13 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
14 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * If you received this file as part of a commercial VirtualBox
|
---|
17 | * distribution, then only the terms of your commercial VirtualBox
|
---|
18 | * license agreement apply instead of the previous paragraph.
|
---|
19 | */
|
---|
20 |
|
---|
21 | #ifndef __VBox_VBoxGuest_h__
|
---|
22 | #define __VBox_VBoxGuest_h__
|
---|
23 |
|
---|
24 | #include <iprt/cdefs.h>
|
---|
25 | #include <iprt/types.h>
|
---|
26 | #include <VBox/err.h>
|
---|
27 | #include <VBox/ostypes.h>
|
---|
28 |
|
---|
29 | /*******************************************************************************
|
---|
30 | * Defined Constants And Macros *
|
---|
31 | *******************************************************************************/
|
---|
32 |
|
---|
33 | /** @todo The following is a temporary fix for the problem of accessing
|
---|
34 | hypervisor pointers from within guest additions */
|
---|
35 |
|
---|
36 | /** Hypervisor linear pointer size type */
|
---|
37 | typedef uint32_t vmmDevHypPtr;
|
---|
38 | /** Hypervisor physical pointer size type */
|
---|
39 | typedef uint32_t vmmDevHypPhys;
|
---|
40 |
|
---|
41 | #if defined(__LINUX__)
|
---|
42 | /** The support device name. */
|
---|
43 | # define VBOXGUEST_DEVICE_NAME "/dev/vboxadd"
|
---|
44 |
|
---|
45 | #elif defined(__OS2__)
|
---|
46 | /** The support device name. */
|
---|
47 | # define VBOXGUEST_DEVICE_NAME "\\Dev\\VBoxGst$"
|
---|
48 |
|
---|
49 | #elif defined(__WIN__)
|
---|
50 | /** The support service name. */
|
---|
51 | # define VBOXGUEST_SERVICE_NAME "VBoxGuest"
|
---|
52 | /** Win32 Device name. */
|
---|
53 | # define VBOXGUEST_DEVICE_NAME "\\\\.\\VBoxGuest"
|
---|
54 | /** Global name for Win2k+ */
|
---|
55 | # define VBOXGUEST_DEVICE_NAME_GLOBAL "\\\\.\\Global\\VBoxGuest"
|
---|
56 | /** Win32 driver name */
|
---|
57 | # define VBOXGUEST_DEVICE_NAME_NT L"\\Device\\VBoxGuest"
|
---|
58 | /** device name */
|
---|
59 | # define VBOXGUEST_DEVICE_NAME_DOS L"\\DosDevices\\VBoxGuest"
|
---|
60 |
|
---|
61 | #else
|
---|
62 | /* PORTME */
|
---|
63 | #endif
|
---|
64 |
|
---|
65 | /** VirtualBox vendor ID */
|
---|
66 | #define VBOX_PCI_VENDORID (0x80ee)
|
---|
67 |
|
---|
68 | /** VMMDev PCI card identifiers */
|
---|
69 | #define VMMDEV_VENDORID VBOX_PCI_VENDORID
|
---|
70 | #define VMMDEV_DEVICEID (0xcafe)
|
---|
71 |
|
---|
72 | /** VirtualBox graphics card identifiers */
|
---|
73 | #define VBOX_VENDORID VBOX_PCI_VENDORID
|
---|
74 | #define VBOX_VESA_VENDORID VBOX_PCI_VENDORID
|
---|
75 | #define VBOX_DEVICEID (0xbeef)
|
---|
76 | #define VBOX_VESA_DEVICEID (0xbeef)
|
---|
77 |
|
---|
78 | /**
|
---|
79 | * VBoxGuest port definitions
|
---|
80 | * @{
|
---|
81 | */
|
---|
82 |
|
---|
83 | /** guest can (== wants to) handle absolute coordinates */
|
---|
84 | #define VBOXGUEST_MOUSE_GUEST_CAN_ABSOLUTE BIT(0)
|
---|
85 | /** host can (== wants to) send absolute coordinates */
|
---|
86 | #define VBOXGUEST_MOUSE_HOST_CAN_ABSOLUTE BIT(1)
|
---|
87 | /** guest can *NOT* switch to software cursor and therefore depends on the host cursor */
|
---|
88 | #define VBOXGUEST_MOUSE_GUEST_NEEDS_HOST_CURSOR BIT(2)
|
---|
89 | /** host does NOT provide support for drawing the cursor itself (e.g. L4 console) */
|
---|
90 | #define VBOXGUEST_MOUSE_HOST_CANNOT_HWPOINTER BIT(3)
|
---|
91 |
|
---|
92 | /** fictive start address of the hypervisor physical memory for MmMapIoSpace */
|
---|
93 | #define HYPERVISOR_PHYSICAL_START 0xf8000000
|
---|
94 |
|
---|
95 | /*
|
---|
96 | * VMMDev Generic Request Interface
|
---|
97 | */
|
---|
98 |
|
---|
99 | /** port for generic request interface */
|
---|
100 | #define PORT_VMMDEV_REQUEST_OFFSET 0
|
---|
101 |
|
---|
102 | /** Current version of the VMMDev interface.
|
---|
103 | *
|
---|
104 | * Additions are allowed to work only if
|
---|
105 | * additions_major == vmmdev_current && additions_minor <= vmmdev_current.
|
---|
106 | * Additions version is reported to host (VMMDev) by VMMDevReq_ReportGuestInfo.
|
---|
107 | *
|
---|
108 | * @remark These defines also live in the 16-bit and assembly versions of this header.
|
---|
109 | */
|
---|
110 | #define VMMDEV_VERSION_MAJOR (0x1)
|
---|
111 | #define VMMDEV_VERSION_MINOR (0x4)
|
---|
112 | #define VMMDEV_VERSION ((VMMDEV_VERSION_MAJOR << 16) | VMMDEV_VERSION_MINOR)
|
---|
113 |
|
---|
114 | /**
|
---|
115 | * VMMDev request types.
|
---|
116 | * @note when updating this, adjust vmmdevGetRequestSize() as well
|
---|
117 | */
|
---|
118 | typedef enum
|
---|
119 | {
|
---|
120 | VMMDevReq_InvalidRequest = 0,
|
---|
121 | VMMDevReq_GetMouseStatus = 1,
|
---|
122 | VMMDevReq_SetMouseStatus = 2,
|
---|
123 | VMMDevReq_SetPointerShape = 3,
|
---|
124 | /** @todo implement on host side */
|
---|
125 | VMMDevReq_GetHostVersion = 4,
|
---|
126 | VMMDevReq_Idle = 5,
|
---|
127 | VMMDevReq_GetHostTime = 10,
|
---|
128 | VMMDevReq_GetHypervisorInfo = 20,
|
---|
129 | VMMDevReq_SetHypervisorInfo = 21,
|
---|
130 | VMMDevReq_SetPowerStatus = 30,
|
---|
131 | VMMDevReq_AcknowledgeEvents = 41,
|
---|
132 | VMMDevReq_CtlGuestFilterMask = 42,
|
---|
133 | VMMDevReq_ReportGuestInfo = 50,
|
---|
134 | VMMDevReq_GetDisplayChangeRequest = 51,
|
---|
135 | VMMDevReq_VideoModeSupported = 52,
|
---|
136 | VMMDevReq_GetHeightReduction = 53,
|
---|
137 | VMMDevReq_GetDisplayChangeRequest2 = 54,
|
---|
138 | #ifdef VBOX_HGCM
|
---|
139 | VMMDevReq_HGCMConnect = 60,
|
---|
140 | VMMDevReq_HGCMDisconnect = 61,
|
---|
141 | VMMDevReq_HGCMCall = 62,
|
---|
142 | #endif
|
---|
143 | VMMDevReq_VideoAccelEnable = 70,
|
---|
144 | VMMDevReq_VideoAccelFlush = 71,
|
---|
145 | VMMDevReq_QueryCredentials = 100,
|
---|
146 | VMMDevReq_ReportCredentialsJudgement = 101,
|
---|
147 | #ifdef DEBUG
|
---|
148 | VMMDevReq_LogString = 200,
|
---|
149 | #endif
|
---|
150 | VMMDevReq_SizeHack = 0x7fffffff
|
---|
151 | } VMMDevRequestType;
|
---|
152 |
|
---|
153 | /** Version of VMMDevRequestHeader structure. */
|
---|
154 | #define VMMDEV_REQUEST_HEADER_VERSION (0x10001)
|
---|
155 |
|
---|
156 | #pragma pack(4)
|
---|
157 | /** generic VMMDev request header */
|
---|
158 | typedef struct
|
---|
159 | {
|
---|
160 | /** size of the structure in bytes (including body). Filled by caller */
|
---|
161 | uint32_t size;
|
---|
162 | /** version of the structure. Filled by caller */
|
---|
163 | uint32_t version;
|
---|
164 | /** type of the request */
|
---|
165 | VMMDevRequestType requestType;
|
---|
166 | /** return code. Filled by VMMDev */
|
---|
167 | int32_t rc;
|
---|
168 | /** reserved fields */
|
---|
169 | uint32_t reserved1;
|
---|
170 | uint32_t reserved2;
|
---|
171 | } VMMDevRequestHeader;
|
---|
172 |
|
---|
173 | /** mouse status request structure */
|
---|
174 | typedef struct
|
---|
175 | {
|
---|
176 | /** header */
|
---|
177 | VMMDevRequestHeader header;
|
---|
178 | /** mouse feature mask */
|
---|
179 | uint32_t mouseFeatures;
|
---|
180 | /** mouse x position */
|
---|
181 | uint32_t pointerXPos;
|
---|
182 | /** mouse y position */
|
---|
183 | uint32_t pointerYPos;
|
---|
184 | } VMMDevReqMouseStatus;
|
---|
185 |
|
---|
186 | /** Note VBOX_MOUSE_POINTER_* flags are used in guest video driver,
|
---|
187 | * values must be <= 0x8000 and must not be changed.
|
---|
188 | */
|
---|
189 |
|
---|
190 | /** pointer is visible */
|
---|
191 | #define VBOX_MOUSE_POINTER_VISIBLE (0x0001)
|
---|
192 | /** pointer has alpha channel */
|
---|
193 | #define VBOX_MOUSE_POINTER_ALPHA (0x0002)
|
---|
194 | /** pointerData contains new pointer shape */
|
---|
195 | #define VBOX_MOUSE_POINTER_SHAPE (0x0004)
|
---|
196 |
|
---|
197 | /** mouse pointer shape/visibility change request */
|
---|
198 | typedef struct
|
---|
199 | {
|
---|
200 | /** header */
|
---|
201 | VMMDevRequestHeader header;
|
---|
202 | /** VBOX_MOUSE_POINTER_* bit flags */
|
---|
203 | uint32_t fFlags;
|
---|
204 | /** x coordinate of hot spot */
|
---|
205 | uint32_t xHot;
|
---|
206 | /** y coordinate of hot spot */
|
---|
207 | uint32_t yHot;
|
---|
208 | /** width of the pointer in pixels */
|
---|
209 | uint32_t width;
|
---|
210 | /** height of the pointer in scanlines */
|
---|
211 | uint32_t height;
|
---|
212 | /** Pointer data.
|
---|
213 | *
|
---|
214 | ****
|
---|
215 | * The data consists of 1 bpp AND mask followed by 32 bpp XOR (color) mask.
|
---|
216 | *
|
---|
217 | * For pointers without alpha channel the XOR mask pixels are 32 bit values: (lsb)BGR0(msb).
|
---|
218 | * For pointers with alpha channel the XOR mask consists of (lsb)BGRA(msb) 32 bit values.
|
---|
219 | *
|
---|
220 | * Guest driver must create the AND mask for pointers with alpha channel, so if host does not
|
---|
221 | * support alpha, the pointer could be displayed as a normal color pointer. The AND mask can
|
---|
222 | * be constructed from alpha values. For example alpha value >= 0xf0 means bit 0 in the AND mask.
|
---|
223 | *
|
---|
224 | * The AND mask is 1 bpp bitmap with byte aligned scanlines. Size of AND mask,
|
---|
225 | * therefore, is cbAnd = (width + 7) / 8 * height. The padding bits at the
|
---|
226 | * end of any scanline are undefined.
|
---|
227 | *
|
---|
228 | * The XOR mask follows the AND mask on the next 4 bytes aligned offset:
|
---|
229 | * uint8_t *pXor = pAnd + (cbAnd + 3) & ~3
|
---|
230 | * Bytes in the gap between the AND and the XOR mask are undefined.
|
---|
231 | * XOR mask scanlines have no gap between them and size of XOR mask is:
|
---|
232 | * cXor = width * 4 * height.
|
---|
233 | ****
|
---|
234 | *
|
---|
235 | * Preallocate 4 bytes for accessing actual data as p->pointerData
|
---|
236 | */
|
---|
237 | char pointerData[4];
|
---|
238 | } VMMDevReqMousePointer;
|
---|
239 |
|
---|
240 | /** string log request structure */
|
---|
241 | typedef struct
|
---|
242 | {
|
---|
243 | /** header */
|
---|
244 | VMMDevRequestHeader header;
|
---|
245 | /** variable length string data */
|
---|
246 | char szString[1];
|
---|
247 | } VMMDevReqLogString;
|
---|
248 |
|
---|
249 | /** host version request structure */
|
---|
250 | typedef struct
|
---|
251 | {
|
---|
252 | /** header */
|
---|
253 | VMMDevRequestHeader header;
|
---|
254 | /** major version */
|
---|
255 | uint32_t major;
|
---|
256 | /** minor version */
|
---|
257 | uint32_t minor;
|
---|
258 | /** build number */
|
---|
259 | uint32_t build;
|
---|
260 | } VMMDevReqHostVersion;
|
---|
261 |
|
---|
262 | /** idle request structure */
|
---|
263 | typedef struct
|
---|
264 | {
|
---|
265 | /** header */
|
---|
266 | VMMDevRequestHeader header;
|
---|
267 | } VMMDevReqIdle;
|
---|
268 |
|
---|
269 | /** host time request structure */
|
---|
270 | typedef struct
|
---|
271 | {
|
---|
272 | /** header */
|
---|
273 | VMMDevRequestHeader header;
|
---|
274 | /** time in milliseconds since unix epoch. Filled by VMMDev. */
|
---|
275 | uint64_t time;
|
---|
276 | } VMMDevReqHostTime;
|
---|
277 |
|
---|
278 | /** hypervisor info structure */
|
---|
279 | typedef struct
|
---|
280 | {
|
---|
281 | /** header */
|
---|
282 | VMMDevRequestHeader header;
|
---|
283 | /** guest virtual address of proposed hypervisor start */
|
---|
284 | vmmDevHypPtr hypervisorStart;
|
---|
285 | /** hypervisor size in bytes */
|
---|
286 | uint32_t hypervisorSize;
|
---|
287 | } VMMDevReqHypervisorInfo;
|
---|
288 |
|
---|
289 | /** system power requests */
|
---|
290 | typedef enum
|
---|
291 | {
|
---|
292 | VMMDevPowerState_Invalid = 0,
|
---|
293 | VMMDevPowerState_Pause = 1,
|
---|
294 | VMMDevPowerState_PowerOff = 2,
|
---|
295 | VMMDevPowerState_SaveState = 3,
|
---|
296 | VMMDevPowerState_SizeHack = 0x7fffffff
|
---|
297 | } VMMDevPowerState;
|
---|
298 |
|
---|
299 | /** system power status structure */
|
---|
300 | typedef struct
|
---|
301 | {
|
---|
302 | /** header */
|
---|
303 | VMMDevRequestHeader header;
|
---|
304 | /** power state request */
|
---|
305 | VMMDevPowerState powerState;
|
---|
306 | } VMMDevPowerStateRequest;
|
---|
307 |
|
---|
308 | /** pending events structure */
|
---|
309 | typedef struct
|
---|
310 | {
|
---|
311 | /** header */
|
---|
312 | VMMDevRequestHeader header;
|
---|
313 | /** pending event bitmap */
|
---|
314 | uint32_t events;
|
---|
315 | } VMMDevEvents;
|
---|
316 |
|
---|
317 | /** guest filter mask control */
|
---|
318 | typedef struct
|
---|
319 | {
|
---|
320 | /** header */
|
---|
321 | VMMDevRequestHeader header;
|
---|
322 | /** mask of events to be added to filter */
|
---|
323 | uint32_t u32OrMask;
|
---|
324 | /** mask of events to be removed from filter */
|
---|
325 | uint32_t u32NotMask;
|
---|
326 | } VMMDevCtlGuestFilterMask;
|
---|
327 |
|
---|
328 | /** guest information structure */
|
---|
329 | typedef struct VBoxGuestInfo
|
---|
330 | {
|
---|
331 | /** The VMMDev interface version expected by additions. */
|
---|
332 | uint32_t additionsVersion;
|
---|
333 | /** guest OS type */
|
---|
334 | OSType osType;
|
---|
335 | /** @todo */
|
---|
336 | } VBoxGuestInfo;
|
---|
337 |
|
---|
338 | /** guest information structure */
|
---|
339 | typedef struct
|
---|
340 | {
|
---|
341 | /** header */
|
---|
342 | VMMDevRequestHeader header;
|
---|
343 | /** Guest information. */
|
---|
344 | VBoxGuestInfo guestInfo;
|
---|
345 | } VMMDevReportGuestInfo;
|
---|
346 |
|
---|
347 | /** display change request structure */
|
---|
348 | typedef struct
|
---|
349 | {
|
---|
350 | /** header */
|
---|
351 | VMMDevRequestHeader header;
|
---|
352 | /** horizontal pixel resolution (0 = do not change) */
|
---|
353 | uint32_t xres;
|
---|
354 | /** vertical pixel resolution (0 = do not change) */
|
---|
355 | uint32_t yres;
|
---|
356 | /** bits per pixel (0 = do not change) */
|
---|
357 | uint32_t bpp;
|
---|
358 | /** Flag that the request is an acknowlegement for the VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST.
|
---|
359 | * Values: 0 - just querying, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST - event acknowledged.
|
---|
360 | */
|
---|
361 | uint32_t eventAck;
|
---|
362 | } VMMDevDisplayChangeRequest;
|
---|
363 |
|
---|
364 | typedef struct
|
---|
365 | {
|
---|
366 | /** header */
|
---|
367 | VMMDevRequestHeader header;
|
---|
368 | /** horizontal pixel resolution (0 = do not change) */
|
---|
369 | uint32_t xres;
|
---|
370 | /** vertical pixel resolution (0 = do not change) */
|
---|
371 | uint32_t yres;
|
---|
372 | /** bits per pixel (0 = do not change) */
|
---|
373 | uint32_t bpp;
|
---|
374 | /** Flag that the request is an acknowlegement for the VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST.
|
---|
375 | * Values: 0 - just querying, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST - event acknowledged.
|
---|
376 | */
|
---|
377 | uint32_t eventAck;
|
---|
378 | /** 0 for primary display, 1 for the first secondary, etc. */
|
---|
379 | uint32_t display;
|
---|
380 | } VMMDevDisplayChangeRequest2;
|
---|
381 |
|
---|
382 | /** video mode supported request structure */
|
---|
383 | typedef struct
|
---|
384 | {
|
---|
385 | /** header */
|
---|
386 | VMMDevRequestHeader header;
|
---|
387 | /** horizontal pixel resolution (input) */
|
---|
388 | uint32_t width;
|
---|
389 | /** vertical pixel resolution (input) */
|
---|
390 | uint32_t height;
|
---|
391 | /** bits per pixel (input) */
|
---|
392 | uint32_t bpp;
|
---|
393 | /** supported flag (output) */
|
---|
394 | bool fSupported;
|
---|
395 | } VMMDevVideoModeSupportedRequest;
|
---|
396 |
|
---|
397 | /** video modes height reduction request structure */
|
---|
398 | typedef struct
|
---|
399 | {
|
---|
400 | /** header */
|
---|
401 | VMMDevRequestHeader header;
|
---|
402 | /** height reduction in pixels (output) */
|
---|
403 | uint32_t heightReduction;
|
---|
404 | } VMMDevGetHeightReductionRequest;
|
---|
405 |
|
---|
406 | #pragma pack()
|
---|
407 |
|
---|
408 | #ifdef VBOX_HGCM
|
---|
409 |
|
---|
410 | /** HGCM flags.
|
---|
411 | * @{
|
---|
412 | */
|
---|
413 | #define VBOX_HGCM_REQ_DONE (0x1)
|
---|
414 | #define VBOX_HGCM_REQ_CANCELLED (0x2)
|
---|
415 | /** @} */
|
---|
416 |
|
---|
417 | #pragma pack(4)
|
---|
418 | typedef struct _VMMDevHGCMRequestHeader
|
---|
419 | {
|
---|
420 | /** Request header. */
|
---|
421 | VMMDevRequestHeader header;
|
---|
422 |
|
---|
423 | /** HGCM flags. */
|
---|
424 | uint32_t fu32Flags;
|
---|
425 |
|
---|
426 | /** Result code. */
|
---|
427 | int32_t result;
|
---|
428 | } VMMDevHGCMRequestHeader;
|
---|
429 |
|
---|
430 | /** HGCM service location types. */
|
---|
431 | typedef enum
|
---|
432 | {
|
---|
433 | VMMDevHGCMLoc_Invalid = 0,
|
---|
434 | VMMDevHGCMLoc_LocalHost = 1,
|
---|
435 | VMMDevHGCMLoc_LocalHost_Existing = 2,
|
---|
436 | VMMDevHGCMLoc_SizeHack = 0x7fffffff
|
---|
437 | } HGCMServiceLocationType;
|
---|
438 |
|
---|
439 | typedef struct
|
---|
440 | {
|
---|
441 | char achName[128];
|
---|
442 | } HGCMServiceLocationHost;
|
---|
443 |
|
---|
444 | typedef struct HGCMSERVICELOCATION
|
---|
445 | {
|
---|
446 | /** Type of the location. */
|
---|
447 | HGCMServiceLocationType type;
|
---|
448 |
|
---|
449 | union
|
---|
450 | {
|
---|
451 | HGCMServiceLocationHost host;
|
---|
452 | } u;
|
---|
453 | } HGCMServiceLocation;
|
---|
454 |
|
---|
455 | typedef struct
|
---|
456 | {
|
---|
457 | /* request header */
|
---|
458 | VMMDevHGCMRequestHeader header;
|
---|
459 |
|
---|
460 | /** IN: Description of service to connect to. */
|
---|
461 | HGCMServiceLocation loc;
|
---|
462 |
|
---|
463 | /** OUT: Client identifier assigned by local instance of HGCM. */
|
---|
464 | uint32_t u32ClientID;
|
---|
465 | } VMMDevHGCMConnect;
|
---|
466 |
|
---|
467 | typedef struct
|
---|
468 | {
|
---|
469 | /* request header */
|
---|
470 | VMMDevHGCMRequestHeader header;
|
---|
471 |
|
---|
472 | /** IN: Client identifier. */
|
---|
473 | uint32_t u32ClientID;
|
---|
474 | } VMMDevHGCMDisconnect;
|
---|
475 |
|
---|
476 | typedef enum
|
---|
477 | {
|
---|
478 | VMMDevHGCMParmType_Invalid = 0,
|
---|
479 | VMMDevHGCMParmType_32bit = 1,
|
---|
480 | VMMDevHGCMParmType_64bit = 2,
|
---|
481 | VMMDevHGCMParmType_PhysAddr = 3,
|
---|
482 | VMMDevHGCMParmType_LinAddr = 4, /**< In and Out */
|
---|
483 | VMMDevHGCMParmType_LinAddr_In = 5, /**< In (read) */
|
---|
484 | VMMDevHGCMParmType_LinAddr_Out= 6, /**< Out (write) */
|
---|
485 | VMMDevHGCMParmType_SizeHack = 0x7fffffff
|
---|
486 | } HGCMFunctionParameterType;
|
---|
487 |
|
---|
488 | typedef struct _HGCMFUNCTIONPARAMETER
|
---|
489 | {
|
---|
490 | HGCMFunctionParameterType type;
|
---|
491 | union
|
---|
492 | {
|
---|
493 | uint32_t value32;
|
---|
494 | uint64_t value64;
|
---|
495 | struct
|
---|
496 | {
|
---|
497 | uint32_t size;
|
---|
498 |
|
---|
499 | union
|
---|
500 | {
|
---|
501 | vmmDevHypPhys physAddr;
|
---|
502 | vmmDevHypPtr linearAddr;
|
---|
503 | } u;
|
---|
504 | } Pointer;
|
---|
505 | } u;
|
---|
506 | } HGCMFunctionParameter;
|
---|
507 |
|
---|
508 | typedef struct
|
---|
509 | {
|
---|
510 | /* request header */
|
---|
511 | VMMDevHGCMRequestHeader header;
|
---|
512 |
|
---|
513 | /** IN: Client identifier. */
|
---|
514 | uint32_t u32ClientID;
|
---|
515 | /** IN: Service function number. */
|
---|
516 | uint32_t u32Function;
|
---|
517 | /** IN: Number of parameters. */
|
---|
518 | uint32_t cParms;
|
---|
519 | /** Parameters follow in form: HGCMFunctionParameter aParms[X]; */
|
---|
520 | } VMMDevHGCMCall;
|
---|
521 | #pragma pack()
|
---|
522 |
|
---|
523 | #define VMMDEV_HGCM_CALL_PARMS(a) ((HGCMFunctionParameter *)((char *)a + sizeof (VMMDevHGCMCall)))
|
---|
524 |
|
---|
525 | #define VBOX_HGCM_MAX_PARMS 256
|
---|
526 |
|
---|
527 | #endif /* VBOX_HGCM */
|
---|
528 |
|
---|
529 |
|
---|
530 | #define VBVA_F_STATUS_ACCEPTED (0x01)
|
---|
531 | #define VBVA_F_STATUS_ENABLED (0x02)
|
---|
532 |
|
---|
533 | #pragma pack(4)
|
---|
534 |
|
---|
535 | typedef struct _VMMDevVideoAccelEnable
|
---|
536 | {
|
---|
537 | /* request header */
|
---|
538 | VMMDevRequestHeader header;
|
---|
539 |
|
---|
540 | /** 0 - disable, !0 - enable. */
|
---|
541 | uint32_t u32Enable;
|
---|
542 |
|
---|
543 | /** The size of VBVAMEMORY::au8RingBuffer expected by driver.
|
---|
544 | * The host will refuse to enable VBVA if the size is not equal to
|
---|
545 | * VBVA_RING_BUFFER_SIZE.
|
---|
546 | */
|
---|
547 | uint32_t cbRingBuffer;
|
---|
548 |
|
---|
549 | /** Guest initializes the status to 0. Host sets appropriate VBVA_F_STATUS_ flags. */
|
---|
550 | uint32_t fu32Status;
|
---|
551 |
|
---|
552 | } VMMDevVideoAccelEnable;
|
---|
553 |
|
---|
554 | typedef struct _VMMDevVideoAccelFlush
|
---|
555 | {
|
---|
556 | /* request header */
|
---|
557 | VMMDevRequestHeader header;
|
---|
558 |
|
---|
559 | } VMMDevVideoAccelFlush;
|
---|
560 |
|
---|
561 | #pragma pack()
|
---|
562 |
|
---|
563 | #pragma pack(1)
|
---|
564 |
|
---|
565 | /** VBVA command header. */
|
---|
566 | typedef struct _VBVACMDHDR
|
---|
567 | {
|
---|
568 | /** Coordinates of affected rectangle. */
|
---|
569 | int16_t x;
|
---|
570 | int16_t y;
|
---|
571 | uint16_t w;
|
---|
572 | uint16_t h;
|
---|
573 | } VBVACMDHDR;
|
---|
574 |
|
---|
575 | /* VBVA order codes. Must be >= 0, because the VRDP server internally
|
---|
576 | * uses negative values to mark some operations.
|
---|
577 | * Values are important since they are used as an index in the
|
---|
578 | * "supported orders" bit mask.
|
---|
579 | */
|
---|
580 | #define VBVA_VRDP_DIRTY_RECT (0)
|
---|
581 | #define VBVA_VRDP_SOLIDRECT (1)
|
---|
582 | #define VBVA_VRDP_SOLIDBLT (2)
|
---|
583 | #define VBVA_VRDP_DSTBLT (3)
|
---|
584 | #define VBVA_VRDP_SCREENBLT (4)
|
---|
585 | #define VBVA_VRDP_PATBLTBRUSH (5)
|
---|
586 | #define VBVA_VRDP_MEMBLT (6)
|
---|
587 | #define VBVA_VRDP_CACHED_BITMAP (7)
|
---|
588 | #define VBVA_VRDP_DELETED_BITMAP (8)
|
---|
589 | #define VBVA_VRDP_LINE (9)
|
---|
590 | #define VBVA_VRDP_BOUNDS (10)
|
---|
591 | #define VBVA_VRDP_REPEAT (11)
|
---|
592 | #define VBVA_VRDP_POLYLINE (12)
|
---|
593 | #define VBVA_VRDP_ELLIPSE (13)
|
---|
594 | #define VBVA_VRDP_SAVESCREEN (14)
|
---|
595 |
|
---|
596 | #define VBVA_VRDP_INDEX_TO_BIT(__index) (1 << (__index))
|
---|
597 |
|
---|
598 | /* 128 bit bitmap hash. */
|
---|
599 | typedef uint8_t VRDPBITMAPHASH[16];
|
---|
600 |
|
---|
601 | typedef struct _VRDPORDERPOINT
|
---|
602 | {
|
---|
603 | int16_t x;
|
---|
604 | int16_t y;
|
---|
605 | } VRDPORDERPOINT;
|
---|
606 |
|
---|
607 | typedef struct _VRDPORDERPOLYPOINTS
|
---|
608 | {
|
---|
609 | uint8_t c;
|
---|
610 | VRDPORDERPOINT a[16];
|
---|
611 | } VRDPORDERPOLYPOINTS;
|
---|
612 |
|
---|
613 | typedef struct _VRDPORDERAREA
|
---|
614 | {
|
---|
615 | int16_t x;
|
---|
616 | int16_t y;
|
---|
617 | uint16_t w;
|
---|
618 | uint16_t h;
|
---|
619 | } VRDPORDERAREA;
|
---|
620 |
|
---|
621 | typedef struct _VRDPORDERBOUNDS
|
---|
622 | {
|
---|
623 | VRDPORDERPOINT pt1;
|
---|
624 | VRDPORDERPOINT pt2;
|
---|
625 | } VRDPORDERBOUNDS;
|
---|
626 |
|
---|
627 | typedef struct _VRDPORDERREPEAT
|
---|
628 | {
|
---|
629 | VRDPORDERBOUNDS bounds;
|
---|
630 | } VRDPORDERREPEAT;
|
---|
631 |
|
---|
632 |
|
---|
633 | /* Header for bitmap bits in VBVA VRDP operations. */
|
---|
634 | typedef struct _VRDPDATABITS
|
---|
635 | {
|
---|
636 | /* Size of bitmap data without the header. */
|
---|
637 | uint32_t cb;
|
---|
638 | int16_t x;
|
---|
639 | int16_t y;
|
---|
640 | uint16_t cWidth;
|
---|
641 | uint16_t cHeight;
|
---|
642 | uint8_t cbPixel;
|
---|
643 | } VRDPDATABITS;
|
---|
644 |
|
---|
645 | typedef struct _VRDPORDERSOLIDRECT
|
---|
646 | {
|
---|
647 | int16_t x;
|
---|
648 | int16_t y;
|
---|
649 | uint16_t w;
|
---|
650 | uint16_t h;
|
---|
651 | uint32_t rgb;
|
---|
652 | } VRDPORDERSOLIDRECT;
|
---|
653 |
|
---|
654 | typedef struct _VRDPORDERSOLIDBLT
|
---|
655 | {
|
---|
656 | int16_t x;
|
---|
657 | int16_t y;
|
---|
658 | uint16_t w;
|
---|
659 | uint16_t h;
|
---|
660 | uint32_t rgb;
|
---|
661 | uint8_t rop;
|
---|
662 | } VRDPORDERSOLIDBLT;
|
---|
663 |
|
---|
664 | typedef struct _VRDPORDERDSTBLT
|
---|
665 | {
|
---|
666 | int16_t x;
|
---|
667 | int16_t y;
|
---|
668 | uint16_t w;
|
---|
669 | uint16_t h;
|
---|
670 | uint8_t rop;
|
---|
671 | } VRDPORDERDSTBLT;
|
---|
672 |
|
---|
673 | typedef struct _VRDPORDERSCREENBLT
|
---|
674 | {
|
---|
675 | int16_t x;
|
---|
676 | int16_t y;
|
---|
677 | uint16_t w;
|
---|
678 | uint16_t h;
|
---|
679 | int16_t xSrc;
|
---|
680 | int16_t ySrc;
|
---|
681 | uint8_t rop;
|
---|
682 | } VRDPORDERSCREENBLT;
|
---|
683 |
|
---|
684 | typedef struct _VRDPORDERPATBLTBRUSH
|
---|
685 | {
|
---|
686 | int16_t x;
|
---|
687 | int16_t y;
|
---|
688 | uint16_t w;
|
---|
689 | uint16_t h;
|
---|
690 | int8_t xSrc;
|
---|
691 | int8_t ySrc;
|
---|
692 | uint32_t rgbFG;
|
---|
693 | uint32_t rgbBG;
|
---|
694 | uint8_t rop;
|
---|
695 | uint8_t pattern[8];
|
---|
696 | } VRDPORDERPATBLTBRUSH;
|
---|
697 |
|
---|
698 | typedef struct _VRDPORDERMEMBLT
|
---|
699 | {
|
---|
700 | int16_t x;
|
---|
701 | int16_t y;
|
---|
702 | uint16_t w;
|
---|
703 | uint16_t h;
|
---|
704 | int16_t xSrc;
|
---|
705 | int16_t ySrc;
|
---|
706 | uint8_t rop;
|
---|
707 | VRDPBITMAPHASH hash;
|
---|
708 | } VRDPORDERMEMBLT;
|
---|
709 |
|
---|
710 | typedef struct _VRDPORDERCACHEDBITMAP
|
---|
711 | {
|
---|
712 | VRDPBITMAPHASH hash;
|
---|
713 | /* VRDPDATABITS and the bitmap data follows. */
|
---|
714 | } VRDPORDERCACHEDBITMAP;
|
---|
715 |
|
---|
716 | typedef struct _VRDPORDERDELETEDBITMAP
|
---|
717 | {
|
---|
718 | VRDPBITMAPHASH hash;
|
---|
719 | } VRDPORDERDELETEDBITMAP;
|
---|
720 |
|
---|
721 | typedef struct _VRDPORDERLINE
|
---|
722 | {
|
---|
723 | int16_t x1;
|
---|
724 | int16_t y1;
|
---|
725 | int16_t x2;
|
---|
726 | int16_t y2;
|
---|
727 | int16_t xBounds1;
|
---|
728 | int16_t yBounds1;
|
---|
729 | int16_t xBounds2;
|
---|
730 | int16_t yBounds2;
|
---|
731 | uint8_t mix;
|
---|
732 | uint32_t rgb;
|
---|
733 | } VRDPORDERLINE;
|
---|
734 |
|
---|
735 | typedef struct _VRDPORDERPOLYLINE
|
---|
736 | {
|
---|
737 | VRDPORDERPOINT ptStart;
|
---|
738 | uint8_t mix;
|
---|
739 | uint32_t rgb;
|
---|
740 | VRDPORDERPOLYPOINTS points;
|
---|
741 | } VRDPORDERPOLYLINE;
|
---|
742 |
|
---|
743 | typedef struct _VRDPORDERELLIPSE
|
---|
744 | {
|
---|
745 | VRDPORDERPOINT pt1;
|
---|
746 | VRDPORDERPOINT pt2;
|
---|
747 | uint8_t mix;
|
---|
748 | uint8_t fillMode;
|
---|
749 | uint32_t rgb;
|
---|
750 | } VRDPORDERELLIPSE;
|
---|
751 |
|
---|
752 | typedef struct _VRDPORDERSAVESCREEN
|
---|
753 | {
|
---|
754 | VRDPORDERPOINT pt1;
|
---|
755 | VRDPORDERPOINT pt2;
|
---|
756 | uint8_t ident;
|
---|
757 | uint8_t restore;
|
---|
758 | } VRDPORDERSAVESCREEN;
|
---|
759 | #pragma pack()
|
---|
760 |
|
---|
761 | /* The VBVA ring buffer is suitable for transferring large (< 2gb) amount of data.
|
---|
762 | * For example big bitmaps which do not fit to the buffer.
|
---|
763 | *
|
---|
764 | * Guest starts writing to the buffer by initializing a record entry in the
|
---|
765 | * aRecords queue. VBVA_F_RECORD_PARTIAL indicates that the record is being
|
---|
766 | * written. As data is written to the ring buffer, the guest increases off32End
|
---|
767 | * for the record.
|
---|
768 | *
|
---|
769 | * The host reads the aRecords on flushes and processes all completed records.
|
---|
770 | * When host encounters situation when only a partial record presents and
|
---|
771 | * cbRecord & ~VBVA_F_RECORD_PARTIAL >= VBVA_RING_BUFFER_SIZE - VBVA_RING_BUFFER_THRESHOLD,
|
---|
772 | * the host fetched all record data and updates off32Head. After that on each flush
|
---|
773 | * the host continues fetching the data until the record is completed.
|
---|
774 | *
|
---|
775 | */
|
---|
776 |
|
---|
777 | #define VBVA_RING_BUFFER_SIZE (_4M - _1K)
|
---|
778 | #define VBVA_RING_BUFFER_THRESHOLD (4 * _1K)
|
---|
779 |
|
---|
780 | #define VBVA_MAX_RECORDS (64)
|
---|
781 |
|
---|
782 | #define VBVA_F_MODE_ENABLED (0x00000001)
|
---|
783 | #define VBVA_F_MODE_VRDP (0x00000002)
|
---|
784 | #define VBVA_F_MODE_VRDP_RESET (0x00000004)
|
---|
785 | #define VBVA_F_MODE_VRDP_ORDER_MASK (0x00000008)
|
---|
786 |
|
---|
787 | #define VBVA_F_RECORD_PARTIAL (0x80000000)
|
---|
788 |
|
---|
789 | #pragma pack(1)
|
---|
790 | typedef struct _VBVARECORD
|
---|
791 | {
|
---|
792 | /** The length of the record. Changed by guest. */
|
---|
793 | uint32_t cbRecord;
|
---|
794 | } VBVARECORD;
|
---|
795 |
|
---|
796 | typedef struct _VBVAMEMORY
|
---|
797 | {
|
---|
798 | /** VBVA_F_MODE_* */
|
---|
799 | uint32_t fu32ModeFlags;
|
---|
800 |
|
---|
801 | /** The offset where the data start in the buffer. */
|
---|
802 | uint32_t off32Data;
|
---|
803 | /** The offset where next data must be placed in the buffer. */
|
---|
804 | uint32_t off32Free;
|
---|
805 |
|
---|
806 | /** The ring buffer for data. */
|
---|
807 | uint8_t au8RingBuffer[VBVA_RING_BUFFER_SIZE];
|
---|
808 |
|
---|
809 | /** The queue of record descriptions. */
|
---|
810 | VBVARECORD aRecords[VBVA_MAX_RECORDS];
|
---|
811 | uint32_t indexRecordFirst;
|
---|
812 | uint32_t indexRecordFree;
|
---|
813 |
|
---|
814 | /* RDP orders supported by the client. The guest reports only them
|
---|
815 | * and falls back to DIRTY rects for not supported ones.
|
---|
816 | *
|
---|
817 | * (1 << VBVA_VRDP_*)
|
---|
818 | */
|
---|
819 | uint32_t fu32SupportedOrders;
|
---|
820 |
|
---|
821 | } VBVAMEMORY;
|
---|
822 | #pragma pack()
|
---|
823 |
|
---|
824 | /** @} */
|
---|
825 |
|
---|
826 |
|
---|
827 | /**
|
---|
828 | * VMMDev RAM
|
---|
829 | * @{
|
---|
830 | */
|
---|
831 |
|
---|
832 | #pragma pack(1)
|
---|
833 | /** Layout of VMMDEV RAM region that contains information for guest */
|
---|
834 | typedef struct
|
---|
835 | {
|
---|
836 | /** size */
|
---|
837 | uint32_t u32Size;
|
---|
838 | /** version */
|
---|
839 | uint32_t u32Version;
|
---|
840 |
|
---|
841 | union {
|
---|
842 | /** Flag telling that VMMDev set the IRQ and acknowlegment is required */
|
---|
843 | struct {
|
---|
844 | bool fHaveEvents;
|
---|
845 | } V1_04;
|
---|
846 |
|
---|
847 | struct {
|
---|
848 | /** Pending events flags, set by host. */
|
---|
849 | uint32_t u32HostEvents;
|
---|
850 | /** Mask of events the guest wants to see, set by guest. */
|
---|
851 | uint32_t u32GuestEventMask;
|
---|
852 | } V1_03;
|
---|
853 | } V;
|
---|
854 |
|
---|
855 | VBVAMEMORY vbvaMemory;
|
---|
856 |
|
---|
857 | } VMMDevMemory;
|
---|
858 | #pragma pack()
|
---|
859 |
|
---|
860 | /** Version of VMMDevMemory structure. */
|
---|
861 | #define VMMDEV_MEMORY_VERSION (1)
|
---|
862 |
|
---|
863 | /** @} */
|
---|
864 |
|
---|
865 |
|
---|
866 | /**
|
---|
867 | * VMMDev events.
|
---|
868 | * @{
|
---|
869 | */
|
---|
870 |
|
---|
871 | /** Host mouse capabilities has been changed. */
|
---|
872 | #define VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED BIT(0)
|
---|
873 | /** HGCM event. */
|
---|
874 | #define VMMDEV_EVENT_HGCM BIT(1)
|
---|
875 | /** A display change request has been issued. */
|
---|
876 | #define VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST BIT(2)
|
---|
877 | /** Credentials are available for judgement. */
|
---|
878 | #define VMMDEV_EVENT_JUDGE_CREDENTIALS BIT(3)
|
---|
879 | /** The guest has been restored. */
|
---|
880 | #define VMMDEV_EVENT_RESTORED BIT(4)
|
---|
881 |
|
---|
882 | /** @} */
|
---|
883 |
|
---|
884 |
|
---|
885 | /**
|
---|
886 | * VBoxGuest IOCTL codes and structures.
|
---|
887 | *
|
---|
888 | * The range 0..15 is for basic driver communication.
|
---|
889 | * The range 16..31 is for HGCM communcation.
|
---|
890 | * The range 32..47 is reserved for future use.
|
---|
891 | * The range 48..63 is for OS specific communcation.
|
---|
892 | * The 7th bit is reserved for future hacks.
|
---|
893 | * The 8th bit is reserved for distinguishing between 32-bit and 64-bit
|
---|
894 | * processes in future 64-bit guest additions.
|
---|
895 | *
|
---|
896 | * While windows IOCTL function number has to start at 2048 and stop at 4096 there
|
---|
897 | * never was any need to do this for everyone. A simple ((Function) | 0x800) would
|
---|
898 | * have sufficed. On Linux we're now intruding upon the type field. Fortunately
|
---|
899 | * this hasn't caused any trouble because the FILE_DEVICE_UNKNOWN value was set
|
---|
900 | * to 0x22 (if it were 0x2C it would not have worked soo smoothly). The situation
|
---|
901 | * would've been the same for *BSD and Darwin since they seems to share common
|
---|
902 | * _IOC() heritage.
|
---|
903 | *
|
---|
904 | * However, on good old OS/2 we only have 8-bit handy for the function number. The
|
---|
905 | * result from using the old IOCTL function numbers her would've been overlapping
|
---|
906 | * between the two ranges.
|
---|
907 | *
|
---|
908 | * To fix this problem and get rid of all the unnecessary windowsy crap that I
|
---|
909 | * bet was copied from my SUPDRVIOC.h once upon a time (although the concept of
|
---|
910 | * prefixing macros with the purpose of avoid clashes with system stuff and
|
---|
911 | * to indicate exactly how owns them seems to have been lost somewhere along
|
---|
912 | * the way), I've introduced a VBOXGUEST_IOCTL_CODE for defining generic IN/OUT
|
---|
913 | * IOCtls on new ports of the additions.
|
---|
914 | *
|
---|
915 | * @remark When creating new IOCtl interfaces keep in mind that not all OSes supports
|
---|
916 | * reporting back the output size. (This got messed up a little bit in VBoxDrv.)
|
---|
917 | *
|
---|
918 | * OS/2 restricts the in/out data size to 64KB, while Linux, BSD and Darwin are
|
---|
919 | * limited by a 14 bits size field (16KB). So, special considerations need to
|
---|
920 | * be taken if more input/output needs to be passed around.
|
---|
921 | *
|
---|
922 | * When passing variable sized input/output special care need to be taken on
|
---|
923 | * Unix platforms (if we're going to play by the rules) since the size is
|
---|
924 | * passed as part of the IOCtl code there. IIRC Darwin will use the size to
|
---|
925 | * perform locking and in/out copying, I don't quite know about linux and *BSD.
|
---|
926 | *
|
---|
927 | * @remark If adding interfaces that only has input or only has output, some new macros
|
---|
928 | * needs to be created so the most efficient IOCtl data buffering method can be
|
---|
929 | * used.
|
---|
930 | *
|
---|
931 | * @{
|
---|
932 | */
|
---|
933 | #ifdef __AMD64__
|
---|
934 | # define VBOXGUEST_IOCTL_FLAG 128
|
---|
935 | #elif defined(__X86__)
|
---|
936 | # define VBOXGUEST_IOCTL_FLAG 0
|
---|
937 | #else
|
---|
938 | # error "dunno which arch this is!"
|
---|
939 | #endif
|
---|
940 |
|
---|
941 | #if defined(__WIN__)
|
---|
942 | # define IOCTL_CODE(DeviceType, Function, Method, Access, DataSize_ignored) \
|
---|
943 | ( ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method))
|
---|
944 |
|
---|
945 | #elif defined(__OS2__)
|
---|
946 | # define VBOXGUEST_IOCTL_CATEGORY 0xc2
|
---|
947 | # define VBOXGUEST_IOCTL_CODE(Function, Size) ((unsigned char)(Function))
|
---|
948 | # define VBOXGUEST_IOCTL_CATEGORY_FAST 0xc3 /**< Also defined in VBoxGuestA-os2.asm. */
|
---|
949 | # define VBOXGUEST_IOCTL_CODE_FAST(Function) ((unsigned char)(Function))
|
---|
950 |
|
---|
951 | #elif defined(__LINUX__)
|
---|
952 | # define IOCTL_CODE(DeviceType, Function, Method_ignored, Access_ignored, DataSize) \
|
---|
953 | ( (3 << 30) | ((DeviceType) << 8) | (Function) | ((DataSize) << 16) )
|
---|
954 | # define METHOD_BUFFERED 0
|
---|
955 | # define FILE_WRITE_ACCESS 0x0002
|
---|
956 | # define FILE_DEVICE_UNKNOWN 0x00000022
|
---|
957 |
|
---|
958 | #elif 0 /* BSD style - needs some adjusting _IORW takes a type and not a size. */
|
---|
959 | # include <sys/ioccom.h>
|
---|
960 | # define VBOXGUEST_IOCTL_CODE(Function, Size) _IORW('V', (Function) | VBOXGUEST_IOCTL_FLAG, (Size))
|
---|
961 | # define VBOXGUEST_IOCTL_CODE_FAST(Function) _IO( 'V', (Function) | VBOXGUEST_IOCTL_FLAG)
|
---|
962 |
|
---|
963 | #else
|
---|
964 | /* PORTME */
|
---|
965 | #endif
|
---|
966 |
|
---|
967 | /** IOCTL to VBoxGuest to query the VMMDev IO port region start. */
|
---|
968 | #ifdef VBOXGUEST_IOCTL_CODE
|
---|
969 | # define VBOXGUEST_IOCTL_GETVMMDEVPORT VBOXGUEST_IOCTL_CODE(1, sizeof(VBoxGuestPortInfo))
|
---|
970 | # define IOCTL_VBOXGUEST_GETVMMDEVPORT VBOXGUEST_IOCTL_GETVMMDEVPORT
|
---|
971 | #else
|
---|
972 | # define IOCTL_VBOXGUEST_GETVMMDEVPORT IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2048, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VBoxGuestPortInfo))
|
---|
973 | #endif
|
---|
974 |
|
---|
975 | #pragma pack(4)
|
---|
976 | typedef struct _VBoxGuestPortInfo
|
---|
977 | {
|
---|
978 | uint32_t portAddress;
|
---|
979 | VMMDevMemory *pVMMDevMemory;
|
---|
980 | } VBoxGuestPortInfo;
|
---|
981 |
|
---|
982 | /** IOCTL to VBoxGuest to wait for a VMMDev host notification */
|
---|
983 | #ifdef VBOXGUEST_IOCTL_CODE
|
---|
984 | # define VBOXGUEST_IOCTL_WAITEVENT VBOXGUEST_IOCTL_CODE(2, sizeof(VBoxGuestWaitEventInfo))
|
---|
985 | # define IOCTL_VBOXGUEST_WAITEVENT VBOXGUEST_IOCTL_WAITEVENT
|
---|
986 | #else
|
---|
987 | # define IOCTL_VBOXGUEST_WAITEVENT IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2049, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VBoxGuestWaitEventInfo))
|
---|
988 | #endif
|
---|
989 |
|
---|
990 | /**
|
---|
991 | * Result codes for VBoxGuestWaitEventInfo::u32Result
|
---|
992 | * @{
|
---|
993 | */
|
---|
994 | /** Successful completion, an event occured. */
|
---|
995 | #define VBOXGUEST_WAITEVENT_OK (0)
|
---|
996 | /** Successful completion, timed out. */
|
---|
997 | #define VBOXGUEST_WAITEVENT_TIMEOUT (1)
|
---|
998 | /** Wait was interrupted. */
|
---|
999 | #define VBOXGUEST_WAITEVENT_INTERRUPTED (2)
|
---|
1000 | /** An error occured while processing the request. */
|
---|
1001 | #define VBOXGUEST_WAITEVENT_ERROR (3)
|
---|
1002 | /** @} */
|
---|
1003 |
|
---|
1004 | /** Input and output buffers layout of the IOCTL_VBOXGUEST_WAITEVENT */
|
---|
1005 | typedef struct _VBoxGuestWaitEventInfo
|
---|
1006 | {
|
---|
1007 | /** timeout in milliseconds */
|
---|
1008 | uint32_t u32TimeoutIn;
|
---|
1009 | /** events to wait for */
|
---|
1010 | uint32_t u32EventMaskIn;
|
---|
1011 | /** result code */
|
---|
1012 | uint32_t u32Result;
|
---|
1013 | /** events occured */
|
---|
1014 | uint32_t u32EventFlagsOut;
|
---|
1015 | } VBoxGuestWaitEventInfo;
|
---|
1016 |
|
---|
1017 | /** IOCTL to VBoxGuest to perform a VMM request
|
---|
1018 | * @remark The data buffer for this IOCtl has an variable size, keep this in mind
|
---|
1019 | * on systems where this matters. */
|
---|
1020 | #ifdef VBOXGUEST_IOCTL_CODE
|
---|
1021 | # define VBOXGUEST_IOCTL_VMMREQUEST(Size) VBOXGUEST_IOCTL_CODE(3, sizeof(VMMDevRequestHeader))
|
---|
1022 | # define IOCTL_VBOXGUEST_VMMREQUEST VBOXGUEST_IOCTL_VMMREQUEST(sizeof(VMMDevRequestHeader))
|
---|
1023 | #else
|
---|
1024 | # define IOCTL_VBOXGUEST_VMMREQUEST IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2050, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VMMDevRequestHeader))
|
---|
1025 | #endif
|
---|
1026 |
|
---|
1027 | /** Input and output buffer layout of the IOCTL_VBOXGUEST_CTL_FILTER_MASK. */
|
---|
1028 | typedef struct _VBoxGuestFilterMaskInfo
|
---|
1029 | {
|
---|
1030 | uint32_t u32OrMask;
|
---|
1031 | uint32_t u32NotMask;
|
---|
1032 | } VBoxGuestFilterMaskInfo;
|
---|
1033 | #pragma pack()
|
---|
1034 |
|
---|
1035 | /** IOCTL to VBoxGuest to control event filter mask */
|
---|
1036 | #ifdef VBOXGUEST_IOCTL_CODE
|
---|
1037 | # define VBOXGUEST_IOCTL_CTL_FILTER_MASK VBOXGUEST_IOCTL_CODE(4, sizeof(VBoxGuestFilterMaskInfo))
|
---|
1038 | # define IOCTL_VBOXGUEST_CTL_FILTER_MASK VBOXGUEST_IOCTL_CTL_FILTER_MASK
|
---|
1039 | #else
|
---|
1040 | # define IOCTL_VBOXGUEST_CTL_FILTER_MASK IOCTL_CODE(FILE_DEVICE_UNKNOWN, 2051, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof (VBoxGuestFilterMaskInfo))
|
---|
1041 | #endif
|
---|
1042 |
|
---|
1043 | #ifdef VBOX_HGCM
|
---|
1044 | /* These structures are shared between the driver and other binaries,
|
---|
1045 | * therefore packing must be defined explicitely.
|
---|
1046 | */
|
---|
1047 | #pragma pack(1)
|
---|
1048 | typedef struct _VBoxGuestHGCMConnectInfo
|
---|
1049 | {
|
---|
1050 | uint32_t result; /**< OUT */
|
---|
1051 | HGCMServiceLocation Loc; /**< IN */
|
---|
1052 | uint32_t u32ClientID; /**< OUT */
|
---|
1053 | } VBoxGuestHGCMConnectInfo;
|
---|
1054 |
|
---|
1055 | typedef struct _VBoxGuestHGCMDisconnectInfo
|
---|
1056 | {
|
---|
1057 | uint32_t result; /**< OUT */
|
---|
1058 | uint32_t u32ClientID; /**< IN */
|
---|
1059 | } VBoxGuestHGCMDisconnectInfo;
|
---|
1060 |
|
---|
1061 | typedef struct _VBoxGuestHGCMCallInfo
|
---|
1062 | {
|
---|
1063 | uint32_t result; /**< OUT Host HGCM return code.*/
|
---|
1064 | uint32_t u32ClientID; /**< IN The id of the caller. */
|
---|
1065 | uint32_t u32Function; /**< IN Function number. */
|
---|
1066 | uint32_t cParms; /**< IN How many parms. */
|
---|
1067 | /* Parameters follow in form HGCMFunctionParameter aParms[cParms] */
|
---|
1068 | } VBoxGuestHGCMCallInfo;
|
---|
1069 | #pragma pack()
|
---|
1070 |
|
---|
1071 | #ifdef VBOXGUEST_IOCTL_CODE
|
---|
1072 | # define VBOXGUEST_IOCTL_HGCM_CONNECT VBOXGUEST_IOCTL_CODE(16, sizeof(VBoxGuestHGCMConnectInfo))
|
---|
1073 | # define IOCTL_VBOXGUEST_HGCM_CONNECT VBOXGUEST_IOCTL_HGCM_CONNECT
|
---|
1074 | # define VBOXGUEST_IOCTL_HGCM_DISCONNECT VBOXGUEST_IOCTL_CODE(17, sizeof(VBoxGuestHGCMDisconnectInfo))
|
---|
1075 | # define IOCTL_VBOXGUEST_HGCM_DISCONNECT VBOXGUEST_IOCTL_HGCM_DISCONNECT
|
---|
1076 | # define VBOXGUEST_IOCTL_HGCM_CALL(Size) VBOXGUEST_IOCTL_CODE(18, (Size))
|
---|
1077 | # define IOCTL_VBOXGUEST_HGCM_CALL VBOXGUEST_IOCTL_HGCM_CALL(sizeof(VBoxGuestHGCMCallInfo))
|
---|
1078 | # define VBOXGUEST_IOCTL_CLIPBOARD_CONNECT VBOXGUEST_IOCTL_CODE(19, sizeof(uint32_t))
|
---|
1079 | # define IOCTL_VBOXGUEST_CLIPBOARD_CONNECT VBOXGUEST_IOCTL_CLIPBOARD_CONNECT
|
---|
1080 | #else
|
---|
1081 | # define IOCTL_VBOXGUEST_HGCM_CONNECT IOCTL_CODE(FILE_DEVICE_UNKNOWN, 3072, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VBoxGuestHGCMConnectInfo))
|
---|
1082 | # define IOCTL_VBOXGUEST_HGCM_DISCONNECT IOCTL_CODE(FILE_DEVICE_UNKNOWN, 3073, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VBoxGuestHGCMDisconnectInfo))
|
---|
1083 | # define IOCTL_VBOXGUEST_HGCM_CALL IOCTL_CODE(FILE_DEVICE_UNKNOWN, 3074, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(VBoxGuestHGCMCallInfo))
|
---|
1084 | # define IOCTL_VBOXGUEST_CLIPBOARD_CONNECT IOCTL_CODE(FILE_DEVICE_UNKNOWN, 3075, METHOD_BUFFERED, FILE_WRITE_ACCESS, sizeof(uint32_t))
|
---|
1085 | #endif
|
---|
1086 |
|
---|
1087 | #define VBOXGUEST_HGCM_CALL_PARMS(a) ((HGCMFunctionParameter *)((uint8_t *)(a) + sizeof (VBoxGuestHGCMCallInfo)))
|
---|
1088 |
|
---|
1089 | #endif /* VBOX_HGCM */
|
---|
1090 |
|
---|
1091 | /*
|
---|
1092 | * Credentials request flags and structure
|
---|
1093 | */
|
---|
1094 |
|
---|
1095 | #define VMMDEV_CREDENTIALS_STRLEN 128
|
---|
1096 |
|
---|
1097 | /** query from host whether credentials are present */
|
---|
1098 | #define VMMDEV_CREDENTIALS_QUERYPRESENCE BIT(1)
|
---|
1099 | /** read credentials from host (can be combined with clear) */
|
---|
1100 | #define VMMDEV_CREDENTIALS_READ BIT(2)
|
---|
1101 | /** clear credentials on host (can be combined with read) */
|
---|
1102 | #define VMMDEV_CREDENTIALS_CLEAR BIT(3)
|
---|
1103 | /** read credentials for judgement in the guest */
|
---|
1104 | #define VMMDEV_CREDENTIALS_READJUDGE BIT(8)
|
---|
1105 | /** clear credentials for judegement on the host */
|
---|
1106 | #define VMMDEV_CREDENTIALS_CLEARJUDGE BIT(9)
|
---|
1107 | /** report credentials acceptance by guest */
|
---|
1108 | #define VMMDEV_CREDENTIALS_JUDGE_OK BIT(10)
|
---|
1109 | /** report credentials denial by guest */
|
---|
1110 | #define VMMDEV_CREDENTIALS_JUDGE_DENY BIT(11)
|
---|
1111 | /** report that no judgement could be made by guest */
|
---|
1112 | #define VMMDEV_CREDENTIALS_JUDGE_NOJUDGEMENT BIT(12)
|
---|
1113 |
|
---|
1114 | /** flag telling the guest that credentials are present */
|
---|
1115 | #define VMMDEV_CREDENTIALS_PRESENT BIT(16)
|
---|
1116 | /** flag telling guest that local logons should be prohibited */
|
---|
1117 | #define VMMDEV_CREDENTIALS_NOLOCALLOGON BIT(17)
|
---|
1118 |
|
---|
1119 | /** credentials request structure */
|
---|
1120 | #pragma pack(4)
|
---|
1121 | typedef struct _VMMDevCredentials
|
---|
1122 | {
|
---|
1123 | /* request header */
|
---|
1124 | VMMDevRequestHeader header;
|
---|
1125 | /* request flags (in/out) */
|
---|
1126 | uint32_t u32Flags;
|
---|
1127 | /* user name (UTF-8) (out) */
|
---|
1128 | char szUserName[VMMDEV_CREDENTIALS_STRLEN];
|
---|
1129 | /* password (UTF-8) (out) */
|
---|
1130 | char szPassword[VMMDEV_CREDENTIALS_STRLEN];
|
---|
1131 | /* domain name (UTF-8) (out) */
|
---|
1132 | char szDomain[VMMDEV_CREDENTIALS_STRLEN];
|
---|
1133 | } VMMDevCredentials;
|
---|
1134 | #pragma pack()
|
---|
1135 |
|
---|
1136 | /** inline helper to determine the request size for the given operation */
|
---|
1137 | DECLINLINE(size_t) vmmdevGetRequestSize(VMMDevRequestType requestType)
|
---|
1138 | {
|
---|
1139 | switch (requestType)
|
---|
1140 | {
|
---|
1141 | case VMMDevReq_GetMouseStatus:
|
---|
1142 | case VMMDevReq_SetMouseStatus:
|
---|
1143 | return sizeof(VMMDevReqMouseStatus);
|
---|
1144 | case VMMDevReq_SetPointerShape:
|
---|
1145 | return sizeof(VMMDevReqMousePointer);
|
---|
1146 | case VMMDevReq_GetHostVersion:
|
---|
1147 | return sizeof(VMMDevReqHostVersion);
|
---|
1148 | case VMMDevReq_Idle:
|
---|
1149 | return sizeof(VMMDevReqIdle);
|
---|
1150 | case VMMDevReq_GetHostTime:
|
---|
1151 | return sizeof(VMMDevReqHostTime);
|
---|
1152 | case VMMDevReq_GetHypervisorInfo:
|
---|
1153 | case VMMDevReq_SetHypervisorInfo:
|
---|
1154 | return sizeof(VMMDevReqHypervisorInfo);
|
---|
1155 | case VMMDevReq_SetPowerStatus:
|
---|
1156 | return sizeof(VMMDevPowerStateRequest);
|
---|
1157 | case VMMDevReq_AcknowledgeEvents:
|
---|
1158 | return sizeof(VMMDevEvents);
|
---|
1159 | case VMMDevReq_ReportGuestInfo:
|
---|
1160 | return sizeof(VMMDevReportGuestInfo);
|
---|
1161 | case VMMDevReq_GetDisplayChangeRequest:
|
---|
1162 | return sizeof(VMMDevDisplayChangeRequest);
|
---|
1163 | case VMMDevReq_GetDisplayChangeRequest2:
|
---|
1164 | return sizeof(VMMDevDisplayChangeRequest2);
|
---|
1165 | case VMMDevReq_VideoModeSupported:
|
---|
1166 | return sizeof(VMMDevVideoModeSupportedRequest);
|
---|
1167 | case VMMDevReq_GetHeightReduction:
|
---|
1168 | return sizeof(VMMDevGetHeightReductionRequest);
|
---|
1169 | #ifdef VBOX_HGCM
|
---|
1170 | case VMMDevReq_HGCMConnect:
|
---|
1171 | return sizeof(VMMDevHGCMConnect);
|
---|
1172 | case VMMDevReq_HGCMDisconnect:
|
---|
1173 | return sizeof(VMMDevHGCMDisconnect);
|
---|
1174 | case VMMDevReq_HGCMCall:
|
---|
1175 | return sizeof(VMMDevHGCMCall);
|
---|
1176 | #endif
|
---|
1177 | case VMMDevReq_VideoAccelEnable:
|
---|
1178 | return sizeof(VMMDevVideoAccelEnable);
|
---|
1179 | case VMMDevReq_VideoAccelFlush:
|
---|
1180 | return sizeof(VMMDevVideoAccelFlush);
|
---|
1181 | case VMMDevReq_QueryCredentials:
|
---|
1182 | return sizeof(VMMDevCredentials);
|
---|
1183 | #ifdef DEBUG
|
---|
1184 | case VMMDevReq_LogString:
|
---|
1185 | return sizeof(VMMDevReqLogString);
|
---|
1186 | #endif
|
---|
1187 | default:
|
---|
1188 | return 0;
|
---|
1189 | }
|
---|
1190 | }
|
---|
1191 |
|
---|
1192 | /**
|
---|
1193 | * Initializes a request structure.
|
---|
1194 | *
|
---|
1195 | */
|
---|
1196 | DECLINLINE(int) vmmdevInitRequest(VMMDevRequestHeader *req, VMMDevRequestType type)
|
---|
1197 | {
|
---|
1198 | uint32_t requestSize;
|
---|
1199 | if (!req)
|
---|
1200 | return VERR_INVALID_PARAMETER;
|
---|
1201 | requestSize = (uint32_t)vmmdevGetRequestSize(type);
|
---|
1202 | if (!requestSize)
|
---|
1203 | return VERR_INVALID_PARAMETER;
|
---|
1204 | req->size = requestSize;
|
---|
1205 | req->version = VMMDEV_REQUEST_HEADER_VERSION;
|
---|
1206 | req->requestType = type;
|
---|
1207 | req->rc = VERR_GENERAL_FAILURE;
|
---|
1208 | req->reserved1 = 0;
|
---|
1209 | req->reserved2 = 0;
|
---|
1210 | return VINF_SUCCESS;
|
---|
1211 | }
|
---|
1212 |
|
---|
1213 |
|
---|
1214 | #ifdef __OS2__
|
---|
1215 |
|
---|
1216 | /**
|
---|
1217 | * The data buffer layout for the IDC entry point (AttachDD).
|
---|
1218 | *
|
---|
1219 | * @remark This is defined in multiple 16-bit headers / sources.
|
---|
1220 | * Some places it's called VBGOS2IDC to short things a bit.
|
---|
1221 | */
|
---|
1222 | typedef struct VBOXGUESTOS2IDCCONNECT
|
---|
1223 | {
|
---|
1224 | /** VMMDEV_VERSION. */
|
---|
1225 | uint32_t u32Version;
|
---|
1226 | /** Opaque session handle. */
|
---|
1227 | uint32_t u32Session;
|
---|
1228 |
|
---|
1229 | /**
|
---|
1230 | * The 32-bit service entry point.
|
---|
1231 | *
|
---|
1232 | * @returns VBox status code.
|
---|
1233 | * @param u32Session The above session handle.
|
---|
1234 | * @param iFunction The requested function.
|
---|
1235 | * @param pvData The input/output data buffer. The caller ensures that this
|
---|
1236 | * cannot be swapped out, or that it's acceptable to take a
|
---|
1237 | * page in fault in the current context. If the request doesn't
|
---|
1238 | * take input or produces output, apssing NULL is okay.
|
---|
1239 | * @param cbData The size of the data buffer.
|
---|
1240 | * @param pcbDataReturned Where to store the amount of data that's returned.
|
---|
1241 | * This can be NULL if pvData is NULL.
|
---|
1242 | */
|
---|
1243 | DECLCALLBACKMEMBER(int, pfnServiceEP)(uint32_t u32Session, unsigned iFunction, void *pvData, size_t cbData, size_t *pcbDataReturned);
|
---|
1244 |
|
---|
1245 | /** The 16-bit service entry point for C code (cdecl).
|
---|
1246 | *
|
---|
1247 | * It's the same as the 32-bit entry point, but the types has
|
---|
1248 | * changed to 16-bit equivalents.
|
---|
1249 | *
|
---|
1250 | * @code
|
---|
1251 | * int far cdecl
|
---|
1252 | * VBoxGuestOs2IDCService16(uint32_t u32Session, uint16_t iFunction,
|
---|
1253 | * void far *fpvData, uint16_t cbData, uint16_t far *pcbDataReturned);
|
---|
1254 | * @endcode
|
---|
1255 | */
|
---|
1256 | RTFAR16 fpfnServiceEP;
|
---|
1257 |
|
---|
1258 | /** The 16-bit service entry point for Assembly code (register).
|
---|
1259 | *
|
---|
1260 | * This is just a wrapper around fpfnServiceEP to simplify calls
|
---|
1261 | * from 16-bit assembly code.
|
---|
1262 | *
|
---|
1263 | * @returns (e)ax: VBox status code; cx: The amount of data returned.
|
---|
1264 | *
|
---|
1265 | * @param u32Session eax - The above session handle.
|
---|
1266 | * @param iFunction dl - The requested function.
|
---|
1267 | * @param pvData es:bx - The input/output data buffer.
|
---|
1268 | * @param cbData cx - The size of the data buffer.
|
---|
1269 | */
|
---|
1270 | RTFAR16 fpfnServiceAsmEP;
|
---|
1271 | } VBOXGUESTOS2IDCCONNECT;
|
---|
1272 | /** Pointer to VBOXGUESTOS2IDCCONNECT buffer. */
|
---|
1273 | typedef VBOXGUESTOS2IDCCONNECT *PVBOXGUESTOS2IDCCONNECT;
|
---|
1274 |
|
---|
1275 | /** OS/2 specific: IDC client disconnect request.
|
---|
1276 | *
|
---|
1277 | * This takes no input and it doesn't return anything. Obviously this
|
---|
1278 | * is only recognized if it arrives thru the IDC service EP.
|
---|
1279 | */
|
---|
1280 | #define VBOXGUEST_IOCTL_OS2_IDC_DISCONNECT VBOXGUEST_IOCTL_CODE(48, sizeof(uint32_t))
|
---|
1281 |
|
---|
1282 | #endif /* __OS2__ */
|
---|
1283 |
|
---|
1284 | /** @} */
|
---|
1285 |
|
---|
1286 |
|
---|
1287 | #ifdef IN_RING3
|
---|
1288 |
|
---|
1289 | /** @def VBGLR3DECL
|
---|
1290 | * Ring 3 VBGL declaration.
|
---|
1291 | * @param type The return type of the function declaration.
|
---|
1292 | */
|
---|
1293 | #define VBGLR3DECL(type) type VBOXCALL
|
---|
1294 |
|
---|
1295 | __BEGIN_DECLS
|
---|
1296 | VBGLR3DECL(int) VbglR3Init(void);
|
---|
1297 | VBGLR3DECL(void) VbglR3Term(void);
|
---|
1298 | VBGLR3DECL(int) VbglR3GRPerform(VMMDevRequestHeader *pReq);
|
---|
1299 | # ifdef __iprt_time_h__
|
---|
1300 | VBGLR3DECL(int) VbglR3GetHostTime(PRTTIMESPEC pTime);
|
---|
1301 | # endif
|
---|
1302 |
|
---|
1303 | VBGLR3DECL(int) VbglR3ClipboardConnect(uint32_t *pu32ClientId);
|
---|
1304 | VBGLR3DECL(int) VbglR3ClipboardDisconnect(uint32_t u32ClientId);
|
---|
1305 | VBGLR3DECL(int) VbglR3ClipboardGetHostMsg(uint32_t u32ClientId, uint32_t *pMsg, uint32_t *pfFormats);
|
---|
1306 | VBGLR3DECL(int) VbglR3ClipboardReadData(uint32_t u32ClientId, uint32_t fFormat, void *pv, uint32_t cb, uint32_t *pcb);
|
---|
1307 | VBGLR3DECL(int) VbglR3ClipboardReportFormats(uint32_t u32ClientId, uint32_t fFormats);
|
---|
1308 | VBGLR3DECL(int) VbglR3ClipboardWriteData(uint32_t u32ClientId, uint32_t fFormat, void *pv, uint32_t cb);
|
---|
1309 |
|
---|
1310 | __END_DECLS
|
---|
1311 |
|
---|
1312 | #endif /* IN_RING3 */
|
---|
1313 |
|
---|
1314 | #endif /* __VBox_VBoxGuest_h__ */
|
---|