VirtualBox

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

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

Another attempt to fix all the compile problems

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