1 | /* $Id: VBoxMPIOCTL.cpp 44529 2013-02-04 15:54:15Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | * VBox XPDM Miniport IOCTL handlers
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2011-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 |
|
---|
19 | #include "VBoxMPInternal.h"
|
---|
20 | #include "common/VBoxMPCommon.h"
|
---|
21 | #include <VBox/Hardware/VBoxVideoVBE.h>
|
---|
22 | #include <VBox/VBoxGuestLib.h>
|
---|
23 | #include <VBox/VBoxVideo.h>
|
---|
24 |
|
---|
25 | /* Note: in/out parameters passed to VBoxDrvStartIO point to the same memory location.
|
---|
26 | * That means we can't read anything from the input one after first write to the output.
|
---|
27 | * Defines below are somewhat silly way to catch possible misuse at compile time.
|
---|
28 | */
|
---|
29 | #define VBOXMPIOCTL_HIDE(_var) \
|
---|
30 | { \
|
---|
31 | PVOID (_var); \
|
---|
32 | (VOID)(_var)
|
---|
33 |
|
---|
34 | #define VBOXMPIOCTL_UNHIDE() \
|
---|
35 | }
|
---|
36 |
|
---|
37 | /* Called for IOCTL_VIDEO_RESET_DEVICE.
|
---|
38 | * Reset device to a state it comes at system boot time.
|
---|
39 | * @todo It doesn't do anythyng at the moment, but it looks like the same as VBoxDrvResetHW.
|
---|
40 | */
|
---|
41 | BOOLEAN VBoxMPResetDevice(PVBOXMP_DEVEXT pExt, PSTATUS_BLOCK pStatus)
|
---|
42 | {
|
---|
43 | LOGF_ENTER();
|
---|
44 |
|
---|
45 | if (pExt->iDevice>0)
|
---|
46 | {
|
---|
47 | LOG(("skipping non-primary display %d", pExt->iDevice));
|
---|
48 | return TRUE;
|
---|
49 | }
|
---|
50 |
|
---|
51 | #if 0
|
---|
52 | /* Don't disable the extended video mode. This would only switch the video mode
|
---|
53 | * to <current width> x <current height> x 0 bpp which is not what we want. And
|
---|
54 | * even worse, it causes an disturbing additional mode switch */
|
---|
55 | VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ENABLE);
|
---|
56 | VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_DATA, VBE_DISPI_DISABLED);
|
---|
57 | #endif
|
---|
58 |
|
---|
59 | /* Tell the host that we no longer support graphics in the additions */
|
---|
60 | /* @todo VBoxMPSetGraphicsCap(FALSE); */
|
---|
61 |
|
---|
62 | LOGF_LEAVE();
|
---|
63 | return TRUE;
|
---|
64 | }
|
---|
65 |
|
---|
66 | /* Called for IOCTL_VIDEO_MAP_VIDEO_MEMORY.
|
---|
67 | * Maps FrameBuffer and video RAM to a caller's virtual adress space.
|
---|
68 | */
|
---|
69 | BOOLEAN VBoxMPMapVideoMemory(PVBOXMP_DEVEXT pExt, PVIDEO_MEMORY pRequestedAddress,
|
---|
70 | PVIDEO_MEMORY_INFORMATION pMapInfo, PSTATUS_BLOCK pStatus)
|
---|
71 | {
|
---|
72 | PHYSICAL_ADDRESS framebuffer;
|
---|
73 | ULONG inIoSpace = 0;
|
---|
74 |
|
---|
75 | LOGF(("framebuffer offset %#x", pExt->ulFrameBufferOffset));
|
---|
76 |
|
---|
77 | framebuffer.QuadPart = VBoxCommonFromDeviceExt(pExt)->phVRAM.QuadPart + pExt->ulFrameBufferOffset;
|
---|
78 |
|
---|
79 | pMapInfo->VideoRamBase = pRequestedAddress->RequestedVirtualAddress;
|
---|
80 | VBOXMPIOCTL_HIDE(pRequestedAddress);
|
---|
81 | pMapInfo->VideoRamLength = pExt->pPrimary->u.primary.ulMaxFrameBufferSize;
|
---|
82 |
|
---|
83 | pStatus->Status = VideoPortMapMemory(pExt, framebuffer, &pMapInfo->VideoRamLength,
|
---|
84 | &inIoSpace, &pMapInfo->VideoRamBase);
|
---|
85 |
|
---|
86 | if (NO_ERROR == pStatus->Status)
|
---|
87 | {
|
---|
88 | pMapInfo->FrameBufferBase = (PUCHAR)pMapInfo->VideoRamBase;
|
---|
89 | pMapInfo->FrameBufferLength =
|
---|
90 | VBoxMPXpdmCurrentVideoMode(pExt)->VisScreenHeight*
|
---|
91 | VBoxMPXpdmCurrentVideoMode(pExt)->ScreenStride;
|
---|
92 |
|
---|
93 | pStatus->Information = sizeof(VIDEO_MEMORY_INFORMATION);
|
---|
94 |
|
---|
95 | /* Save the new framebuffer size */
|
---|
96 | pExt->ulFrameBufferSize = pMapInfo->FrameBufferLength;
|
---|
97 | HGSMIAreaInitialize(&pExt->areaDisplay, pMapInfo->FrameBufferBase,
|
---|
98 | pMapInfo->FrameBufferLength, pExt->ulFrameBufferOffset);
|
---|
99 | }
|
---|
100 |
|
---|
101 | VBOXMPIOCTL_UNHIDE();
|
---|
102 | LOGF_LEAVE();
|
---|
103 | return NO_ERROR == pStatus->Status;
|
---|
104 | }
|
---|
105 |
|
---|
106 | /* Called for IOCTL_VIDEO_UNMAP_VIDEO_MEMORY.
|
---|
107 | * Unmaps previously mapped FrameBuffer and video RAM from caller's virtual adress space.
|
---|
108 | */
|
---|
109 | BOOLEAN VBoxMPUnmapVideoMemory(PVBOXMP_DEVEXT pExt, PVIDEO_MEMORY VideoMemory, PSTATUS_BLOCK pStatus)
|
---|
110 | {
|
---|
111 | LOGF_ENTER();
|
---|
112 |
|
---|
113 | HGSMIAreaClear(&pExt->areaDisplay);
|
---|
114 | pStatus->Status = VideoPortUnmapMemory(pExt, VideoMemory->RequestedVirtualAddress, NULL);
|
---|
115 |
|
---|
116 | LOGF_LEAVE();
|
---|
117 | return TRUE;
|
---|
118 | }
|
---|
119 |
|
---|
120 | /* Called for IOCTL_VIDEO_SHARE_VIDEO_MEMORY.
|
---|
121 | * Maps FrameBuffer as a linear frame buffer to a caller's virtual adress space. (obsolete).
|
---|
122 | */
|
---|
123 | BOOLEAN VBoxMPShareVideoMemory(PVBOXMP_DEVEXT pExt, PVIDEO_SHARE_MEMORY pShareMem,
|
---|
124 | PVIDEO_SHARE_MEMORY_INFORMATION pShareMemInfo, PSTATUS_BLOCK pStatus)
|
---|
125 | {
|
---|
126 | PHYSICAL_ADDRESS shareAddress;
|
---|
127 | ULONG inIoSpace = 0;
|
---|
128 | ULONG offset, size;
|
---|
129 | PVOID virtualAddress;
|
---|
130 | ULONG ulMaxFBSize;
|
---|
131 |
|
---|
132 | LOGF_ENTER();
|
---|
133 |
|
---|
134 | ulMaxFBSize = pExt->pPrimary->u.primary.ulMaxFrameBufferSize;
|
---|
135 | offset = pShareMem->ViewOffset;
|
---|
136 | size = pShareMem->ViewSize;
|
---|
137 | virtualAddress = pShareMem->ProcessHandle;
|
---|
138 | VBOXMPIOCTL_HIDE(pShareMem);
|
---|
139 |
|
---|
140 | if ((offset>ulMaxFBSize) || ((offset+size)>ulMaxFBSize))
|
---|
141 | {
|
---|
142 | WARN(("share failed offset:size(%#x:%#x) > %#x fb size.", offset, size, ulMaxFBSize));
|
---|
143 | pStatus->Status = ERROR_INVALID_PARAMETER;
|
---|
144 | return FALSE;
|
---|
145 | }
|
---|
146 |
|
---|
147 | shareAddress.QuadPart = VBoxCommonFromDeviceExt(pExt)->phVRAM.QuadPart + pExt->ulFrameBufferOffset;
|
---|
148 |
|
---|
149 | pStatus->Status = VideoPortMapMemory(pExt, shareAddress, &size, &inIoSpace, &virtualAddress);
|
---|
150 |
|
---|
151 | if (NO_ERROR == pStatus->Status)
|
---|
152 | {
|
---|
153 | pShareMemInfo->SharedViewOffset = offset;
|
---|
154 | pShareMemInfo->SharedViewSize = size;
|
---|
155 | pShareMemInfo->VirtualAddress = virtualAddress;
|
---|
156 |
|
---|
157 | pStatus->Information = sizeof(VIDEO_SHARE_MEMORY_INFORMATION);
|
---|
158 | }
|
---|
159 |
|
---|
160 | VBOXMPIOCTL_UNHIDE();
|
---|
161 | LOGF_LEAVE();
|
---|
162 | return NO_ERROR == pStatus->Status;
|
---|
163 | }
|
---|
164 |
|
---|
165 | /* Called for IOCTL_VIDEO_UNSHARE_VIDEO_MEMORY.
|
---|
166 | * Unmaps framebuffer previously mapped with IOCTL_VIDEO_SHARE_VIDEO_MEMORY.
|
---|
167 | */
|
---|
168 | BOOLEAN VBoxMPUnshareVideoMemory(PVBOXMP_DEVEXT pExt, PVIDEO_SHARE_MEMORY pMem, PSTATUS_BLOCK pStatus)
|
---|
169 | {
|
---|
170 | LOGF_ENTER();
|
---|
171 |
|
---|
172 | pStatus->Status = VideoPortUnmapMemory(pExt, pMem->RequestedVirtualAddress, pMem->ProcessHandle);
|
---|
173 |
|
---|
174 | LOGF_LEAVE();
|
---|
175 | return TRUE;
|
---|
176 | }
|
---|
177 |
|
---|
178 | /* Called for IOCTL_VIDEO_SET_CURRENT_MODE.
|
---|
179 | * Sets adapter video mode.
|
---|
180 | */
|
---|
181 | BOOLEAN VBoxMPSetCurrentMode(PVBOXMP_DEVEXT pExt, PVIDEO_MODE pMode, PSTATUS_BLOCK pStatus)
|
---|
182 | {
|
---|
183 | ULONG RequestedMode;
|
---|
184 | VIDEO_MODE_INFORMATION *pModeInfo;
|
---|
185 |
|
---|
186 | LOGF(("mode=%#x", pMode->RequestedMode));
|
---|
187 |
|
---|
188 | /* Get requested mode info */
|
---|
189 | RequestedMode = pMode->RequestedMode & ~(VIDEO_MODE_NO_ZERO_MEMORY|VIDEO_MODE_MAP_MEM_LINEAR);
|
---|
190 | if (RequestedMode!=pMode->RequestedMode)
|
---|
191 | {
|
---|
192 | WARN(("ignoring set VIDEO_MODE_NO_ZERO_MEMORY or VIDEO_MODE_MAP_MEM_LINEAR"));
|
---|
193 | }
|
---|
194 |
|
---|
195 | pModeInfo = VBoxMPCmnGetVideoModeInfo(RequestedMode-1);
|
---|
196 | if (!pModeInfo)
|
---|
197 | {
|
---|
198 | pStatus->Status = ERROR_INVALID_PARAMETER;
|
---|
199 | return FALSE;
|
---|
200 | }
|
---|
201 |
|
---|
202 | LOG(("width %d, height %d, bpp %d",
|
---|
203 | pModeInfo->VisScreenWidth, pModeInfo->VisScreenHeight, pModeInfo->BitsPerPlane));
|
---|
204 |
|
---|
205 | /* Update device info */
|
---|
206 | pExt->CurrentMode = RequestedMode;
|
---|
207 | pExt->CurrentModeWidth = pModeInfo->VisScreenWidth;
|
---|
208 | pExt->CurrentModeHeight = pModeInfo->VisScreenHeight;
|
---|
209 | pExt->CurrentModeBPP = pModeInfo->BitsPerPlane;
|
---|
210 |
|
---|
211 | if (pExt->iDevice>0)
|
---|
212 | {
|
---|
213 | LOG(("skipping non-primary display %d", pExt->iDevice));
|
---|
214 | return TRUE;
|
---|
215 | }
|
---|
216 |
|
---|
217 | /* Perform actual mode switch */
|
---|
218 | VBoxVideoSetModeRegisters((USHORT)pModeInfo->VisScreenWidth, (USHORT)pModeInfo->VisScreenHeight,
|
---|
219 | (USHORT)pModeInfo->VisScreenWidth, (USHORT)pModeInfo->BitsPerPlane, 0, 0, 0);
|
---|
220 |
|
---|
221 | /*@todo read back from port to check if mode switch was successful */
|
---|
222 |
|
---|
223 | LOGF_LEAVE();
|
---|
224 | return TRUE;
|
---|
225 | }
|
---|
226 |
|
---|
227 | /* Called for IOCTL_VIDEO_QUERY_CURRENT_MODE.
|
---|
228 | * Returns information about current video mode.
|
---|
229 | */
|
---|
230 | BOOLEAN VBoxMPQueryCurrentMode(PVBOXMP_DEVEXT pExt, PVIDEO_MODE_INFORMATION pModeInfo, PSTATUS_BLOCK pStatus)
|
---|
231 | {
|
---|
232 | LOGF_ENTER();
|
---|
233 |
|
---|
234 | pStatus->Information = sizeof(VIDEO_MODE_INFORMATION);
|
---|
235 |
|
---|
236 | VideoPortMoveMemory(pModeInfo, VBoxMPXpdmCurrentVideoMode(pExt), sizeof(VIDEO_MODE_INFORMATION));
|
---|
237 |
|
---|
238 | LOGF_LEAVE();
|
---|
239 | return TRUE;
|
---|
240 | }
|
---|
241 |
|
---|
242 | /* Called for IOCTL_VIDEO_QUERY_NUM_AVAIL_MODES.
|
---|
243 | * Returns count of supported video modes and structure size in bytes,
|
---|
244 | * used by the following IOCTL_VIDEO_QUERY_AVAIL_MODES.
|
---|
245 | */
|
---|
246 | BOOLEAN VBoxMPQueryNumAvailModes(PVBOXMP_DEVEXT pExt, PVIDEO_NUM_MODES pNumModes, PSTATUS_BLOCK pStatus)
|
---|
247 | {
|
---|
248 | LOGF_ENTER();
|
---|
249 |
|
---|
250 | VBoxMPXpdmBuildVideoModesTable(pExt);
|
---|
251 |
|
---|
252 | pNumModes->NumModes = VBoxMPXpdmGetVideoModesCount();
|
---|
253 | pNumModes->ModeInformationLength = sizeof(VIDEO_MODE_INFORMATION);
|
---|
254 | pStatus->Information = sizeof(VIDEO_NUM_MODES);
|
---|
255 |
|
---|
256 | LOGF_LEAVE();
|
---|
257 | return TRUE;
|
---|
258 | }
|
---|
259 |
|
---|
260 | /* Called for IOCTL_VIDEO_QUERY_AVAIL_MODES.
|
---|
261 | * Returns information about supported video modes.
|
---|
262 | */
|
---|
263 | BOOLEAN VBoxMPQueryAvailModes(PVBOXMP_DEVEXT pExt, PVIDEO_MODE_INFORMATION pModes, PSTATUS_BLOCK pStatus)
|
---|
264 | {
|
---|
265 | LOGF_ENTER();
|
---|
266 |
|
---|
267 | ULONG ulSize = VBoxMPXpdmGetVideoModesCount()*sizeof(VIDEO_MODE_INFORMATION);
|
---|
268 | pStatus->Information = ulSize;
|
---|
269 | VideoPortMoveMemory(pModes, VBoxMPCmnGetVideoModeInfo(0), ulSize);
|
---|
270 |
|
---|
271 | LOGF_LEAVE();
|
---|
272 | return TRUE;
|
---|
273 | }
|
---|
274 |
|
---|
275 | /* Called for IOCTL_VIDEO_SET_COLOR_REGISTERS.
|
---|
276 | * Sets adapter's color registers.
|
---|
277 | */
|
---|
278 | BOOLEAN VBoxMPSetColorRegisters(PVBOXMP_DEVEXT pExt, PVIDEO_CLUT pClut, PSTATUS_BLOCK pStatus)
|
---|
279 | {
|
---|
280 | LONG entry;
|
---|
281 |
|
---|
282 | LOGF_ENTER();
|
---|
283 |
|
---|
284 | if (pClut->FirstEntry+pClut->NumEntries > 256)
|
---|
285 | {
|
---|
286 | pStatus->Status = ERROR_INVALID_PARAMETER;
|
---|
287 | return FALSE;
|
---|
288 | }
|
---|
289 |
|
---|
290 | for (entry=pClut->FirstEntry; entry<pClut->FirstEntry+pClut->NumEntries; ++entry)
|
---|
291 | {
|
---|
292 | VBoxVideoCmnPortWriteUchar(VBE_DISPI_IOPORT_DAC_WRITE_INDEX, (UCHAR)entry);
|
---|
293 | VBoxVideoCmnPortWriteUchar(VBE_DISPI_IOPORT_DAC_DATA, pClut->LookupTable[entry].RgbArray.Red);
|
---|
294 | VBoxVideoCmnPortWriteUchar(VBE_DISPI_IOPORT_DAC_DATA, pClut->LookupTable[entry].RgbArray.Green);
|
---|
295 | VBoxVideoCmnPortWriteUchar(VBE_DISPI_IOPORT_DAC_DATA, pClut->LookupTable[entry].RgbArray.Blue);
|
---|
296 | }
|
---|
297 |
|
---|
298 | LOGF_LEAVE();
|
---|
299 | return TRUE;
|
---|
300 | }
|
---|
301 |
|
---|
302 | /* Called for IOCTL_VIDEO_SET_POINTER_ATTR.
|
---|
303 | * Sets pointer attributes.
|
---|
304 | */
|
---|
305 | BOOLEAN VBoxMPSetPointerAttr(PVBOXMP_DEVEXT pExt, PVIDEO_POINTER_ATTRIBUTES pPointerAttrs, uint32_t cbLen, PSTATUS_BLOCK pStatus)
|
---|
306 | {
|
---|
307 | BOOLEAN bRC;
|
---|
308 |
|
---|
309 | LOGF_ENTER();
|
---|
310 |
|
---|
311 | if (VBoxQueryHostWantsAbsolute())
|
---|
312 | {
|
---|
313 | bRC = VBoxMPCmnUpdatePointerShape(VBoxCommonFromDeviceExt(pExt), pPointerAttrs, cbLen);
|
---|
314 | }
|
---|
315 | else
|
---|
316 | {
|
---|
317 | LOG(("Fallback to sw pointer."));
|
---|
318 | pStatus->Status = ERROR_INVALID_FUNCTION;
|
---|
319 | bRC = FALSE;
|
---|
320 | }
|
---|
321 |
|
---|
322 | LOGF_LEAVE();
|
---|
323 | return bRC;
|
---|
324 | }
|
---|
325 |
|
---|
326 |
|
---|
327 |
|
---|
328 | /* Called for IOCTL_VIDEO_ENABLE_POINTER/IOCTL_VIDEO_DISABLE_POINTER.
|
---|
329 | * Hides pointer or makes it visible depending on bEnable value passed.
|
---|
330 | */
|
---|
331 | BOOLEAN VBoxMPEnablePointer(PVBOXMP_DEVEXT pExt, BOOLEAN bEnable, PSTATUS_BLOCK pStatus)
|
---|
332 | {
|
---|
333 | BOOLEAN bRC = TRUE;
|
---|
334 | LOGF_ENTER();
|
---|
335 |
|
---|
336 | if (VBoxQueryHostWantsAbsolute())
|
---|
337 | {
|
---|
338 | /* Check if it's not shown already. */
|
---|
339 | if (bEnable == pExt->pPrimary->u.primary.fMouseHidden)
|
---|
340 | {
|
---|
341 | VIDEO_POINTER_ATTRIBUTES attrs;
|
---|
342 |
|
---|
343 | /* Visible and No Shape means show the pointer, 0 means hide pointer.
|
---|
344 | * It's enough to init only this field.
|
---|
345 | */
|
---|
346 | attrs.Enable = bEnable ? VBOX_MOUSE_POINTER_VISIBLE:0;
|
---|
347 |
|
---|
348 |
|
---|
349 | /* Pass info to the host. */
|
---|
350 | bRC = VBoxMPCmnUpdatePointerShape(VBoxCommonFromDeviceExt(pExt), &attrs, sizeof(attrs));
|
---|
351 |
|
---|
352 | if (bRC)
|
---|
353 | {
|
---|
354 | /* Update device state. */
|
---|
355 | pExt->pPrimary->u.primary.fMouseHidden = !bEnable;
|
---|
356 | }
|
---|
357 | }
|
---|
358 | }
|
---|
359 | else
|
---|
360 | {
|
---|
361 | pStatus->Status = ERROR_INVALID_FUNCTION;
|
---|
362 | bRC = FALSE;
|
---|
363 | }
|
---|
364 |
|
---|
365 | LOGF_LEAVE();
|
---|
366 | return bRC;
|
---|
367 | }
|
---|
368 |
|
---|
369 | /* Called for IOCTL_VIDEO_QUERY_POINTER_POSITION.
|
---|
370 | * Query pointer position.
|
---|
371 | */
|
---|
372 | BOOLEAN VBoxMPQueryPointerPosition(PVBOXMP_DEVEXT pExt, PVIDEO_POINTER_POSITION pPos, PSTATUS_BLOCK pStatus)
|
---|
373 | {
|
---|
374 | uint16_t PosX, PosY;
|
---|
375 | BOOLEAN bRC = TRUE;
|
---|
376 | LOGF_ENTER();
|
---|
377 |
|
---|
378 | if (VBoxQueryPointerPos(&PosX, &PosY))
|
---|
379 | {
|
---|
380 | PVIDEO_MODE_INFORMATION pMode = VBoxMPXpdmCurrentVideoMode(pExt);
|
---|
381 | /* map from 0xFFFF to the current resolution */
|
---|
382 | pPos->Column = (SHORT)(PosX / (0xFFFF / pMode->VisScreenWidth));
|
---|
383 | pPos->Row = (SHORT)(PosY / (0xFFFF / pMode->VisScreenHeight));
|
---|
384 |
|
---|
385 | pStatus->Information = sizeof(VIDEO_POINTER_POSITION);
|
---|
386 | }
|
---|
387 | else
|
---|
388 | {
|
---|
389 | pStatus->Status = ERROR_INVALID_FUNCTION;
|
---|
390 | bRC = FALSE;
|
---|
391 | }
|
---|
392 |
|
---|
393 | LOGF_LEAVE();
|
---|
394 | return bRC;
|
---|
395 | }
|
---|
396 |
|
---|
397 | /* Called for IOCTL_VIDEO_QUERY_POINTER_CAPABILITIES.
|
---|
398 | * Query supported hardware pointer feaures.
|
---|
399 | * Note: we always return all caps we could ever support,
|
---|
400 | * related functions will return errors if host doesn't accept pointer integration
|
---|
401 | * and force display driver to enter software fallback codepath.
|
---|
402 | */
|
---|
403 | BOOLEAN VBoxMPQueryPointerCapabilities(PVBOXMP_DEVEXT pExt, PVIDEO_POINTER_CAPABILITIES pCaps, PSTATUS_BLOCK pStatus)
|
---|
404 | {
|
---|
405 | LOGF_ENTER();
|
---|
406 |
|
---|
407 | pStatus->Information = sizeof(VIDEO_POINTER_CAPABILITIES);
|
---|
408 |
|
---|
409 | pCaps->Flags = VIDEO_MODE_ASYNC_POINTER | VIDEO_MODE_COLOR_POINTER | VIDEO_MODE_MONO_POINTER;
|
---|
410 | /* Up to 64x64 shapes */
|
---|
411 | pCaps->MaxWidth = 64;
|
---|
412 | pCaps->MaxHeight = 64;
|
---|
413 | /* Not used by our display driver */
|
---|
414 | pCaps->HWPtrBitmapStart = -1;
|
---|
415 | pCaps->HWPtrBitmapEnd = -1;
|
---|
416 |
|
---|
417 | LOGF_LEAVE();
|
---|
418 | return TRUE;
|
---|
419 | }
|
---|
420 |
|
---|
421 | /* Called for IOCTL_VIDEO_VBVA_ENABLE.
|
---|
422 | * Display driver is ready to switch to VBVA operation mode.
|
---|
423 | */
|
---|
424 | BOOLEAN VBoxMPVBVAEnable(PVBOXMP_DEVEXT pExt, BOOLEAN bEnable, VBVAENABLERESULT *pResult, PSTATUS_BLOCK pStatus)
|
---|
425 | {
|
---|
426 | int rc;
|
---|
427 | BOOLEAN bRC = TRUE;
|
---|
428 | LOGF_ENTER();
|
---|
429 |
|
---|
430 | rc = VBoxVbvaEnable(pExt, bEnable, pResult);
|
---|
431 |
|
---|
432 | if (RT_SUCCESS(rc))
|
---|
433 | {
|
---|
434 | pStatus->Information = sizeof(VBVAENABLERESULT);
|
---|
435 | }
|
---|
436 | else
|
---|
437 | {
|
---|
438 | pStatus->Status = ERROR_INVALID_FUNCTION;
|
---|
439 | bRC = FALSE;
|
---|
440 | }
|
---|
441 |
|
---|
442 | LOGF_LEAVE();
|
---|
443 | return bRC;
|
---|
444 | }
|
---|
445 |
|
---|
446 | /* Called for IOCTL_VIDEO_VBOX_SETVISIBLEREGION.
|
---|
447 | * Sends visible regions information to the host.
|
---|
448 | */
|
---|
449 | BOOLEAN VBoxMPSetVisibleRegion(uint32_t cRects, RTRECT *pRects, PSTATUS_BLOCK pStatus)
|
---|
450 | {
|
---|
451 | int rc;
|
---|
452 | BOOLEAN bRC = FALSE;
|
---|
453 | LOGF_ENTER();
|
---|
454 |
|
---|
455 | VMMDevVideoSetVisibleRegion *req = NULL;
|
---|
456 | rc = VbglGRAlloc((VMMDevRequestHeader **)&req, sizeof(VMMDevVideoSetVisibleRegion) + (cRects-1)*sizeof(RTRECT),
|
---|
457 | VMMDevReq_VideoSetVisibleRegion);
|
---|
458 |
|
---|
459 | if (RT_SUCCESS(rc))
|
---|
460 | {
|
---|
461 | req->cRect = cRects;
|
---|
462 | memcpy(&req->Rect, pRects, cRects*sizeof(RTRECT));
|
---|
463 | rc = VbglGRPerform(&req->header);
|
---|
464 |
|
---|
465 | if (RT_SUCCESS(rc))
|
---|
466 | {
|
---|
467 | bRC=TRUE;
|
---|
468 | }
|
---|
469 |
|
---|
470 | VbglGRFree(&req->header);
|
---|
471 | }
|
---|
472 | else
|
---|
473 | {
|
---|
474 | WARN(("VbglGRAlloc rc = %#xrc", rc));
|
---|
475 | }
|
---|
476 |
|
---|
477 | if (!bRC)
|
---|
478 | {
|
---|
479 | pStatus->Status = ERROR_INVALID_FUNCTION;
|
---|
480 | }
|
---|
481 |
|
---|
482 | LOGF_LEAVE();
|
---|
483 | return bRC;
|
---|
484 | }
|
---|
485 |
|
---|
486 | /* Called for IOCTL_VIDEO_HGSMI_QUERY_PORTPROCS.
|
---|
487 | * Returns video port api function pointers.
|
---|
488 | */
|
---|
489 | BOOLEAN VBoxMPHGSMIQueryPortProcs(PVBOXMP_DEVEXT pExt, HGSMIQUERYCPORTPROCS *pProcs, PSTATUS_BLOCK pStatus)
|
---|
490 | {
|
---|
491 | BOOLEAN bRC = TRUE;
|
---|
492 | LOGF_ENTER();
|
---|
493 |
|
---|
494 | if (VBoxCommonFromDeviceExt(pExt)->bHGSMI)
|
---|
495 | {
|
---|
496 | pProcs->pContext = pExt->pPrimary;
|
---|
497 | pProcs->VideoPortProcs = pExt->pPrimary->u.primary.VideoPortProcs;
|
---|
498 |
|
---|
499 | pStatus->Information = sizeof(HGSMIQUERYCPORTPROCS);
|
---|
500 | }
|
---|
501 | else
|
---|
502 | {
|
---|
503 | pStatus->Status = ERROR_INVALID_FUNCTION;
|
---|
504 | bRC=FALSE;
|
---|
505 | }
|
---|
506 |
|
---|
507 | LOGF_LEAVE();
|
---|
508 | return bRC;
|
---|
509 | }
|
---|
510 |
|
---|
511 | /* Called for IOCTL_VIDEO_HGSMI_QUERY_CALLBACKS.
|
---|
512 | * Returns HGSMI related callbacks.
|
---|
513 | */
|
---|
514 | BOOLEAN VBoxMPHGSMIQueryCallbacks(PVBOXMP_DEVEXT pExt, HGSMIQUERYCALLBACKS *pCallbacks, PSTATUS_BLOCK pStatus)
|
---|
515 | {
|
---|
516 | BOOLEAN bRC = TRUE;
|
---|
517 | LOGF_ENTER();
|
---|
518 |
|
---|
519 | if (VBoxCommonFromDeviceExt(pExt)->bHGSMI)
|
---|
520 | {
|
---|
521 | pCallbacks->hContext = VBoxCommonFromDeviceExt(pExt);
|
---|
522 | pCallbacks->pfnCompletionHandler = VBoxMPHGSMIHostCmdCompleteCB;
|
---|
523 | pCallbacks->pfnRequestCommandsHandler = VBoxMPHGSMIHostCmdRequestCB;
|
---|
524 |
|
---|
525 | pStatus->Information = sizeof(HGSMIQUERYCALLBACKS);
|
---|
526 | }
|
---|
527 | else
|
---|
528 | {
|
---|
529 | pStatus->Status = ERROR_INVALID_FUNCTION;
|
---|
530 | bRC=FALSE;
|
---|
531 | }
|
---|
532 |
|
---|
533 |
|
---|
534 | LOGF_LEAVE();
|
---|
535 | return bRC;
|
---|
536 | }
|
---|
537 |
|
---|
538 | /* Called for IOCTL_VIDEO_QUERY_HGSMI_INFO.
|
---|
539 | * Returns hgsmi info for this adapter.
|
---|
540 | */
|
---|
541 | BOOLEAN VBoxMPQueryHgsmiInfo(PVBOXMP_DEVEXT pExt, QUERYHGSMIRESULT *pResult, PSTATUS_BLOCK pStatus)
|
---|
542 | {
|
---|
543 | BOOLEAN bRC = TRUE;
|
---|
544 | LOGF_ENTER();
|
---|
545 |
|
---|
546 | if (VBoxCommonFromDeviceExt(pExt)->bHGSMI)
|
---|
547 | {
|
---|
548 | pResult->iDevice = pExt->iDevice;
|
---|
549 | pResult->ulFlags = 0;
|
---|
550 | pResult->areaDisplay = pExt->areaDisplay;
|
---|
551 | pResult->u32DisplayInfoSize = VBVA_DISPLAY_INFORMATION_SIZE;
|
---|
552 | pResult->u32MinVBVABufferSize = VBVA_MIN_BUFFER_SIZE;
|
---|
553 | pResult->IOPortGuestCommand = VBoxCommonFromDeviceExt(pExt)->guestCtx.port;
|
---|
554 |
|
---|
555 | pStatus->Information = sizeof(QUERYHGSMIRESULT);
|
---|
556 | }
|
---|
557 | else
|
---|
558 | {
|
---|
559 | pStatus->Status = ERROR_INVALID_FUNCTION;
|
---|
560 | bRC=FALSE;
|
---|
561 | }
|
---|
562 |
|
---|
563 | LOGF_LEAVE();
|
---|
564 | return bRC;
|
---|
565 | }
|
---|
566 |
|
---|
567 | /* Called for IOCTL_VIDEO_HGSMI_HANDLER_ENABLE.
|
---|
568 | * Enables HGSMI miniport channel.
|
---|
569 | */
|
---|
570 | BOOLEAN VBoxMPHgsmiHandlerEnable(PVBOXMP_DEVEXT pExt, HGSMIHANDLERENABLE *pChannel, PSTATUS_BLOCK pStatus)
|
---|
571 | {
|
---|
572 | BOOLEAN bRC = TRUE;
|
---|
573 | LOGF_ENTER();
|
---|
574 |
|
---|
575 | if (VBoxCommonFromDeviceExt(pExt)->bHGSMI)
|
---|
576 | {
|
---|
577 | int rc = VBoxVbvaChannelDisplayEnable(VBoxCommonFromDeviceExt(pExt), pExt->iDevice, pChannel->u8Channel);
|
---|
578 | if (RT_FAILURE(rc))
|
---|
579 | {
|
---|
580 | pStatus->Status = ERROR_INVALID_NAME;
|
---|
581 | bRC=FALSE;
|
---|
582 | }
|
---|
583 | }
|
---|
584 | else
|
---|
585 | {
|
---|
586 | pStatus->Status = ERROR_INVALID_FUNCTION;
|
---|
587 | bRC=FALSE;
|
---|
588 | }
|
---|
589 |
|
---|
590 | LOGF_LEAVE();
|
---|
591 | return bRC;
|
---|
592 | }
|
---|
593 |
|
---|
594 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
595 | /* Called for IOCTL_VIDEO_VHWA_QUERY_INFO.
|
---|
596 | * Returns framebuffer offset.
|
---|
597 | */
|
---|
598 | BOOLEAN VBoxMPVhwaQueryInfo(PVBOXMP_DEVEXT pExt, VHWAQUERYINFO *pInfo, PSTATUS_BLOCK pStatus)
|
---|
599 | {
|
---|
600 | BOOLEAN bRC = TRUE;
|
---|
601 | LOGF_ENTER();
|
---|
602 |
|
---|
603 | if (VBoxCommonFromDeviceExt(pExt)->bHGSMI)
|
---|
604 | {
|
---|
605 | pInfo->offVramBase = (ULONG_PTR)pExt->ulFrameBufferOffset;
|
---|
606 |
|
---|
607 | pStatus->Information = sizeof (VHWAQUERYINFO);
|
---|
608 | }
|
---|
609 | else
|
---|
610 | {
|
---|
611 | pStatus->Status = ERROR_INVALID_FUNCTION;
|
---|
612 | bRC=FALSE;
|
---|
613 | }
|
---|
614 |
|
---|
615 | LOGF_LEAVE();
|
---|
616 | return bRC;
|
---|
617 | }
|
---|
618 | #endif
|
---|