Skip to content

Commit 8ed533d

Browse files
committed
Graphics: Fix version negotiation
1 parent 5ab2847 commit 8ed533d

File tree

4 files changed

+28
-33
lines changed

4 files changed

+28
-33
lines changed

MacHyperVSupport/Graphics/HyperVGraphicsPrivate.cpp

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,6 @@
99
#include "HyperVPCIRoot.hpp"
1010
#include "HyperVPlatformProvider.hpp"
1111

12-
static const VMBusVersion graphicsVersions[] = {
13-
kHyperVGraphicsVersionV3_2,
14-
kHyperVGraphicsVersionV3_0
15-
};
16-
17-
/*bool HyperVGraphics::wakePacketHandler(VMBusPacketHeader *pktHeader, UInt32 pktHeaderLength, UInt8 *pktData, UInt32 pktDataLength) {
18-
HyperVGraphicsMessage *gfxMsg = (HyperVGraphicsMessage*) pktData;
19-
HVDBGLOG("Received packet type 0x%X (%u bytes)", gfxMsg->gfxHeader.type, gfxMsg->gfxHeader.size);
20-
switch (gfxMsg->gfxHeader.type) {
21-
case kHyperVGraphicsMessageTypeVersionResponse:
22-
case kHyperVGraphicsMessageTypeVRAMAck:
23-
case kHyperVGraphicsMessageTypeResolutionUpdateAck:
24-
return true;
25-
26-
default:
27-
break;
28-
}
29-
30-
return false;
31-
}*/
32-
3312
void HyperVGraphics::handleRefreshTimer(IOTimerEventSource *sender) {
3413
HyperVGraphicsMessage gfxMsg = { };
3514

@@ -122,13 +101,29 @@ IOReturn HyperVGraphics::connectGraphics() {
122101
//
123102
// Negotiate graphics system version.
124103
//
125-
for (UInt32 i = 0; i < arrsize(graphicsVersions); i++) {
126-
status = negotiateVersion(graphicsVersions[i]);
127-
if (status == kIOReturnSuccess) {
128-
foundVersion = true;
129-
_currentGraphicsVersion = graphicsVersions[i];
104+
VMBusVersion graphicsVersion;
105+
switch (_hvDevice->getVMBusVersion()) {
106+
case kVMBusVersionWIN8:
107+
case kVMBusVersionWIN8_1:
108+
case kVMBusVersionWIN10:
109+
case kVMBusVersionWIN10_V4_1: // TODO: Check if this is correct.
110+
graphicsVersion = kHyperVGraphicsVersionV3_2;
111+
break;
112+
113+
case kVMBusVersionWIN7:
114+
case kVMBusVersionWS2008:
115+
graphicsVersion = kHyperVGraphicsVersionV3_0;
116+
break;
117+
118+
default:
119+
graphicsVersion = kHyperVGraphicsVersionV3_5;
130120
break;
131-
}
121+
}
122+
123+
status = negotiateVersion(graphicsVersion);
124+
if (status == kIOReturnSuccess) {
125+
foundVersion = true;
126+
_currentGraphicsVersion = graphicsVersion;
132127
}
133128

134129
if (!foundVersion) {
@@ -154,9 +149,6 @@ IOReturn HyperVGraphics::connectGraphics() {
154149
HVSYSLOG("Failed to send graphics memory location with status 0x%X", status);
155150
return status;
156151
}
157-
158-
// updatePointer();
159-
// updateScreenResolution(1024, 768, false);
160152

161153
return kIOReturnSuccess;
162154
}

MacHyperVSupport/Graphics/HyperVGraphicsRegs.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525
//
2626
// Graphics versions.
2727
//
28-
#define kHyperVGraphicsVersionV3_0 { 3, 0 } // Windows Server 2008 R2 and older
29-
#define kHyperVGraphicsVersionV3_2 { 3, 2 } // Windows 8 / Windows Server 2012 and newer
28+
#define kHyperVGraphicsVersionV3_0 { 3, 0 } // Windows Server 2008 and Windows Server 2008 R2
29+
#define kHyperVGraphicsVersionV3_2 { 3, 2 } // Windows 8 / Windows Server 2012, Windows 8.1 / Windows Server 2012 R2, and Windows 10 / Windows Server 2016
30+
#define kHyperVGraphicsVersionV3_5 { 3, 5 } // Windows 10 v1809 / Windows Server 2019 and newer
3031

3132
//
3233
// Fixed transaction IDs for request/response due to transaction IDs

MacHyperVSupport/VMBus/HyperVVMBus.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ class HyperVVMBus : public IOService {
159159
// Misc functions.
160160
//
161161
inline HyperVController *getHvController() { return hvController; }
162-
162+
inline UInt32 getVersion() { return _vmbusVersion; }
163+
163164
//
164165
// VMBus channel management.
165166
//

MacHyperVSupport/VMBusDevice/HyperVVMBusDevice.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ class HyperVVMBusDevice : public IOService {
197197
//
198198
inline void setDebugMessagePrinting(bool enabled) { debugPackets = enabled; }
199199
inline HyperVController *getHvController() { return _vmbusProvider->getHvController(); }
200+
inline UInt32 getVMBusVersion() { return _vmbusProvider->getVersion(); }
200201

201202
//
202203
// Messages.

0 commit comments

Comments
 (0)