Skip to content

Commit

Permalink
Graphics: Fix version negotiation
Browse files Browse the repository at this point in the history
  • Loading branch information
Goldfish64 committed Feb 18, 2025
1 parent 5ab2847 commit 8ed533d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 33 deletions.
52 changes: 22 additions & 30 deletions MacHyperVSupport/Graphics/HyperVGraphicsPrivate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,6 @@
#include "HyperVPCIRoot.hpp"
#include "HyperVPlatformProvider.hpp"

static const VMBusVersion graphicsVersions[] = {
kHyperVGraphicsVersionV3_2,
kHyperVGraphicsVersionV3_0
};

/*bool HyperVGraphics::wakePacketHandler(VMBusPacketHeader *pktHeader, UInt32 pktHeaderLength, UInt8 *pktData, UInt32 pktDataLength) {
HyperVGraphicsMessage *gfxMsg = (HyperVGraphicsMessage*) pktData;
HVDBGLOG("Received packet type 0x%X (%u bytes)", gfxMsg->gfxHeader.type, gfxMsg->gfxHeader.size);
switch (gfxMsg->gfxHeader.type) {
case kHyperVGraphicsMessageTypeVersionResponse:
case kHyperVGraphicsMessageTypeVRAMAck:
case kHyperVGraphicsMessageTypeResolutionUpdateAck:
return true;
default:
break;
}
return false;
}*/

void HyperVGraphics::handleRefreshTimer(IOTimerEventSource *sender) {
HyperVGraphicsMessage gfxMsg = { };

Expand Down Expand Up @@ -122,13 +101,29 @@ IOReturn HyperVGraphics::connectGraphics() {
//
// Negotiate graphics system version.
//
for (UInt32 i = 0; i < arrsize(graphicsVersions); i++) {
status = negotiateVersion(graphicsVersions[i]);
if (status == kIOReturnSuccess) {
foundVersion = true;
_currentGraphicsVersion = graphicsVersions[i];
VMBusVersion graphicsVersion;
switch (_hvDevice->getVMBusVersion()) {
case kVMBusVersionWIN8:
case kVMBusVersionWIN8_1:
case kVMBusVersionWIN10:
case kVMBusVersionWIN10_V4_1: // TODO: Check if this is correct.
graphicsVersion = kHyperVGraphicsVersionV3_2;
break;

case kVMBusVersionWIN7:
case kVMBusVersionWS2008:
graphicsVersion = kHyperVGraphicsVersionV3_0;
break;

default:
graphicsVersion = kHyperVGraphicsVersionV3_5;
break;
}
}

status = negotiateVersion(graphicsVersion);
if (status == kIOReturnSuccess) {
foundVersion = true;
_currentGraphicsVersion = graphicsVersion;
}

if (!foundVersion) {
Expand All @@ -154,9 +149,6 @@ IOReturn HyperVGraphics::connectGraphics() {
HVSYSLOG("Failed to send graphics memory location with status 0x%X", status);
return status;
}

// updatePointer();
// updateScreenResolution(1024, 768, false);

return kIOReturnSuccess;
}
Expand Down
5 changes: 3 additions & 2 deletions MacHyperVSupport/Graphics/HyperVGraphicsRegs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
//
// Graphics versions.
//
#define kHyperVGraphicsVersionV3_0 { 3, 0 } // Windows Server 2008 R2 and older
#define kHyperVGraphicsVersionV3_2 { 3, 2 } // Windows 8 / Windows Server 2012 and newer
#define kHyperVGraphicsVersionV3_0 { 3, 0 } // Windows Server 2008 and Windows Server 2008 R2
#define kHyperVGraphicsVersionV3_2 { 3, 2 } // Windows 8 / Windows Server 2012, Windows 8.1 / Windows Server 2012 R2, and Windows 10 / Windows Server 2016
#define kHyperVGraphicsVersionV3_5 { 3, 5 } // Windows 10 v1809 / Windows Server 2019 and newer

//
// Fixed transaction IDs for request/response due to transaction IDs
Expand Down
3 changes: 2 additions & 1 deletion MacHyperVSupport/VMBus/HyperVVMBus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ class HyperVVMBus : public IOService {
// Misc functions.
//
inline HyperVController *getHvController() { return hvController; }

inline UInt32 getVersion() { return _vmbusVersion; }

//
// VMBus channel management.
//
Expand Down
1 change: 1 addition & 0 deletions MacHyperVSupport/VMBusDevice/HyperVVMBusDevice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ class HyperVVMBusDevice : public IOService {
//
inline void setDebugMessagePrinting(bool enabled) { debugPackets = enabled; }
inline HyperVController *getHvController() { return _vmbusProvider->getHvController(); }
inline UInt32 getVMBusVersion() { return _vmbusProvider->getVersion(); }

//
// Messages.
Expand Down

0 comments on commit 8ed533d

Please sign in to comment.