1 | /* $Id: VBoxMPIOCTL.cpp 58665 2015-11-11 17:14:51Z 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(pExt, RequestedMode-1);
|
---|
196 | if (!pModeInfo)
|
---|
197 | {
|
---|
198 | pStatus->Status = ERROR_INVALID_PARAMETER;
|
---|
199 | return FALSE;
|
---|
200 | }
|
---|
201 |
|
---|
202 | LOG(("screen [%d] mode %d width %d, height %d, bpp %d",
|
---|
203 | pExt->iDevice, pModeInfo->ModeIndex, 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(pExt);
|
---|
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(pExt)*sizeof(VIDEO_MODE_INFORMATION);
|
---|
268 | pStatus->Information = ulSize;
|
---|
269 | VideoPortMoveMemory(pModes, VBoxMPCmnGetVideoModeInfo(pExt, 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 | bRC = FALSE;
|
---|
319 | }
|
---|
320 |
|
---|
321 | if (!bRC)
|
---|
322 | {
|
---|
323 | pStatus->Status = ERROR_INVALID_FUNCTION;
|
---|
324 | }
|
---|
325 |
|
---|
326 | LOGF_LEAVE();
|
---|
327 | return bRC;
|
---|
328 | }
|
---|
329 |
|
---|
330 |
|
---|
331 |
|
---|
332 | /* Called for IOCTL_VIDEO_ENABLE_POINTER/IOCTL_VIDEO_DISABLE_POINTER.
|
---|
333 | * Hides pointer or makes it visible depending on bEnable value passed.
|
---|
334 | */
|
---|
335 | BOOLEAN VBoxMPEnablePointer(PVBOXMP_DEVEXT pExt, BOOLEAN bEnable, PSTATUS_BLOCK pStatus)
|
---|
336 | {
|
---|
337 | BOOLEAN bRC = TRUE;
|
---|
338 | LOGF_ENTER();
|
---|
339 |
|
---|
340 | if (VBoxQueryHostWantsAbsolute())
|
---|
341 | {
|
---|
342 | /* Check if it's not shown already. */
|
---|
343 | if (bEnable == pExt->pPrimary->u.primary.fMouseHidden)
|
---|
344 | {
|
---|
345 | VIDEO_POINTER_ATTRIBUTES attrs;
|
---|
346 |
|
---|
347 | /* Visible and No Shape means show the pointer, 0 means hide pointer.
|
---|
348 | * It's enough to init only this field.
|
---|
349 | */
|
---|
350 | attrs.Enable = bEnable ? VBOX_MOUSE_POINTER_VISIBLE:0;
|
---|
351 |
|
---|
352 |
|
---|
353 | /* Pass info to the host. */
|
---|
354 | bRC = VBoxMPCmnUpdatePointerShape(VBoxCommonFromDeviceExt(pExt), &attrs, sizeof(attrs));
|
---|
355 |
|
---|
356 | if (bRC)
|
---|
357 | {
|
---|
358 | /* Update device state. */
|
---|
359 | pExt->pPrimary->u.primary.fMouseHidden = !bEnable;
|
---|
360 | }
|
---|
361 | }
|
---|
362 | }
|
---|
363 | else
|
---|
364 | {
|
---|
365 | bRC = FALSE;
|
---|
366 | }
|
---|
367 |
|
---|
368 | if (!bRC)
|
---|
369 | {
|
---|
370 | pStatus->Status = ERROR_INVALID_FUNCTION;
|
---|
371 | }
|
---|
372 |
|
---|
373 | LOGF_LEAVE();
|
---|
374 | return bRC;
|
---|
375 | }
|
---|
376 |
|
---|
377 | /* Called for IOCTL_VIDEO_QUERY_POINTER_POSITION.
|
---|
378 | * Query pointer position.
|
---|
379 | */
|
---|
380 | BOOLEAN VBoxMPQueryPointerPosition(PVBOXMP_DEVEXT pExt, PVIDEO_POINTER_POSITION pPos, PSTATUS_BLOCK pStatus)
|
---|
381 | {
|
---|
382 | uint16_t PosX, PosY;
|
---|
383 | BOOLEAN bRC = TRUE;
|
---|
384 | LOGF_ENTER();
|
---|
385 |
|
---|
386 | if (VBoxQueryPointerPos(&PosX, &PosY))
|
---|
387 | {
|
---|
388 | PVIDEO_MODE_INFORMATION pMode = VBoxMPXpdmCurrentVideoMode(pExt);
|
---|
389 | /* map from 0xFFFF to the current resolution */
|
---|
390 | pPos->Column = (SHORT)(PosX / (0xFFFF / pMode->VisScreenWidth));
|
---|
391 | pPos->Row = (SHORT)(PosY / (0xFFFF / pMode->VisScreenHeight));
|
---|
392 |
|
---|
393 | pStatus->Information = sizeof(VIDEO_POINTER_POSITION);
|
---|
394 | }
|
---|
395 | else
|
---|
396 | {
|
---|
397 | pStatus->Status = ERROR_INVALID_FUNCTION;
|
---|
398 | bRC = FALSE;
|
---|
399 | }
|
---|
400 |
|
---|
401 | LOGF_LEAVE();
|
---|
402 | return bRC;
|
---|
403 | }
|
---|
404 |
|
---|
405 | /* Called for IOCTL_VIDEO_QUERY_POINTER_CAPABILITIES.
|
---|
406 | * Query supported hardware pointer feaures.
|
---|
407 | * Note: we always return all caps we could ever support,
|
---|
408 | * related functions will return errors if host doesn't accept pointer integration
|
---|
409 | * and force display driver to enter software fallback codepath.
|
---|
410 | */
|
---|
411 | BOOLEAN VBoxMPQueryPointerCapabilities(PVBOXMP_DEVEXT pExt, PVIDEO_POINTER_CAPABILITIES pCaps, PSTATUS_BLOCK pStatus)
|
---|
412 | {
|
---|
413 | LOGF_ENTER();
|
---|
414 |
|
---|
415 | pStatus->Information = sizeof(VIDEO_POINTER_CAPABILITIES);
|
---|
416 |
|
---|
417 | pCaps->Flags = VIDEO_MODE_ASYNC_POINTER | VIDEO_MODE_COLOR_POINTER;
|
---|
418 | /* Up to 64x64 shapes */
|
---|
419 | pCaps->MaxWidth = 64;
|
---|
420 | pCaps->MaxHeight = 64;
|
---|
421 | /* Not used by our display driver */
|
---|
422 | pCaps->HWPtrBitmapStart = -1;
|
---|
423 | pCaps->HWPtrBitmapEnd = -1;
|
---|
424 |
|
---|
425 | LOGF_LEAVE();
|
---|
426 | return TRUE;
|
---|
427 | }
|
---|
428 |
|
---|
429 | /* Called for IOCTL_VIDEO_VBVA_ENABLE.
|
---|
430 | * Display driver is ready to switch to VBVA operation mode.
|
---|
431 | */
|
---|
432 | BOOLEAN VBoxMPVBVAEnable(PVBOXMP_DEVEXT pExt, BOOLEAN bEnable, VBVAENABLERESULT *pResult, PSTATUS_BLOCK pStatus)
|
---|
433 | {
|
---|
434 | int rc;
|
---|
435 | BOOLEAN bRC = TRUE;
|
---|
436 | LOGF_ENTER();
|
---|
437 |
|
---|
438 | rc = VBoxVbvaEnable(pExt, bEnable, pResult);
|
---|
439 |
|
---|
440 | if (RT_SUCCESS(rc))
|
---|
441 | {
|
---|
442 | pStatus->Information = sizeof(VBVAENABLERESULT);
|
---|
443 | }
|
---|
444 | else
|
---|
445 | {
|
---|
446 | pStatus->Status = ERROR_INVALID_FUNCTION;
|
---|
447 | bRC = FALSE;
|
---|
448 | }
|
---|
449 |
|
---|
450 | LOGF_LEAVE();
|
---|
451 | return bRC;
|
---|
452 | }
|
---|
453 |
|
---|
454 | /* Called for IOCTL_VIDEO_VBOX_SETVISIBLEREGION.
|
---|
455 | * Sends visible regions information to the host.
|
---|
456 | */
|
---|
457 | BOOLEAN VBoxMPSetVisibleRegion(uint32_t cRects, RTRECT *pRects, PSTATUS_BLOCK pStatus)
|
---|
458 | {
|
---|
459 | int rc;
|
---|
460 | BOOLEAN bRC = FALSE;
|
---|
461 | LOGF_ENTER();
|
---|
462 |
|
---|
463 | VMMDevVideoSetVisibleRegion *req = NULL;
|
---|
464 | rc = VbglGRAlloc((VMMDevRequestHeader **)&req, sizeof(VMMDevVideoSetVisibleRegion) + (cRects-1)*sizeof(RTRECT),
|
---|
465 | VMMDevReq_VideoSetVisibleRegion);
|
---|
466 |
|
---|
467 | if (RT_SUCCESS(rc))
|
---|
468 | {
|
---|
469 | req->cRect = cRects;
|
---|
470 | memcpy(&req->Rect, pRects, cRects*sizeof(RTRECT));
|
---|
471 | rc = VbglGRPerform(&req->header);
|
---|
472 |
|
---|
473 | if (RT_SUCCESS(rc))
|
---|
474 | {
|
---|
475 | bRC=TRUE;
|
---|
476 | }
|
---|
477 |
|
---|
478 | VbglGRFree(&req->header);
|
---|
479 | }
|
---|
480 | else
|
---|
481 | {
|
---|
482 | WARN(("VbglGRAlloc rc = %#xrc", rc));
|
---|
483 | }
|
---|
484 |
|
---|
485 | if (!bRC)
|
---|
486 | {
|
---|
487 | pStatus->Status = ERROR_INVALID_FUNCTION;
|
---|
488 | }
|
---|
489 |
|
---|
490 | LOGF_LEAVE();
|
---|
491 | return bRC;
|
---|
492 | }
|
---|
493 |
|
---|
494 | /* Called for IOCTL_VIDEO_HGSMI_QUERY_PORTPROCS.
|
---|
495 | * Returns video port api function pointers.
|
---|
496 | */
|
---|
497 | BOOLEAN VBoxMPHGSMIQueryPortProcs(PVBOXMP_DEVEXT pExt, HGSMIQUERYCPORTPROCS *pProcs, PSTATUS_BLOCK pStatus)
|
---|
498 | {
|
---|
499 | BOOLEAN bRC = TRUE;
|
---|
500 | LOGF_ENTER();
|
---|
501 |
|
---|
502 | if (VBoxCommonFromDeviceExt(pExt)->bHGSMI)
|
---|
503 | {
|
---|
504 | pProcs->pContext = pExt->pPrimary;
|
---|
505 | pProcs->VideoPortProcs = pExt->pPrimary->u.primary.VideoPortProcs;
|
---|
506 |
|
---|
507 | pStatus->Information = sizeof(HGSMIQUERYCPORTPROCS);
|
---|
508 | }
|
---|
509 | else
|
---|
510 | {
|
---|
511 | pStatus->Status = ERROR_INVALID_FUNCTION;
|
---|
512 | bRC=FALSE;
|
---|
513 | }
|
---|
514 |
|
---|
515 | LOGF_LEAVE();
|
---|
516 | return bRC;
|
---|
517 | }
|
---|
518 |
|
---|
519 | /* Called for IOCTL_VIDEO_HGSMI_QUERY_CALLBACKS.
|
---|
520 | * Returns HGSMI related callbacks.
|
---|
521 | */
|
---|
522 | BOOLEAN VBoxMPHGSMIQueryCallbacks(PVBOXMP_DEVEXT pExt, HGSMIQUERYCALLBACKS *pCallbacks, PSTATUS_BLOCK pStatus)
|
---|
523 | {
|
---|
524 | BOOLEAN bRC = TRUE;
|
---|
525 | LOGF_ENTER();
|
---|
526 |
|
---|
527 | if (VBoxCommonFromDeviceExt(pExt)->bHGSMI)
|
---|
528 | {
|
---|
529 | pCallbacks->hContext = VBoxCommonFromDeviceExt(pExt);
|
---|
530 | pCallbacks->pfnCompletionHandler = VBoxMPHGSMIHostCmdCompleteCB;
|
---|
531 | pCallbacks->pfnRequestCommandsHandler = VBoxMPHGSMIHostCmdRequestCB;
|
---|
532 |
|
---|
533 | pStatus->Information = sizeof(HGSMIQUERYCALLBACKS);
|
---|
534 | }
|
---|
535 | else
|
---|
536 | {
|
---|
537 | pStatus->Status = ERROR_INVALID_FUNCTION;
|
---|
538 | bRC=FALSE;
|
---|
539 | }
|
---|
540 |
|
---|
541 |
|
---|
542 | LOGF_LEAVE();
|
---|
543 | return bRC;
|
---|
544 | }
|
---|
545 |
|
---|
546 | /* Called for IOCTL_VIDEO_QUERY_HGSMI_INFO.
|
---|
547 | * Returns hgsmi info for this adapter.
|
---|
548 | */
|
---|
549 | BOOLEAN VBoxMPQueryHgsmiInfo(PVBOXMP_DEVEXT pExt, QUERYHGSMIRESULT *pResult, PSTATUS_BLOCK pStatus)
|
---|
550 | {
|
---|
551 | BOOLEAN bRC = TRUE;
|
---|
552 | LOGF_ENTER();
|
---|
553 |
|
---|
554 | if (VBoxCommonFromDeviceExt(pExt)->bHGSMI)
|
---|
555 | {
|
---|
556 | pResult->iDevice = pExt->iDevice;
|
---|
557 | pResult->ulFlags = 0;
|
---|
558 | pResult->areaDisplay = pExt->areaDisplay;
|
---|
559 | pResult->u32DisplayInfoSize = VBVA_DISPLAY_INFORMATION_SIZE;
|
---|
560 | pResult->u32MinVBVABufferSize = VBVA_MIN_BUFFER_SIZE;
|
---|
561 | pResult->IOPortGuestCommand = VBoxCommonFromDeviceExt(pExt)->guestCtx.port;
|
---|
562 |
|
---|
563 | pStatus->Information = sizeof(QUERYHGSMIRESULT);
|
---|
564 | }
|
---|
565 | else
|
---|
566 | {
|
---|
567 | pStatus->Status = ERROR_INVALID_FUNCTION;
|
---|
568 | bRC=FALSE;
|
---|
569 | }
|
---|
570 |
|
---|
571 | LOGF_LEAVE();
|
---|
572 | return bRC;
|
---|
573 | }
|
---|
574 |
|
---|
575 | /* Called for IOCTL_VIDEO_HGSMI_HANDLER_ENABLE.
|
---|
576 | * Enables HGSMI miniport channel.
|
---|
577 | */
|
---|
578 | BOOLEAN VBoxMPHgsmiHandlerEnable(PVBOXMP_DEVEXT pExt, HGSMIHANDLERENABLE *pChannel, PSTATUS_BLOCK pStatus)
|
---|
579 | {
|
---|
580 | BOOLEAN bRC = TRUE;
|
---|
581 | LOGF_ENTER();
|
---|
582 |
|
---|
583 | if (VBoxCommonFromDeviceExt(pExt)->bHGSMI)
|
---|
584 | {
|
---|
585 | int rc = VBoxVbvaChannelDisplayEnable(VBoxCommonFromDeviceExt(pExt), pExt->iDevice, pChannel->u8Channel);
|
---|
586 | if (RT_FAILURE(rc))
|
---|
587 | {
|
---|
588 | pStatus->Status = ERROR_INVALID_NAME;
|
---|
589 | bRC=FALSE;
|
---|
590 | }
|
---|
591 | }
|
---|
592 | else
|
---|
593 | {
|
---|
594 | pStatus->Status = ERROR_INVALID_FUNCTION;
|
---|
595 | bRC=FALSE;
|
---|
596 | }
|
---|
597 |
|
---|
598 | LOGF_LEAVE();
|
---|
599 | return bRC;
|
---|
600 | }
|
---|
601 |
|
---|
602 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
603 | /* Called for IOCTL_VIDEO_VHWA_QUERY_INFO.
|
---|
604 | * Returns framebuffer offset.
|
---|
605 | */
|
---|
606 | BOOLEAN VBoxMPVhwaQueryInfo(PVBOXMP_DEVEXT pExt, VHWAQUERYINFO *pInfo, PSTATUS_BLOCK pStatus)
|
---|
607 | {
|
---|
608 | BOOLEAN bRC = TRUE;
|
---|
609 | LOGF_ENTER();
|
---|
610 |
|
---|
611 | if (VBoxCommonFromDeviceExt(pExt)->bHGSMI)
|
---|
612 | {
|
---|
613 | pInfo->offVramBase = (ULONG_PTR)pExt->ulFrameBufferOffset;
|
---|
614 |
|
---|
615 | pStatus->Information = sizeof (VHWAQUERYINFO);
|
---|
616 | }
|
---|
617 | else
|
---|
618 | {
|
---|
619 | pStatus->Status = ERROR_INVALID_FUNCTION;
|
---|
620 | bRC=FALSE;
|
---|
621 | }
|
---|
622 |
|
---|
623 | LOGF_LEAVE();
|
---|
624 | return bRC;
|
---|
625 | }
|
---|
626 | #endif
|
---|
627 |
|
---|
628 | BOOLEAN VBoxMPQueryRegistryFlags(PVBOXMP_DEVEXT pExt, ULONG *pulFlags, PSTATUS_BLOCK pStatus)
|
---|
629 | {
|
---|
630 | BOOLEAN bRC = TRUE;
|
---|
631 | LOGF_ENTER();
|
---|
632 |
|
---|
633 | VBOXMPCMNREGISTRY Registry;
|
---|
634 |
|
---|
635 | int rc = VBoxMPCmnRegInit(pExt, &Registry);
|
---|
636 | VBOXMP_WARN_VPS_NOBP(rc);
|
---|
637 |
|
---|
638 | if (rc == NO_ERROR)
|
---|
639 | {
|
---|
640 | uint32_t u32Flags = 0;
|
---|
641 | rc = VBoxMPCmnRegQueryDword(Registry, L"VBoxVideoFlags", &u32Flags);
|
---|
642 | VBOXMP_WARN_VPS_NOBP(rc);
|
---|
643 | if (rc != NO_ERROR)
|
---|
644 | {
|
---|
645 | u32Flags = 0;
|
---|
646 | }
|
---|
647 |
|
---|
648 | LOG(("Registry flags 0x%08X", u32Flags));
|
---|
649 | *pulFlags = u32Flags;
|
---|
650 | pStatus->Information = sizeof(ULONG);
|
---|
651 | }
|
---|
652 |
|
---|
653 | rc = VBoxMPCmnRegFini(Registry);
|
---|
654 | VBOXMP_WARN_VPS_NOBP(rc);
|
---|
655 |
|
---|
656 | LOGF_LEAVE();
|
---|
657 | return bRC;
|
---|
658 | }
|
---|