VirtualBox

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

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

The Giant CDDL Dual-License Header Change.

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