VirtualBox

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

Last change on this file since 7061 was 7061, checked in by vboxsync, 17 years ago

Use uint64_t instead of RTGCPHYS in VMMDevChangeMemBalloon (binary incompatible, but shouldn't matter...).

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette