VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/common/VBoxMPHGSMI.cpp@ 44529

Last change on this file since 44529 was 44529, checked in by vboxsync, 12 years ago

header (C) fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.8 KB
Line 
1/* $Id: VBoxMPHGSMI.cpp 44529 2013-02-04 15:54:15Z vboxsync $ */
2
3/** @file
4 * VBox Miniport HGSMI related functions
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 "VBoxMPHGSMI.h"
20#include "VBoxMPCommon.h"
21#include <VBox/VMMDev.h>
22
23/**
24 * Helper function to register secondary displays (DualView). Note that this will not
25 * be available on pre-XP versions, and some editions on XP will fail because they are
26 * intentionally crippled.
27 *
28 * HGSMI variant is a bit different because it uses only HGSMI interface (VBVA channel)
29 * to talk to the host.
30 */
31void VBoxSetupDisplaysHGSMI(PVBOXMP_COMMON pCommon, PHYSICAL_ADDRESS phVRAM, uint32_t ulApertureSize,
32 uint32_t cbVRAM, uint32_t fCaps)
33{
34 /** @todo I simply converted this from Windows error codes. That is wrong,
35 * but we currently freely mix and match those (failure == rc > 0) and iprt
36 * ones (failure == rc < 0) anyway. This needs to be fully reviewed and
37 * fixed. */
38 int rc = VINF_SUCCESS;
39 uint32_t offVRAMBaseMapping, cbMapping, offGuestHeapMemory, cbGuestHeapMemory,
40 offHostFlags, offVRAMHostArea, cbHostArea;
41 LOGF_ENTER();
42
43 memset(pCommon, 0, sizeof(*pCommon));
44 pCommon->phVRAM = phVRAM;
45 pCommon->ulApertureSize = ulApertureSize;
46 pCommon->cbVRAM = cbVRAM;
47 pCommon->cDisplays = 1;
48 pCommon->bHGSMI = VBoxHGSMIIsSupported();
49
50 if (pCommon->bHGSMI)
51 {
52 VBoxHGSMIGetBaseMappingInfo(pCommon->cbVRAM, &offVRAMBaseMapping,
53 &cbMapping, &offGuestHeapMemory,
54 &cbGuestHeapMemory, &offHostFlags);
55
56 /* Map the adapter information. It will be needed for HGSMI IO. */
57 rc = VBoxMPCmnMapAdapterMemory(pCommon, &pCommon->pvAdapterInformation, offVRAMBaseMapping, cbMapping);
58 if (RT_FAILURE(rc))
59 {
60 LOG(("VBoxMPCmnMapAdapterMemory failed rc = %d", rc));
61 pCommon->bHGSMI = false;
62 }
63 else
64 {
65 /* Setup an HGSMI heap within the adapter information area. */
66 rc = VBoxHGSMISetupGuestContext(&pCommon->guestCtx,
67 pCommon->pvAdapterInformation,
68 cbGuestHeapMemory,
69 offVRAMBaseMapping
70 + offGuestHeapMemory);
71
72 if (RT_FAILURE(rc))
73 {
74 LOG(("HGSMIHeapSetup failed rc = %d", rc));
75 pCommon->bHGSMI = false;
76 }
77 }
78 }
79
80 /* Setup the host heap and the adapter memory. */
81 if (pCommon->bHGSMI)
82 {
83 VBoxHGSMIGetHostAreaMapping(&pCommon->guestCtx, pCommon->cbVRAM,
84 offVRAMBaseMapping, &offVRAMHostArea,
85 &cbHostArea);
86 if (cbHostArea)
87 {
88
89 /* Map the heap region.
90 *
91 * Note: the heap will be used for the host buffers submitted to the guest.
92 * The miniport driver is responsible for reading FIFO and notifying
93 * display drivers.
94 */
95 pCommon->cbMiniportHeap = cbHostArea;
96 rc = VBoxMPCmnMapAdapterMemory (pCommon, &pCommon->pvMiniportHeap,
97 offVRAMHostArea, cbHostArea);
98 if (RT_FAILURE(rc))
99 {
100 pCommon->pvMiniportHeap = NULL;
101 pCommon->cbMiniportHeap = 0;
102 pCommon->bHGSMI = false;
103 }
104 else
105 VBoxHGSMISetupHostContext(&pCommon->hostCtx,
106 pCommon->pvAdapterInformation,
107 offHostFlags,
108 pCommon->pvMiniportHeap,
109 offVRAMHostArea, cbHostArea);
110 }
111 else
112 {
113 /* Host has not requested a heap. */
114 pCommon->pvMiniportHeap = NULL;
115 pCommon->cbMiniportHeap = 0;
116 }
117 }
118
119 if (pCommon->bHGSMI)
120 {
121 /* Setup the information for the host. */
122 rc = VBoxHGSMISendHostCtxInfo(&pCommon->guestCtx,
123 offVRAMBaseMapping + offHostFlags,
124 fCaps, offVRAMHostArea,
125 pCommon->cbMiniportHeap);
126
127 if (RT_FAILURE(rc))
128 {
129 pCommon->bHGSMI = false;
130 }
131 }
132
133 /* Check whether the guest supports multimonitors. */
134 if (pCommon->bHGSMI)
135 {
136 /* Query the configured number of displays. */
137 pCommon->cDisplays = VBoxHGSMIGetMonitorCount(&pCommon->guestCtx);
138 }
139 else
140 {
141 VBoxFreeDisplaysHGSMI(pCommon);
142 }
143
144 LOGF_LEAVE();
145}
146
147static bool VBoxUnmapAdpInfoCallback(void *pvCommon)
148{
149 PVBOXMP_COMMON pCommon = (PVBOXMP_COMMON)pvCommon;
150
151 pCommon->hostCtx.pfHostFlags = NULL;
152 return true;
153}
154
155void VBoxFreeDisplaysHGSMI(PVBOXMP_COMMON pCommon)
156{
157 VBoxMPCmnUnmapAdapterMemory(pCommon, &pCommon->pvMiniportHeap);
158#ifdef VBOX_WDDM_MINIPORT
159 VBoxSHGSMITerm(&pCommon->guestCtx.heapCtx);
160#else
161 HGSMIHeapDestroy(&pCommon->guestCtx.heapCtx);
162#endif
163
164 /* Unmap the adapter information needed for HGSMI IO. */
165 VBoxMPCmnSyncToVideoIRQ(pCommon, VBoxUnmapAdpInfoCallback, pCommon);
166 VBoxMPCmnUnmapAdapterMemory(pCommon, &pCommon->pvAdapterInformation);
167}
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