VirtualBox

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

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

bugref:8087: Additions/x11: support non-root X server: add host flags location reporting to the kernel graphics driver in preparation for adding IRQ handling. Among other things, the host uses the flags, which it places at the location reported/requested by the guest in video RAM, to tell the guest what event the IRQ was sent in response to.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 13.9 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) VBoxHGSMIReportFlagsLocation(PHGSMIGUESTCOMMANDCONTEXT pCtx,
226 HGSMIOFFSET offLocation);
227RTDECL(int) VBoxHGSMISendCapsInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx,
228 uint32_t fCaps);
229/** @todo we should provide a cleanup function too as part of the API */
230RTDECL(int) VBoxHGSMISetupGuestContext(PHGSMIGUESTCOMMANDCONTEXT pCtx,
231 void *pvGuestHeapMemory,
232 uint32_t cbGuestHeapMemory,
233 uint32_t offVRAMGuestHeapMemory,
234 const HGSMIENV *pEnv);
235RTDECL(void) VBoxHGSMIGetHostAreaMapping(PHGSMIGUESTCOMMANDCONTEXT pCtx,
236 uint32_t cbVRAM,
237 uint32_t offVRAMBaseMapping,
238 uint32_t *poffVRAMHostArea,
239 uint32_t *pcbHostArea);
240RTDECL(void) VBoxHGSMISetupHostContext(PHGSMIHOSTCOMMANDCONTEXT pCtx,
241 void *pvBaseMapping,
242 uint32_t offHostFlags,
243 void *pvHostAreaMapping,
244 uint32_t offVRAMHostArea,
245 uint32_t cbHostArea);
246RTDECL(int) VBoxHGSMISendHostCtxInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx,
247 HGSMIOFFSET offVRAMFlagsLocation,
248 uint32_t fCaps,
249 uint32_t offVRAMHostArea,
250 uint32_t cbHostArea);
251RTDECL(int) VBoxQueryConfHGSMI(PHGSMIGUESTCOMMANDCONTEXT pCtx,
252 uint32_t u32Index, uint32_t *pulValue);
253RTDECL(int) VBoxQueryConfHGSMIDef(PHGSMIGUESTCOMMANDCONTEXT pCtx,
254 uint32_t u32Index, uint32_t u32DefValue, uint32_t *pulValue);
255RTDECL(int) VBoxHGSMIUpdatePointerShape(PHGSMIGUESTCOMMANDCONTEXT pCtx,
256 uint32_t fFlags,
257 uint32_t cHotX,
258 uint32_t cHotY,
259 uint32_t cWidth,
260 uint32_t cHeight,
261 uint8_t *pPixels,
262 uint32_t cbLength);
263RTDECL(int) VBoxHGSMICursorPosition(PHGSMIGUESTCOMMANDCONTEXT pCtx, bool fReportPosition, uint32_t x, uint32_t y,
264 uint32_t *pxHost, uint32_t *pyHost);
265
266/** @} */
267
268/** @name VBVA APIs
269 * @{ */
270RTDECL(bool) VBoxVBVAEnable(PVBVABUFFERCONTEXT pCtx,
271 PHGSMIGUESTCOMMANDCONTEXT pHGSMICtx,
272 struct VBVABUFFER *pVBVA, int32_t cScreen);
273RTDECL(void) VBoxVBVADisable(PVBVABUFFERCONTEXT pCtx,
274 PHGSMIGUESTCOMMANDCONTEXT pHGSMICtx,
275 int32_t cScreen);
276RTDECL(bool) VBoxVBVABufferBeginUpdate(PVBVABUFFERCONTEXT pCtx,
277 PHGSMIGUESTCOMMANDCONTEXT pHGSMICtx);
278RTDECL(void) VBoxVBVABufferEndUpdate(PVBVABUFFERCONTEXT pCtx);
279RTDECL(bool) VBoxVBVAWrite(PVBVABUFFERCONTEXT pCtx,
280 PHGSMIGUESTCOMMANDCONTEXT pHGSMICtx,
281 const void *pv, uint32_t cb);
282RTDECL(bool) VBoxVBVAOrderSupported(PVBVABUFFERCONTEXT pCtx, unsigned code);
283RTDECL(void) VBoxVBVASetupBufferContext(PVBVABUFFERCONTEXT pCtx,
284 uint32_t offVRAMBuffer,
285 uint32_t cbBuffer);
286
287/** @} */
288
289/** @name Modesetting APIs
290 * @{ */
291
292RTDECL(uint32_t) VBoxHGSMIGetMonitorCount(PHGSMIGUESTCOMMANDCONTEXT pCtx);
293RTDECL(uint32_t) VBoxVideoGetVRAMSize(void);
294RTDECL(bool) VBoxVideoAnyWidthAllowed(void);
295RTDECL(uint16_t) VBoxHGSMIGetScreenFlags(PHGSMIGUESTCOMMANDCONTEXT pCtx);
296
297struct VBVAINFOVIEW;
298/**
299 * Callback funtion called from @a VBoxHGSMISendViewInfo to initialise
300 * the @a VBVAINFOVIEW structure for each screen.
301 *
302 * @returns iprt status code
303 * @param pvData context data for the callback, passed to @a
304 * VBoxHGSMISendViewInfo along with the callback
305 * @param pInfo array of @a VBVAINFOVIEW structures to be filled in
306 * @todo explicitly pass the array size
307 */
308typedef DECLCALLBACK(int) FNHGSMIFILLVIEWINFO(void *pvData,
309 struct VBVAINFOVIEW *pInfo,
310 uint32_t cViews);
311/** Pointer to a FNHGSMIFILLVIEWINFO callback */
312typedef FNHGSMIFILLVIEWINFO *PFNHGSMIFILLVIEWINFO;
313
314RTDECL(int) VBoxHGSMISendViewInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx,
315 uint32_t u32Count,
316 PFNHGSMIFILLVIEWINFO pfnFill,
317 void *pvData);
318RTDECL(void) VBoxVideoSetModeRegisters(uint16_t cWidth, uint16_t cHeight,
319 uint16_t cVirtWidth, uint16_t cBPP,
320 uint16_t fFlags,
321 uint16_t cx, uint16_t cy);
322RTDECL(bool) VBoxVideoGetModeRegisters(uint16_t *pcWidth,
323 uint16_t *pcHeight,
324 uint16_t *pcVirtWidth,
325 uint16_t *pcBPP,
326 uint16_t *pfFlags);
327RTDECL(void) VBoxVideoDisableVBE(void);
328RTDECL(void) VBoxHGSMIProcessDisplayInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx,
329 uint32_t cDisplay,
330 int32_t cOriginX,
331 int32_t cOriginY,
332 uint32_t offStart,
333 uint32_t cbPitch,
334 uint32_t cWidth,
335 uint32_t cHeight,
336 uint16_t cBPP,
337 uint16_t fFlags);
338RTDECL(int) VBoxHGSMIUpdateInputMapping(PHGSMIGUESTCOMMANDCONTEXT pCtx, int32_t cOriginX, int32_t cOriginY,
339 uint32_t cWidth, uint32_t cHeight);
340RTDECL(int) VBoxHGSMIGetModeHints(PHGSMIGUESTCOMMANDCONTEXT pCtx,
341 unsigned cScreens, VBVAMODEHINT *paHints);
342
343/** @} */
344
345RT_C_DECLS_END
346
347#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