VirtualBox

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

Last change on this file since 37490 was 36867, checked in by vboxsync, 14 years ago

Additions/Video: display/miniport drivers

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.6 KB
Line 
1/* $Id: VBoxMPHGSMI.cpp 36867 2011-04-28 07:27:03Z vboxsync $ */
2
3/** @file
4 * VBox Miniport HGSMI related functions
5 */
6
7/*
8 * Copyright (C) 2011 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,
32 uint32_t AdapterMemorySize, 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->cbVRAM = AdapterMemorySize;
45 pCommon->cDisplays = 1;
46 pCommon->bHGSMI = VBoxHGSMIIsSupported();
47
48 if (pCommon->bHGSMI)
49 {
50 VBoxHGSMIGetBaseMappingInfo(pCommon->cbVRAM, &offVRAMBaseMapping,
51 &cbMapping, &offGuestHeapMemory,
52 &cbGuestHeapMemory, &offHostFlags);
53
54 /* Map the adapter information. It will be needed for HGSMI IO. */
55 rc = VBoxMPCmnMapAdapterMemory(pCommon, &pCommon->pvAdapterInformation, offVRAMBaseMapping, cbMapping);
56 if (RT_FAILURE(rc))
57 {
58 LOG(("VBoxMPCmnMapAdapterMemory failed rc = %d", rc));
59 pCommon->bHGSMI = false;
60 }
61 else
62 {
63 /* Setup an HGSMI heap within the adapter information area. */
64 rc = VBoxHGSMISetupGuestContext(&pCommon->guestCtx,
65 pCommon->pvAdapterInformation,
66 cbGuestHeapMemory,
67 offVRAMBaseMapping
68 + offGuestHeapMemory);
69
70 if (RT_FAILURE(rc))
71 {
72 LOG(("HGSMIHeapSetup failed rc = %d", rc));
73 pCommon->bHGSMI = false;
74 }
75 }
76 }
77
78 /* Setup the host heap and the adapter memory. */
79 if (pCommon->bHGSMI)
80 {
81 VBoxHGSMIGetHostAreaMapping(&pCommon->guestCtx, pCommon->cbVRAM,
82 offVRAMBaseMapping, &offVRAMHostArea,
83 &cbHostArea);
84 if (cbHostArea)
85 {
86
87 /* Map the heap region.
88 *
89 * Note: the heap will be used for the host buffers submitted to the guest.
90 * The miniport driver is responsible for reading FIFO and notifying
91 * display drivers.
92 */
93 pCommon->cbMiniportHeap = cbHostArea;
94 rc = VBoxMPCmnMapAdapterMemory (pCommon, &pCommon->pvMiniportHeap,
95 offVRAMHostArea, cbHostArea);
96 if (RT_FAILURE(rc))
97 {
98 pCommon->pvMiniportHeap = NULL;
99 pCommon->cbMiniportHeap = 0;
100 pCommon->bHGSMI = false;
101 }
102 else
103 VBoxHGSMISetupHostContext(&pCommon->hostCtx,
104 pCommon->pvAdapterInformation,
105 offHostFlags,
106 pCommon->pvMiniportHeap,
107 offVRAMHostArea, cbHostArea);
108 }
109 else
110 {
111 /* Host has not requested a heap. */
112 pCommon->pvMiniportHeap = NULL;
113 pCommon->cbMiniportHeap = 0;
114 }
115 }
116
117 if (pCommon->bHGSMI)
118 {
119 /* Setup the information for the host. */
120 rc = VBoxHGSMISendHostCtxInfo(&pCommon->guestCtx,
121 offVRAMBaseMapping + offHostFlags,
122 fCaps, offVRAMHostArea,
123 pCommon->cbMiniportHeap);
124
125 if (RT_FAILURE(rc))
126 {
127 pCommon->bHGSMI = false;
128 }
129 }
130
131 /* Check whether the guest supports multimonitors. */
132 if (pCommon->bHGSMI)
133 {
134 /* Query the configured number of displays. */
135 pCommon->cDisplays = VBoxHGSMIGetMonitorCount(&pCommon->guestCtx);
136 }
137 else
138 {
139 VBoxFreeDisplaysHGSMI(pCommon);
140 }
141
142 LOGF_LEAVE();
143}
144
145static bool VBoxUnmapAdpInfoCallback(void *pvCommon)
146{
147 PVBOXMP_COMMON pCommon = (PVBOXMP_COMMON)pvCommon;
148
149 pCommon->hostCtx.pfHostFlags = NULL;
150 return true;
151}
152
153void VBoxFreeDisplaysHGSMI(PVBOXMP_COMMON pCommon)
154{
155 VBoxMPCmnUnmapAdapterMemory(pCommon, &pCommon->pvMiniportHeap);
156 HGSMIHeapDestroy(&pCommon->guestCtx.heapCtx);
157
158 /* Unmap the adapter information needed for HGSMI IO. */
159 VBoxMPCmnSyncToVideoIRQ(pCommon, VBoxUnmapAdpInfoCallback, pCommon);
160 VBoxMPCmnUnmapAdapterMemory(pCommon, &pCommon->pvAdapterInformation);
161}
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