VirtualBox

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

Last change on this file since 50940 was 50482, checked in by vboxsync, 11 years ago

Build HGSMI memory allocator (unused)

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