VirtualBox

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

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

Additions/common: added guest property enumeration functions to the guest library

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