Skip to content

Commit

Permalink
PCI: Cleanup PCI bridge code and add MSI-X support
Browse files Browse the repository at this point in the history
  • Loading branch information
Goldfish64 committed Oct 14, 2023
1 parent 8f844d6 commit b9c08fb
Show file tree
Hide file tree
Showing 12 changed files with 540 additions and 413 deletions.
4 changes: 0 additions & 4 deletions MacHyperVSupport/Controller/HyperV.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ typedef enum : UInt32 {

#define kHyperVHypercallRetryCount 100


#define kHyperVPCIBusSyntheticGraphics 0xFB
#define kHyperVPCIBusDummy 0xFE

#if DEBUG
//
// Debug logging function.
Expand Down
8 changes: 7 additions & 1 deletion MacHyperVSupport/GraphicsBridge/HyperVGraphicsBridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ bool HyperVGraphicsBridge::start(IOService *provider) {
//
// Locate root PCI bus instance and register ourselves.
//
if (!HyperVPCIRoot::registerChildPCIBridge(this)) {
_hvPCIRoot = HyperVPCIRoot::getPCIRootInstance();
if (_hvPCIRoot == nullptr) {
_hvDevice->release();
return false;
}

if (_hvPCIRoot->registerChildPCIBridge(this, &_pciBusNumber) != kIOReturnSuccess) {
HVSYSLOG("Failed to register with root PCI bus instance");
OSSafeReleaseNULL(_hvDevice);
return false;
Expand Down
9 changes: 6 additions & 3 deletions MacHyperVSupport/GraphicsBridge/HyperVGraphicsBridge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@
#include <IOKit/pci/IOPCIBridge.h>
#include "HyperVVMBusDevice.hpp"
#include "HyperVGraphicsBridgeRegs.hpp"
#include "HyperVPCIRoot.hpp"

class HyperVGraphicsBridge : public HV_PCIBRIDGE_CLASS {
OSDeclareDefaultStructors(HyperVGraphicsBridge);
HVDeclareLogFunctionsVMBusChild("gfxb");
typedef HV_PCIBRIDGE_CLASS super;

private:
HyperVVMBusDevice *_hvDevice;
HyperVVMBusDevice *_hvDevice = nullptr;
HyperVPCIRoot *_hvPCIRoot = nullptr;
VMBusVersion _currentGraphicsVersion = { };
UInt8 _pciBusNumber = 0;

//
// Fake PCI structures.
Expand Down Expand Up @@ -62,12 +65,12 @@ class HyperVGraphicsBridge : public HV_PCIBRIDGE_CLASS {

UInt8 firstBusNum() APPLE_KEXT_OVERRIDE {
HVDBGLOG("start");
return kHyperVPCIBusSyntheticGraphics;
return _pciBusNumber;
}

UInt8 lastBusNum() APPLE_KEXT_OVERRIDE {
HVDBGLOG("start");
return kHyperVPCIBusSyntheticGraphics;
return _pciBusNumber;
}
};

Expand Down
5 changes: 4 additions & 1 deletion MacHyperVSupport/Network/HyperVNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ bool HyperVNetwork::start(IOService *provider) {
//
// Install packet handlers.
//
status = _hvDevice->installPacketActions(this, OSMemberFunctionCast(HyperVVMBusDevice::PacketReadyAction, this, &HyperVNetwork::handlePacket), OSMemberFunctionCast(HyperVVMBusDevice::WakePacketAction, this, &HyperVNetwork::wakePacketHandler), kHyperVNetworkReceivePacketSize);
status = _hvDevice->installPacketActions(this,
OSMemberFunctionCast(HyperVVMBusDevice::PacketReadyAction, this, &HyperVNetwork::handlePacket),
OSMemberFunctionCast(HyperVVMBusDevice::WakePacketAction, this, &HyperVNetwork::wakePacketHandler),
kHyperVNetworkReceivePacketSize);
if (status != kIOReturnSuccess) {
HVSYSLOG("Failed to install packet handlers with status 0x%X", status);
break;
Expand Down
Loading

0 comments on commit b9c08fb

Please sign in to comment.