VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/xpdm/VBoxMPIOCTL.cpp

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

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

© 2023 Oracle
ContactPrivacy policyTerms of Use