VirtualBox

source: vbox/trunk/include/VBox/VBoxVideoGuest.h@ 56378

Last change on this file since 56378 was 56378, checked in by vboxsync, 9 years ago

Windows guest additions, VBVA: host mouse cursor capability.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 13.8 KB
Line 
1/** @file
2 *
3 * VBox Host Guest Shared Memory Interface (HGSMI).
4 * OS-independent guest structures.
5 */
6
7/*
8 * Copyright (C) 2006-2015 Oracle Corporation
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 *
18 * The contents of this file may alternatively be used under the terms
19 * of the Common Development and Distribution License Version 1.0
20 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
21 * VirtualBox OSE distribution, in which case the provisions of the
22 * CDDL are applicable instead of those of the GPL.
23 *
24 * You may elect to license modified versions of this file under the
25 * terms and conditions of either the GPL or the CDDL or both.
26 */
27
28
29#ifndef __HGSMI_GUEST_h__
30#define __HGSMI_GUEST_h__
31
32#include <VBox/HGSMI/HGSMI.h>
33#include <VBox/HGSMI/HGSMIChSetup.h>
34#include <VBox/VBoxVideo.h>
35
36#ifdef VBOX_XPDM_MINIPORT
37RT_C_DECLS_BEGIN
38# include "miniport.h"
39# include "ntddvdeo.h"
40# include <Video.h>
41RT_C_DECLS_END
42#elif defined VBOX_GUESTR3XORGMOD
43# include <compiler.h>
44#else
45# include <iprt/asm-amd64-x86.h>
46#endif
47
48#ifdef VBOX_WDDM_MINIPORT
49# include "wddm/VBoxMPShgsmi.h"
50 typedef VBOXSHGSMI HGSMIGUESTCMDHEAP;
51# define HGSMIGUESTCMDHEAP_GET(_p) (&(_p)->Heap)
52#else
53 typedef HGSMIHEAP HGSMIGUESTCMDHEAP;
54# define HGSMIGUESTCMDHEAP_GET(_p) (_p)
55#endif
56
57RT_C_DECLS_BEGIN
58
59/**
60 * Structure grouping the context needed for submitting commands to the host
61 * via HGSMI
62 */
63typedef struct HGSMIGUESTCOMMANDCONTEXT
64{
65 /** Information about the memory heap located in VRAM from which data
66 * structures to be sent to the host are allocated. */
67 HGSMIGUESTCMDHEAP heapCtx;
68 /** The I/O port used for submitting commands to the host by writing their
69 * offsets into the heap. */
70 RTIOPORT port;
71} HGSMIGUESTCOMMANDCONTEXT, *PHGSMIGUESTCOMMANDCONTEXT;
72
73
74/**
75 * Structure grouping the context needed for receiving commands from the host
76 * via HGSMI
77 */
78typedef struct HGSMIHOSTCOMMANDCONTEXT
79{
80 /** Information about the memory area located in VRAM in which the host
81 * places data structures to be read by the guest. */
82 HGSMIAREA areaCtx;
83 /** Convenience structure used for matching host commands to handlers. */
84 /** @todo handlers are registered individually in code rather than just
85 * passing a static structure in order to gain extra flexibility. There is
86 * currently no expected usage case for this though. Is the additional
87 * complexity really justified? */
88 HGSMICHANNELINFO channels;
89 /** Flag to indicate that one thread is currently processing the command
90 * queue. */
91 volatile bool fHostCmdProcessing;
92 /* Pointer to the VRAM location where the HGSMI host flags are kept. */
93 volatile HGSMIHOSTFLAGS *pfHostFlags;
94 /** The I/O port used for receiving commands from the host as offsets into
95 * the memory area and sending back confirmations (command completion,
96 * IRQ acknowlegement). */
97 RTIOPORT port;
98} HGSMIHOSTCOMMANDCONTEXT, *PHGSMIHOSTCOMMANDCONTEXT;
99
100
101/**
102 * Structure grouping the context needed for sending graphics acceleration
103 * information to the host via VBVA. Each screen has its own VBVA buffer.
104 */
105typedef struct VBVABUFFERCONTEXT
106{
107 /** Offset of the buffer in the VRAM section for the screen */
108 uint32_t offVRAMBuffer;
109 /** Length of the buffer in bytes */
110 uint32_t cbBuffer;
111 /** This flag is set if we wrote to the buffer faster than the host could
112 * read it. */
113 bool fHwBufferOverflow;
114 /** The VBVA record that we are currently preparing for the host, NULL if
115 * none. */
116 struct VBVARECORD *pRecord;
117 /** Pointer to the VBVA buffer mapped into the current address space. Will
118 * be NULL if VBVA is not enabled. */
119 struct VBVABUFFER *pVBVA;
120} VBVABUFFERCONTEXT, *PVBVABUFFERCONTEXT;
121
122/** @name Helper functions
123 * @{ */
124/** Write an 8-bit value to an I/O port. */
125DECLINLINE(void) VBoxVideoCmnPortWriteUchar(RTIOPORT Port, uint8_t Value)
126{
127#ifdef VBOX_XPDM_MINIPORT
128 VideoPortWritePortUchar((PUCHAR)Port, Value);
129#elif defined VBOX_GUESTR3XORGMOD
130 outb(Port, Value);
131#else /** @todo make these explicit */
132 ASMOutU8(Port, Value);
133#endif
134}
135
136/** Write a 16-bit value to an I/O port. */
137DECLINLINE(void) VBoxVideoCmnPortWriteUshort(RTIOPORT Port, uint16_t Value)
138{
139#ifdef VBOX_XPDM_MINIPORT
140 VideoPortWritePortUshort((PUSHORT)Port,Value);
141#elif defined VBOX_GUESTR3XORGMOD
142 outw(Port, Value);
143#else
144 ASMOutU16(Port, Value);
145#endif
146}
147
148/** Write a 32-bit value to an I/O port. */
149DECLINLINE(void) VBoxVideoCmnPortWriteUlong(RTIOPORT Port, uint32_t Value)
150{
151#ifdef VBOX_XPDM_MINIPORT
152 VideoPortWritePortUlong((PULONG)Port,Value);
153#elif defined VBOX_GUESTR3XORGMOD
154 outl(Port, Value);
155#else
156 ASMOutU32(Port, Value);
157#endif
158}
159
160/** Read an 8-bit value from an I/O port. */
161DECLINLINE(uint8_t) VBoxVideoCmnPortReadUchar(RTIOPORT Port)
162{
163#ifdef VBOX_XPDM_MINIPORT
164 return VideoPortReadPortUchar((PUCHAR)Port);
165#elif defined VBOX_GUESTR3XORGMOD
166 return inb(Port);
167#else
168 return ASMInU8(Port);
169#endif
170}
171
172/** Read a 16-bit value from an I/O port. */
173DECLINLINE(uint16_t) VBoxVideoCmnPortReadUshort(RTIOPORT Port)
174{
175#ifdef VBOX_XPDM_MINIPORT
176 return VideoPortReadPortUshort((PUSHORT)Port);
177#elif defined VBOX_GUESTR3XORGMOD
178 return inw(Port);
179#else
180 return ASMInU16(Port);
181#endif
182}
183
184/** Read a 32-bit value from an I/O port. */
185DECLINLINE(uint32_t) VBoxVideoCmnPortReadUlong(RTIOPORT Port)
186{
187#ifdef VBOX_XPDM_MINIPORT
188 return VideoPortReadPortUlong((PULONG)Port);
189#elif defined VBOX_GUESTR3XORGMOD
190 return inl(Port);
191#else
192 return ASMInU32(Port);
193#endif
194}
195
196/** @} */
197
198/** @name Base HGSMI APIs
199 * @{ */
200
201/** Acknowlege an IRQ. */
202DECLINLINE(void) VBoxHGSMIClearIrq(PHGSMIHOSTCOMMANDCONTEXT pCtx)
203{
204 VBoxVideoCmnPortWriteUlong(pCtx->port, HGSMIOFFSET_VOID);
205}
206
207RTDECL(void) VBoxHGSMIHostCmdComplete(PHGSMIHOSTCOMMANDCONTEXT pCtx,
208 void *pvMem);
209RTDECL(void) VBoxHGSMIProcessHostQueue(PHGSMIHOSTCOMMANDCONTEXT pCtx);
210RTDECL(bool) VBoxHGSMIIsSupported(void);
211RTDECL(void *) VBoxHGSMIBufferAlloc(PHGSMIGUESTCOMMANDCONTEXT pCtx,
212 HGSMISIZE cbData,
213 uint8_t u8Ch,
214 uint16_t u16Op);
215RTDECL(void) VBoxHGSMIBufferFree(PHGSMIGUESTCOMMANDCONTEXT pCtx,
216 void *pvBuffer);
217RTDECL(int) VBoxHGSMIBufferSubmit(PHGSMIGUESTCOMMANDCONTEXT pCtx,
218 void *pvBuffer);
219RTDECL(void) VBoxHGSMIGetBaseMappingInfo(uint32_t cbVRAM,
220 uint32_t *poffVRAMBaseMapping,
221 uint32_t *pcbMapping,
222 uint32_t *poffGuestHeapMemory,
223 uint32_t *pcbGuestHeapMemory,
224 uint32_t *poffHostFlags);
225RTDECL(int) VBoxHGSMISendCapsInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx,
226 uint32_t fCaps);
227/** @todo we should provide a cleanup function too as part of the API */
228RTDECL(int) VBoxHGSMISetupGuestContext(PHGSMIGUESTCOMMANDCONTEXT pCtx,
229 void *pvGuestHeapMemory,
230 uint32_t cbGuestHeapMemory,
231 uint32_t offVRAMGuestHeapMemory,
232 const HGSMIENV *pEnv);
233RTDECL(void) VBoxHGSMIGetHostAreaMapping(PHGSMIGUESTCOMMANDCONTEXT pCtx,
234 uint32_t cbVRAM,
235 uint32_t offVRAMBaseMapping,
236 uint32_t *poffVRAMHostArea,
237 uint32_t *pcbHostArea);
238RTDECL(void) VBoxHGSMISetupHostContext(PHGSMIHOSTCOMMANDCONTEXT pCtx,
239 void *pvBaseMapping,
240 uint32_t offHostFlags,
241 void *pvHostAreaMapping,
242 uint32_t offVRAMHostArea,
243 uint32_t cbHostArea);
244RTDECL(int) VBoxHGSMISendHostCtxInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx,
245 HGSMIOFFSET offVRAMFlagsLocation,
246 uint32_t fCaps,
247 uint32_t offVRAMHostArea,
248 uint32_t cbHostArea);
249RTDECL(int) VBoxQueryConfHGSMI(PHGSMIGUESTCOMMANDCONTEXT pCtx,
250 uint32_t u32Index, uint32_t *pulValue);
251RTDECL(int) VBoxQueryConfHGSMIDef(PHGSMIGUESTCOMMANDCONTEXT pCtx,
252 uint32_t u32Index, uint32_t u32DefValue, uint32_t *pulValue);
253RTDECL(int) VBoxHGSMIUpdatePointerShape(PHGSMIGUESTCOMMANDCONTEXT pCtx,
254 uint32_t fFlags,
255 uint32_t cHotX,
256 uint32_t cHotY,
257 uint32_t cWidth,
258 uint32_t cHeight,
259 uint8_t *pPixels,
260 uint32_t cbLength);
261RTDECL(int) VBoxHGSMICursorPosition(PHGSMIGUESTCOMMANDCONTEXT pCtx, bool fReportPosition, uint32_t x, uint32_t y,
262 uint32_t *pxHost, uint32_t *pyHost);
263
264/** @} */
265
266/** @name VBVA APIs
267 * @{ */
268RTDECL(bool) VBoxVBVAEnable(PVBVABUFFERCONTEXT pCtx,
269 PHGSMIGUESTCOMMANDCONTEXT pHGSMICtx,
270 struct VBVABUFFER *pVBVA, int32_t cScreen);
271RTDECL(void) VBoxVBVADisable(PVBVABUFFERCONTEXT pCtx,
272 PHGSMIGUESTCOMMANDCONTEXT pHGSMICtx,
273 int32_t cScreen);
274RTDECL(bool) VBoxVBVABufferBeginUpdate(PVBVABUFFERCONTEXT pCtx,
275 PHGSMIGUESTCOMMANDCONTEXT pHGSMICtx);
276RTDECL(void) VBoxVBVABufferEndUpdate(PVBVABUFFERCONTEXT pCtx);
277RTDECL(bool) VBoxVBVAWrite(PVBVABUFFERCONTEXT pCtx,
278 PHGSMIGUESTCOMMANDCONTEXT pHGSMICtx,
279 const void *pv, uint32_t cb);
280RTDECL(bool) VBoxVBVAOrderSupported(PVBVABUFFERCONTEXT pCtx, unsigned code);
281RTDECL(void) VBoxVBVASetupBufferContext(PVBVABUFFERCONTEXT pCtx,
282 uint32_t offVRAMBuffer,
283 uint32_t cbBuffer);
284
285/** @} */
286
287/** @name Modesetting APIs
288 * @{ */
289
290RTDECL(uint32_t) VBoxHGSMIGetMonitorCount(PHGSMIGUESTCOMMANDCONTEXT pCtx);
291RTDECL(uint32_t) VBoxVideoGetVRAMSize(void);
292RTDECL(bool) VBoxVideoAnyWidthAllowed(void);
293RTDECL(uint16_t) VBoxHGSMIGetScreenFlags(PHGSMIGUESTCOMMANDCONTEXT pCtx);
294RTDECL(uint32_t) VBoxHGSMIGetMouseCursorFlags(PHGSMIGUESTCOMMANDCONTEXT pCtx);
295
296struct VBVAINFOVIEW;
297/**
298 * Callback funtion called from @a VBoxHGSMISendViewInfo to initialise
299 * the @a VBVAINFOVIEW structure for each screen.
300 *
301 * @returns iprt status code
302 * @param pvData context data for the callback, passed to @a
303 * VBoxHGSMISendViewInfo along with the callback
304 * @param pInfo array of @a VBVAINFOVIEW structures to be filled in
305 * @todo explicitly pass the array size
306 */
307typedef DECLCALLBACK(int) FNHGSMIFILLVIEWINFO(void *pvData,
308 struct VBVAINFOVIEW *pInfo,
309 uint32_t cViews);
310/** Pointer to a FNHGSMIFILLVIEWINFO callback */
311typedef FNHGSMIFILLVIEWINFO *PFNHGSMIFILLVIEWINFO;
312
313RTDECL(int) VBoxHGSMISendViewInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx,
314 uint32_t u32Count,
315 PFNHGSMIFILLVIEWINFO pfnFill,
316 void *pvData);
317RTDECL(void) VBoxVideoSetModeRegisters(uint16_t cWidth, uint16_t cHeight,
318 uint16_t cVirtWidth, uint16_t cBPP,
319 uint16_t fFlags,
320 uint16_t cx, uint16_t cy);
321RTDECL(bool) VBoxVideoGetModeRegisters(uint16_t *pcWidth,
322 uint16_t *pcHeight,
323 uint16_t *pcVirtWidth,
324 uint16_t *pcBPP,
325 uint16_t *pfFlags);
326RTDECL(void) VBoxVideoDisableVBE(void);
327RTDECL(void) VBoxHGSMIProcessDisplayInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx,
328 uint32_t cDisplay,
329 int32_t cOriginX,
330 int32_t cOriginY,
331 uint32_t offStart,
332 uint32_t cbPitch,
333 uint32_t cWidth,
334 uint32_t cHeight,
335 uint16_t cBPP,
336 uint16_t fFlags);
337RTDECL(int) VBoxHGSMIUpdateInputMapping(PHGSMIGUESTCOMMANDCONTEXT pCtx, int32_t cOriginX, int32_t cOriginY,
338 uint32_t cWidth, uint32_t cHeight);
339RTDECL(int) VBoxHGSMIGetModeHints(PHGSMIGUESTCOMMANDCONTEXT pCtx,
340 unsigned cScreens, VBVAMODEHINT *paHints);
341
342/** @} */
343
344RT_C_DECLS_END
345
346#endif /* __HGSMI_GUEST_h__*/
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