VirtualBox

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

Last change on this file since 55306 was 54565, checked in by vboxsync, 10 years ago

include,Additions: introduce VBVA_SCREEN_F_BLANK

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 13.6 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-2012 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) VBoxHGSMIUpdatePointerShape(PHGSMIGUESTCOMMANDCONTEXT pCtx,
252 uint32_t fFlags,
253 uint32_t cHotX,
254 uint32_t cHotY,
255 uint32_t cWidth,
256 uint32_t cHeight,
257 uint8_t *pPixels,
258 uint32_t cbLength);
259RTDECL(int) VBoxHGSMICursorPosition(PHGSMIGUESTCOMMANDCONTEXT pCtx, bool fReportPosition, uint32_t x, uint32_t y,
260 uint32_t *pxHost, uint32_t *pyHost);
261
262/** @} */
263
264/** @name VBVA APIs
265 * @{ */
266RTDECL(bool) VBoxVBVAEnable(PVBVABUFFERCONTEXT pCtx,
267 PHGSMIGUESTCOMMANDCONTEXT pHGSMICtx,
268 struct VBVABUFFER *pVBVA, int32_t cScreen);
269RTDECL(void) VBoxVBVADisable(PVBVABUFFERCONTEXT pCtx,
270 PHGSMIGUESTCOMMANDCONTEXT pHGSMICtx,
271 int32_t cScreen);
272RTDECL(bool) VBoxVBVABufferBeginUpdate(PVBVABUFFERCONTEXT pCtx,
273 PHGSMIGUESTCOMMANDCONTEXT pHGSMICtx);
274RTDECL(void) VBoxVBVABufferEndUpdate(PVBVABUFFERCONTEXT pCtx);
275RTDECL(bool) VBoxVBVAWrite(PVBVABUFFERCONTEXT pCtx,
276 PHGSMIGUESTCOMMANDCONTEXT pHGSMICtx,
277 const void *pv, uint32_t cb);
278RTDECL(bool) VBoxVBVAOrderSupported(PVBVABUFFERCONTEXT pCtx, unsigned code);
279RTDECL(void) VBoxVBVASetupBufferContext(PVBVABUFFERCONTEXT pCtx,
280 uint32_t offVRAMBuffer,
281 uint32_t cbBuffer);
282
283/** @} */
284
285/** @name Modesetting APIs
286 * @{ */
287
288RTDECL(uint32_t) VBoxHGSMIGetMonitorCount(PHGSMIGUESTCOMMANDCONTEXT pCtx);
289RTDECL(uint32_t) VBoxVideoGetVRAMSize(void);
290RTDECL(bool) VBoxVideoAnyWidthAllowed(void);
291RTDECL(uint16_t) VBoxHGSMIGetScreenFlags(PHGSMIGUESTCOMMANDCONTEXT pCtx);
292
293struct VBVAINFOVIEW;
294/**
295 * Callback funtion called from @a VBoxHGSMISendViewInfo to initialise
296 * the @a VBVAINFOVIEW structure for each screen.
297 *
298 * @returns iprt status code
299 * @param pvData context data for the callback, passed to @a
300 * VBoxHGSMISendViewInfo along with the callback
301 * @param pInfo array of @a VBVAINFOVIEW structures to be filled in
302 * @todo explicitly pass the array size
303 */
304typedef DECLCALLBACK(int) FNHGSMIFILLVIEWINFO(void *pvData,
305 struct VBVAINFOVIEW *pInfo,
306 uint32_t cViews);
307/** Pointer to a FNHGSMIFILLVIEWINFO callback */
308typedef FNHGSMIFILLVIEWINFO *PFNHGSMIFILLVIEWINFO;
309
310RTDECL(int) VBoxHGSMISendViewInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx,
311 uint32_t u32Count,
312 PFNHGSMIFILLVIEWINFO pfnFill,
313 void *pvData);
314RTDECL(void) VBoxVideoSetModeRegisters(uint16_t cWidth, uint16_t cHeight,
315 uint16_t cVirtWidth, uint16_t cBPP,
316 uint16_t fFlags,
317 uint16_t cx, uint16_t cy);
318RTDECL(bool) VBoxVideoGetModeRegisters(uint16_t *pcWidth,
319 uint16_t *pcHeight,
320 uint16_t *pcVirtWidth,
321 uint16_t *pcBPP,
322 uint16_t *pfFlags);
323RTDECL(void) VBoxVideoDisableVBE(void);
324RTDECL(void) VBoxHGSMIProcessDisplayInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx,
325 uint32_t cDisplay,
326 int32_t cOriginX,
327 int32_t cOriginY,
328 uint32_t offStart,
329 uint32_t cbPitch,
330 uint32_t cWidth,
331 uint32_t cHeight,
332 uint16_t cBPP,
333 uint16_t fFlags);
334RTDECL(int) VBoxHGSMIUpdateInputMapping(PHGSMIGUESTCOMMANDCONTEXT pCtx, int32_t cOriginX, int32_t cOriginY,
335 uint32_t cWidth, uint32_t cHeight);
336RTDECL(int) VBoxHGSMIGetModeHints(PHGSMIGUESTCOMMANDCONTEXT pCtx,
337 unsigned cScreens, VBVAMODEHINT *paHints);
338
339/** @} */
340
341RT_C_DECLS_END
342
343#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