VirtualBox

source: vbox/trunk/include/VBox/VBoxGuest.h@ 8006

Last change on this file since 8006 was 7536, checked in by vboxsync, 16 years ago

freebsd todo.

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

© 2023 Oracle
ContactPrivacy policyTerms of Use