1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox Host Guest Shared Memory Interface (HGSMI).
|
---|
4 | * OS-independent guest structures.
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2008 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 |
|
---|
35 | #ifdef VBOX_XPDM_MINIPORT
|
---|
36 | RT_C_DECLS_BEGIN
|
---|
37 | # include "miniport.h"
|
---|
38 | # include "ntddvdeo.h"
|
---|
39 | # include <Video.h>
|
---|
40 | RT_C_DECLS_END
|
---|
41 | #else
|
---|
42 | # include <iprt/asm-amd64-x86.h>
|
---|
43 | #endif
|
---|
44 |
|
---|
45 | RT_C_DECLS_BEGIN
|
---|
46 |
|
---|
47 | /**
|
---|
48 | * Structure grouping the context needed for submitting commands to the host
|
---|
49 | * via HGSMI
|
---|
50 | */
|
---|
51 | typedef struct HGSMIGUESTCOMMANDCONTEXT
|
---|
52 | {
|
---|
53 | /** Information about the memory heap located in VRAM from which data
|
---|
54 | * structures to be sent to the host are allocated. */
|
---|
55 | HGSMIHEAP heapCtx;
|
---|
56 | /** The I/O port used for submitting commands to the host by writing their
|
---|
57 | * offsets into the heap. */
|
---|
58 | RTIOPORT port;
|
---|
59 | } HGSMIGUESTCOMMANDCONTEXT, *PHGSMIGUESTCOMMANDCONTEXT;
|
---|
60 |
|
---|
61 |
|
---|
62 | /**
|
---|
63 | * Structure grouping the context needed for receiving commands from the host
|
---|
64 | * via HGSMI
|
---|
65 | */
|
---|
66 | typedef struct HGSMIHOSTCOMMANDCONTEXT
|
---|
67 | {
|
---|
68 | /** Information about the memory area located in VRAM in which the host
|
---|
69 | * places data structures to be read by the guest. */
|
---|
70 | HGSMIAREA areaCtx;
|
---|
71 | /** Convenience structure used for matching host commands to handlers. */
|
---|
72 | /** @todo handlers are registered individually in code rather than just
|
---|
73 | * passing a static structure in order to gain extra flexibility. There is
|
---|
74 | * currently no expected usage case for this though. Is the additional
|
---|
75 | * complexity really justified? */
|
---|
76 | HGSMICHANNELINFO channels;
|
---|
77 | /** Flag to indicate that one thread is currently processing the command
|
---|
78 | * queue. */
|
---|
79 | volatile bool fHostCmdProcessing;
|
---|
80 | /* Pointer to the VRAM location where the HGSMI host flags are kept. */
|
---|
81 | volatile HGSMIHOSTFLAGS *pfHostFlags;
|
---|
82 | /** The I/O port used for receiving commands from the host as offsets into
|
---|
83 | * the memory area and sending back confirmations (command completion,
|
---|
84 | * IRQ acknowlegement). */
|
---|
85 | RTIOPORT port;
|
---|
86 | } HGSMIHOSTCOMMANDCONTEXT, *PHGSMIHOSTCOMMANDCONTEXT;
|
---|
87 |
|
---|
88 |
|
---|
89 | /**
|
---|
90 | * Structure grouping the context needed for sending graphics acceleration
|
---|
91 | * information to the host via VBVA. Each screen has its own VBVA buffer.
|
---|
92 | */
|
---|
93 | typedef struct VBVABUFFERCONTEXT
|
---|
94 | {
|
---|
95 | /** Offset of the buffer in the VRAM section for the screen */
|
---|
96 | uint32_t offVRAMBuffer;
|
---|
97 | /** Length of the buffer in bytes */
|
---|
98 | uint32_t cbBuffer;
|
---|
99 | /** This flag is set if we wrote to the buffer faster than the host could
|
---|
100 | * read it. */
|
---|
101 | bool fHwBufferOverflow;
|
---|
102 | /** The VBVA record that we are currently preparing for the host, NULL if
|
---|
103 | * none. */
|
---|
104 | struct VBVARECORD *pRecord;
|
---|
105 | /** Pointer to the VBVA buffer mapped into the current address space. Will
|
---|
106 | * be NULL if VBVA is not enabled. */
|
---|
107 | struct VBVABUFFER *pVBVA;
|
---|
108 | } VBVABUFFERCONTEXT, *PVBVABUFFERCONTEXT;
|
---|
109 |
|
---|
110 | /** @name Helper functions
|
---|
111 | * @{ */
|
---|
112 | /** Write an 8-bit value to an I/O port. */
|
---|
113 | DECLINLINE(void) VBoxVideoCmnPortWriteUchar(RTIOPORT Port, uint8_t Value)
|
---|
114 | {
|
---|
115 | #ifdef VBOX_XPDM_MINIPORT
|
---|
116 | VideoPortWritePortUchar((PUCHAR)Port, Value);
|
---|
117 | #else /** @todo make these explicit */
|
---|
118 | ASMOutU8(Port, Value);
|
---|
119 | #endif
|
---|
120 | }
|
---|
121 |
|
---|
122 | /** Write a 16-bit value to an I/O port. */
|
---|
123 | DECLINLINE(void) VBoxVideoCmnPortWriteUshort(RTIOPORT Port, uint16_t Value)
|
---|
124 | {
|
---|
125 | #ifdef VBOX_XPDM_MINIPORT
|
---|
126 | VideoPortWritePortUshort((PUSHORT)Port,Value);
|
---|
127 | #else
|
---|
128 | ASMOutU16(Port, Value);
|
---|
129 | #endif
|
---|
130 | }
|
---|
131 |
|
---|
132 | /** Write a 32-bit value to an I/O port. */
|
---|
133 | DECLINLINE(void) VBoxVideoCmnPortWriteUlong(RTIOPORT Port, uint32_t Value)
|
---|
134 | {
|
---|
135 | #ifdef VBOX_XPDM_MINIPORT
|
---|
136 | VideoPortWritePortUlong((PULONG)Port,Value);
|
---|
137 | #else
|
---|
138 | ASMOutU32(Port, Value);
|
---|
139 | #endif
|
---|
140 | }
|
---|
141 |
|
---|
142 | /** Read an 8-bit value from an I/O port. */
|
---|
143 | DECLINLINE(uint8_t) VBoxVideoCmnPortReadUchar(RTIOPORT Port)
|
---|
144 | {
|
---|
145 | #ifdef VBOX_XPDM_MINIPORT
|
---|
146 | return VideoPortReadPortUchar((PUCHAR)Port);
|
---|
147 | #else
|
---|
148 | return ASMInU8(Port);
|
---|
149 | #endif
|
---|
150 | }
|
---|
151 |
|
---|
152 | /** Read a 16-bit value from an I/O port. */
|
---|
153 | DECLINLINE(uint16_t) VBoxVideoCmnPortReadUshort(RTIOPORT Port)
|
---|
154 | {
|
---|
155 | #ifdef VBOX_XPDM_MINIPORT
|
---|
156 | return VideoPortReadPortUshort((PUSHORT)Port);
|
---|
157 | #else
|
---|
158 | return ASMInU16(Port);
|
---|
159 | #endif
|
---|
160 | }
|
---|
161 |
|
---|
162 | /** Read a 32-bit value from an I/O port. */
|
---|
163 | DECLINLINE(uint32_t) VBoxVideoCmnPortReadUlong(RTIOPORT Port)
|
---|
164 | {
|
---|
165 | #ifdef VBOX_XPDM_MINIPORT
|
---|
166 | return VideoPortReadPortUlong((PULONG)Port);
|
---|
167 | #else
|
---|
168 | return ASMInU32(Port);
|
---|
169 | #endif
|
---|
170 | }
|
---|
171 |
|
---|
172 | /** @} */
|
---|
173 |
|
---|
174 | /** @name Base HGSMI APIs
|
---|
175 | * @{ */
|
---|
176 |
|
---|
177 | /** Acknowlege an IRQ. */
|
---|
178 | DECLINLINE(void) VBoxHGSMIClearIrq(PHGSMIHOSTCOMMANDCONTEXT pCtx)
|
---|
179 | {
|
---|
180 | VBoxVideoCmnPortWriteUlong(pCtx->port, HGSMIOFFSET_VOID);
|
---|
181 | }
|
---|
182 |
|
---|
183 | RTDECL(void) VBoxHGSMIHostCmdComplete(PHGSMIHOSTCOMMANDCONTEXT pCtx,
|
---|
184 | void *pvMem);
|
---|
185 | RTDECL(void) VBoxHGSMIProcessHostQueue(PHGSMIHOSTCOMMANDCONTEXT pCtx);
|
---|
186 | RTDECL(bool) VBoxHGSMIIsSupported(void);
|
---|
187 | RTDECL(void *) VBoxHGSMIBufferAlloc(PHGSMIGUESTCOMMANDCONTEXT pCtx,
|
---|
188 | HGSMISIZE cbData,
|
---|
189 | uint8_t u8Ch,
|
---|
190 | uint16_t u16Op);
|
---|
191 | RTDECL(void) VBoxHGSMIBufferFree(PHGSMIGUESTCOMMANDCONTEXT pCtx,
|
---|
192 | void *pvBuffer);
|
---|
193 | RTDECL(int) VBoxHGSMIBufferSubmit(PHGSMIGUESTCOMMANDCONTEXT pCtx,
|
---|
194 | void *pvBuffer);
|
---|
195 | RTDECL(void) VBoxHGSMIGetBaseMappingInfo(uint32_t cbVRAM,
|
---|
196 | uint32_t *poffVRAMBaseMapping,
|
---|
197 | uint32_t *pcbMapping,
|
---|
198 | uint32_t *poffGuestHeapMemory,
|
---|
199 | uint32_t *pcbGuestHeapMemory,
|
---|
200 | uint32_t *poffHostFlags);
|
---|
201 | /** @todo we should provide a cleanup function too as part of the API */
|
---|
202 | RTDECL(int) VBoxHGSMISetupGuestContext(PHGSMIGUESTCOMMANDCONTEXT pCtx,
|
---|
203 | void *pvGuestHeapMemory,
|
---|
204 | uint32_t cbGuestHeapMemory,
|
---|
205 | uint32_t offVRAMGuestHeapMemory);
|
---|
206 | RTDECL(void) VBoxHGSMIGetHostAreaMapping(PHGSMIGUESTCOMMANDCONTEXT pCtx,
|
---|
207 | uint32_t cbVRAM,
|
---|
208 | uint32_t offVRAMBaseMapping,
|
---|
209 | uint32_t *poffVRAMHostArea,
|
---|
210 | uint32_t *pcbHostArea);
|
---|
211 | RTDECL(void) VBoxHGSMISetupHostContext(PHGSMIHOSTCOMMANDCONTEXT pCtx,
|
---|
212 | void *pvBaseMapping,
|
---|
213 | uint32_t offHostFlags,
|
---|
214 | void *pvHostAreaMapping,
|
---|
215 | uint32_t offVRAMHostArea,
|
---|
216 | uint32_t cbHostArea);
|
---|
217 | RTDECL(int) VBoxHGSMISendHostCtxInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx,
|
---|
218 | HGSMIOFFSET offVRAMFlagsLocation,
|
---|
219 | uint32_t fCaps,
|
---|
220 | uint32_t offVRAMHostArea,
|
---|
221 | uint32_t cbHostArea);
|
---|
222 | RTDECL(int) VBoxQueryConfHGSMI(PHGSMIGUESTCOMMANDCONTEXT pCtx,
|
---|
223 | uint32_t u32Index, uint32_t *pulValue);
|
---|
224 | RTDECL(bool) VBoxHGSMIUpdatePointerShape(PHGSMIGUESTCOMMANDCONTEXT pCtx,
|
---|
225 | uint32_t fFlags,
|
---|
226 | uint32_t cHotX,
|
---|
227 | uint32_t cHotY,
|
---|
228 | uint32_t cWidth,
|
---|
229 | uint32_t cHeight,
|
---|
230 | uint8_t *pPixels,
|
---|
231 | uint32_t cbLength);
|
---|
232 |
|
---|
233 | /** @} */
|
---|
234 |
|
---|
235 | /** @name VBVA APIs
|
---|
236 | * @{ */
|
---|
237 | RTDECL(bool) VBoxVBVAEnable(PVBVABUFFERCONTEXT pCtx,
|
---|
238 | PHGSMIGUESTCOMMANDCONTEXT pHGSMICtx,
|
---|
239 | struct VBVABUFFER *pVBVA, int32_t cScreen);
|
---|
240 | RTDECL(void) VBoxVBVADisable(PVBVABUFFERCONTEXT pCtx,
|
---|
241 | PHGSMIGUESTCOMMANDCONTEXT pHGSMICtx,
|
---|
242 | int32_t cScreen);
|
---|
243 | RTDECL(bool) VBoxVBVABufferBeginUpdate(PVBVABUFFERCONTEXT pCtx,
|
---|
244 | PHGSMIGUESTCOMMANDCONTEXT pHGSMICtx);
|
---|
245 | RTDECL(void) VBoxVBVABufferEndUpdate(PVBVABUFFERCONTEXT pCtx);
|
---|
246 | RTDECL(bool) VBoxVBVAWrite(PVBVABUFFERCONTEXT pCtx,
|
---|
247 | PHGSMIGUESTCOMMANDCONTEXT pHGSMICtx,
|
---|
248 | const void *pv, uint32_t cb);
|
---|
249 | RTDECL(bool) VBoxVBVAOrderSupported(PVBVABUFFERCONTEXT pCtx, unsigned code);
|
---|
250 | RTDECL(void) VBoxVBVASetupBufferContext(PVBVABUFFERCONTEXT pCtx,
|
---|
251 | uint32_t offVRAMBuffer,
|
---|
252 | uint32_t cbBuffer);
|
---|
253 |
|
---|
254 | /** @} */
|
---|
255 |
|
---|
256 | /** @name Modesetting APIs
|
---|
257 | * @{ */
|
---|
258 |
|
---|
259 | RTDECL(uint32_t) VBoxHGSMIGetMonitorCount(PHGSMIGUESTCOMMANDCONTEXT pCtx);
|
---|
260 |
|
---|
261 | struct VBVAINFOVIEW;
|
---|
262 | /**
|
---|
263 | * Callback funtion called from @a VBoxHGSMISendViewInfo to initialise
|
---|
264 | * the @a VBVAINFOVIEW structure for each screen.
|
---|
265 | *
|
---|
266 | * @returns iprt status code
|
---|
267 | * @param pvData context data for the callback, passed to @a
|
---|
268 | * VBoxHGSMISendViewInfo along with the callback
|
---|
269 | * @param pInfo array of @a VBVAINFOVIEW structures to be filled in
|
---|
270 | * @todo explicitly pass the array size
|
---|
271 | */
|
---|
272 | typedef DECLCALLBACK(int) FNHGSMIFILLVIEWINFO(void *pvData,
|
---|
273 | struct VBVAINFOVIEW *pInfo,
|
---|
274 | uint32_t cViews);
|
---|
275 | /** Pointer to a FNHGSMIFILLVIEWINFO callback */
|
---|
276 | typedef FNHGSMIFILLVIEWINFO *PFNHGSMIFILLVIEWINFO;
|
---|
277 |
|
---|
278 | RTDECL(int) VBoxHGSMISendViewInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx,
|
---|
279 | uint32_t u32Count,
|
---|
280 | PFNHGSMIFILLVIEWINFO pfnFill,
|
---|
281 | void *pvData);
|
---|
282 | RTDECL(void) VBoxVideoSetModeRegisters(uint16_t cWidth, uint16_t cHeight,
|
---|
283 | uint16_t cVirtWidth, uint16_t cBPP,
|
---|
284 | uint16_t cx, uint16_t cy);
|
---|
285 | RTDECL(void) VBoxHGSMIProcessDisplayInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx,
|
---|
286 | uint32_t cDisplay,
|
---|
287 | int32_t cOriginX,
|
---|
288 | int32_t cOriginY,
|
---|
289 | uint32_t offStart,
|
---|
290 | uint32_t cbPitch,
|
---|
291 | uint32_t cWidth,
|
---|
292 | uint32_t cHeight,
|
---|
293 | uint16_t cBPP);
|
---|
294 |
|
---|
295 | /** @} */
|
---|
296 |
|
---|
297 | RT_C_DECLS_END
|
---|
298 |
|
---|
299 | #endif /* __HGSMI_GUEST_h__*/
|
---|