-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3a3bcfc
commit df0ccca
Showing
5 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// HyperVNetwork.cpp | ||
// Hyper-V network driver | ||
// | ||
// Copyright © 2021 Goldfish64. All rights reserved. | ||
// | ||
|
||
#include "HyperVNetwork.hpp" | ||
#include "HyperVNetworkRegs.hpp" | ||
|
||
OSDefineMetaClassAndStructors(HyperVNetwork, super); | ||
|
||
bool HyperVNetwork::start(IOService *provider) { | ||
if (!super::start(provider)) { | ||
return false; | ||
} | ||
|
||
DBGLOG("Initializing Hyper-V Synthetic Networking"); | ||
|
||
// | ||
// Get parent VMBus device object. | ||
// | ||
hvDevice = OSDynamicCast(HyperVVMBusDevice, provider); | ||
if (hvDevice == NULL) { | ||
super::stop(provider); | ||
return false; | ||
} | ||
hvDevice->retain(); | ||
|
||
// | ||
// Configure the channel. | ||
// | ||
if (!hvDevice->openChannel(kHyperVNetworkRingBufferSize, kHyperVNetworkRingBufferSize, this, OSMemberFunctionCast(IOInterruptEventAction, this, &HyperVNetwork::handleInterrupt))) { | ||
super::stop(provider); | ||
return false; | ||
} | ||
|
||
SYSLOG("Initialized Hyper-V Synthetic Networking"); | ||
return true; | ||
} | ||
|
||
void HyperVNetwork::handleInterrupt(OSObject *owner, IOInterruptEventSource *sender, int count) { | ||
DBGLOG("Interrupt"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// HyperVNetwork.cpp | ||
// Hyper-V network driver | ||
// | ||
// Copyright © 2021 Goldfish64. All rights reserved. | ||
// | ||
|
||
#ifndef HyperVNetwork_hpp | ||
#define HyperVNetwork_hpp | ||
|
||
#include "HyperVVMBusDevice.hpp" | ||
|
||
#define super IOService | ||
|
||
#define SYSLOG(str, ...) SYSLOG_PRINT("HyperVNetwork", str, ## __VA_ARGS__) | ||
#define DBGLOG(str, ...) DBGLOG_PRINT("HyperVNetwork", str, ## __VA_ARGS__) | ||
|
||
class HyperVNetwork : public IOService { | ||
OSDeclareDefaultStructors(HyperVNetwork); | ||
|
||
private: | ||
// | ||
// Parent VMBus device. | ||
// | ||
HyperVVMBusDevice *hvDevice; | ||
|
||
void handleInterrupt(OSObject *owner, IOInterruptEventSource *sender, int count); | ||
|
||
public: | ||
// | ||
// IOService overrides. | ||
// | ||
virtual bool start(IOService *provider) APPLE_KEXT_OVERRIDE; | ||
}; | ||
|
||
#endif /* HyperVNetwork_hpp */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// HyperVNetworkRegs.cpp | ||
// Hyper-V network driver | ||
// | ||
// Copyright © 2021 Goldfish64. All rights reserved. | ||
// | ||
|
||
#ifndef HyperVNetworkRegs_h | ||
#define HyperVNetworkRegs_h | ||
|
||
#define kHyperVNetworkRingBufferSize (128 * PAGE_SIZE) | ||
|
||
#endif /* HyperVNetworkRegs_h */ |