#import <IOKit/firewire/IOFireWireNub.h>
#import <IOKit/firewire/IOFireWireController.h>
#import <IOKit/firewire/IOConfigDirectory.h>
#import <IOKit/firewire/IOFWSimpleContiguousPhysicalAddressSpace.h>
#import <IOKit/firewire/IOFireWireLink.h>
#import "IOFireWireUserClient.h"
#import <IOKit/assert.h>
#import <IOKit/IOMessage.h>
OSDefineMetaClassAndStructors(IOFireWireNubAux, OSObject);
OSMetaClassDefineReservedUnused(IOFireWireNubAux, 0);
OSMetaClassDefineReservedUnused(IOFireWireNubAux, 1);
OSMetaClassDefineReservedUnused(IOFireWireNubAux, 2);
OSMetaClassDefineReservedUnused(IOFireWireNubAux, 3);
OSMetaClassDefineReservedUnused(IOFireWireNubAux, 4);
OSMetaClassDefineReservedUnused(IOFireWireNubAux, 5);
OSMetaClassDefineReservedUnused(IOFireWireNubAux, 6);
OSMetaClassDefineReservedUnused(IOFireWireNubAux, 7);
OSMetaClassDefineReservedUnused(IOFireWireNubAux, 8);
OSMetaClassDefineReservedUnused(IOFireWireNubAux, 9);
OSMetaClassDefineReservedUnused(IOFireWireNubAux, 10);
OSMetaClassDefineReservedUnused(IOFireWireNubAux, 11);
OSMetaClassDefineReservedUnused(IOFireWireNubAux, 12);
OSMetaClassDefineReservedUnused(IOFireWireNubAux, 13);
OSMetaClassDefineReservedUnused(IOFireWireNubAux, 14);
OSMetaClassDefineReservedUnused(IOFireWireNubAux, 15);
#pragma mark -
bool IOFireWireNubAux::init( IOFireWireNub * primary )
{
bool success = true;
if( !OSObject::init() )
success = false;
if( success )
{
fPrimary = primary;
fTerminationState = kNotTerminated;
}
return success;
}
void IOFireWireNubAux::free()
{
OSObject::free();
}
UInt32 IOFireWireNubAux::hopCount( IOFireWireNub * nub )
{
return fPrimary->fControl->hopCount( fPrimary->fNodeID, nub->fNodeID );
}
UInt32 IOFireWireNubAux::hopCount( void )
{
return fPrimary->fControl->hopCount( fPrimary->fNodeID );
}
TerminationState IOFireWireNubAux::getTerminationState( void )
{
return fTerminationState;
}
void IOFireWireNubAux::setTerminationState( TerminationState state )
{
fTerminationState = state;
}
bool IOFireWireNubAux::isPhysicalAccessEnabled( void )
{
return false;
}
IOFWSimpleContiguousPhysicalAddressSpace * IOFireWireNubAux::createSimpleContiguousPhysicalAddressSpace( vm_size_t size, IODirection direction )
{
return fPrimary->fControl->createSimpleContiguousPhysicalAddressSpace( size, direction );
}
IOFWSimplePhysicalAddressSpace * IOFireWireNubAux::createSimplePhysicalAddressSpace( vm_size_t size, IODirection direction )
{
return fPrimary->fControl->createSimplePhysicalAddressSpace( size, direction );
}
#pragma mark -
OSDefineMetaClass( IOFireWireNub, IOService )
OSDefineAbstractStructors(IOFireWireNub, IOService)
OSMetaClassDefineReservedUnused(IOFireWireNub, 2);
OSMetaClassDefineReservedUnused(IOFireWireNub, 3);
bool IOFireWireNub::init( OSDictionary * propTable )
{
bool success = true;
OSNumber *offset;
if( !IOService::init(propTable) )
{
success = false;
}
if( success )
{
fAuxiliary = createAuxiliary();
if( fAuxiliary == NULL )
success = false;
}
if( success )
{
offset = OSDynamicCast(OSNumber, propTable->getObject("GUID"));
if( offset )
fUniqueID = offset->unsigned64BitValue();
fConfigDirectorySet = OSSet::withCapacity(1);
if( fConfigDirectorySet == NULL )
success = false;
}
return success;
}
IOFireWireNubAux * IOFireWireNub::createAuxiliary( void )
{
IOFireWireNubAux * auxiliary;
auxiliary = new IOFireWireNubAux;
if( auxiliary != NULL && !auxiliary->init(this) )
{
auxiliary->release();
auxiliary = NULL;
}
return auxiliary;
}
void IOFireWireNub::free()
{
if( fDirectory != NULL )
{
fDirectory->release();
fDirectory = NULL;
}
if( fConfigDirectorySet != NULL )
{
fConfigDirectorySet->release();
fConfigDirectorySet = NULL;
}
if( fAuxiliary != NULL )
{
fAuxiliary->release();
fAuxiliary = NULL;
}
if( fControl != NULL )
{
fControl->release();
fControl = NULL;
}
IOService::free();
}
IOReturn IOFireWireNub::getNodeIDGeneration(UInt32 &generation, UInt16 &nodeID, UInt16 &localID) const
{
generation = fGeneration;
nodeID = fNodeID;
localID = fLocalNodeID;
return kIOReturnSuccess;
}
IOReturn IOFireWireNub::getNodeIDGeneration(UInt32 &generation, UInt16 &nodeID) const
{
generation = fGeneration;
nodeID = fNodeID;
return kIOReturnSuccess;
}
IOFWSpeed IOFireWireNub::FWSpeed() const
{
return fControl->FWSpeed(fNodeID);
}
IOFWSpeed IOFireWireNub::FWSpeed(const IOFireWireNub *dst) const
{
return fControl->FWSpeed(fNodeID, dst->fNodeID);
}
int IOFireWireNub::maxPackLog(bool forSend) const
{
int log = fControl->maxPackLog(forSend, fNodeID);
return log;
}
int IOFireWireNub::maxPackLog(bool forSend, FWAddress address) const
{
int log = fControl->maxPackLog(forSend, fNodeID);
if(forSend) {
if(log > fMaxWritePackLog)
log = fMaxWritePackLog;
}
else if(address.addressHi == kCSRRegisterSpaceBaseAddressHi &&
address.addressLo > kConfigROMBaseAddress &&
address.addressLo < kConfigROMBaseAddress + 1024) {
if(log > fMaxReadROMPackLog)
log = fMaxReadROMPackLog;
}
else if(log > fMaxReadPackLog)
log = fMaxReadPackLog;
return log;
}
int IOFireWireNub::maxPackLog(bool forSend, const IOFireWireNub *dst) const
{
int log;
if(forSend) {
log = fControl->maxPackLog(fNodeID, dst->fNodeID);
}
else {
log = fControl->maxPackLog(dst->fNodeID, fNodeID);
}
return log;
}
void IOFireWireNub::setMaxPackLog(bool forSend, bool forROM, int maxPackLog)
{
if(forSend)
fMaxWritePackLog = maxPackLog;
else if(forROM)
fMaxReadROMPackLog = maxPackLog;
else
fMaxReadPackLog = maxPackLog;
}
IOFWReadCommand *IOFireWireNub::createReadCommand(FWAddress devAddress, IOMemoryDescriptor *hostMem,
FWDeviceCallback completion, void *refcon,
bool failOnReset)
{
IOFWReadCommand * cmd;
cmd = new IOFWReadCommand;
if(cmd) {
if(!cmd->initAll(this, devAddress,
hostMem, completion, refcon, failOnReset)) {
cmd->release();
cmd = NULL;
}
}
return cmd;
}
IOFWReadQuadCommand *IOFireWireNub::createReadQuadCommand(FWAddress devAddress, UInt32 *quads, int numQuads,
FWDeviceCallback completion, void *refcon,
bool failOnReset)
{
IOFWReadQuadCommand * cmd;
cmd = new IOFWReadQuadCommand;
if(cmd) {
if(!cmd->initAll(this, devAddress, quads, numQuads,
completion, refcon, failOnReset)) {
cmd->release();
cmd = NULL;
}
}
return cmd;
}
IOFWWriteCommand *IOFireWireNub::createWriteCommand(FWAddress devAddress, IOMemoryDescriptor *hostMem,
FWDeviceCallback completion, void *refcon,
bool failOnReset)
{
IOFWWriteCommand * cmd;
cmd = new IOFWWriteCommand;
if(cmd)
{
if(!cmd->initAll(this, devAddress, hostMem,
completion, refcon, failOnReset))
{
cmd->release();
cmd = NULL;
}
}
return cmd;
}
IOFWWriteQuadCommand *IOFireWireNub::createWriteQuadCommand(FWAddress devAddress,
UInt32 *quads, int numQuads,
FWDeviceCallback completion, void *refcon,
bool failOnReset)
{
IOFWWriteQuadCommand * cmd;
cmd = new IOFWWriteQuadCommand;
if(cmd)
{
if(!cmd->initAll(this, devAddress, quads, numQuads,
completion, refcon, failOnReset))
{
cmd->release();
cmd = NULL;
}
}
return cmd;
}
IOFWCompareAndSwapCommand *
IOFireWireNub::createCompareAndSwapCommand(FWAddress devAddress, const UInt32 *cmpVal, const UInt32 *newVal,
int size, FWDeviceCallback completion, void *refcon, bool failOnReset)
{
IOFWCompareAndSwapCommand * cmd;
cmd = new IOFWCompareAndSwapCommand;
if(cmd)
{
if(!cmd->initAll(this, devAddress, cmpVal, newVal, size, completion, refcon, failOnReset))
{
cmd->release();
cmd = NULL;
}
}
return cmd;
}
IOFWPhysicalAddressSpace *IOFireWireNub::createPhysicalAddressSpace(IOMemoryDescriptor *mem)
{
return fControl->createPhysicalAddressSpace(mem);
}
IOFWPseudoAddressSpace *IOFireWireNub::createPseudoAddressSpace(FWAddress *addr, UInt32 len,
FWReadCallback reader, FWWriteCallback writer, void *refcon)
{
return fControl->createPseudoAddressSpace(addr, len, reader, writer, refcon);
}
IOReturn IOFireWireNub::getConfigDirectory(IOConfigDirectory *&dir)
{
fControl->closeGate();
dir = fDirectory;
fConfigDirectorySet->setObject( fDirectory );
fControl->openGate();
return kIOReturnSuccess;
}
IOReturn IOFireWireNub::getConfigDirectoryRef( IOConfigDirectory *&dir )
{
dir = fDirectory;
fDirectory->retain();
return kIOReturnSuccess;
}
IOReturn IOFireWireNub::setConfigDirectory( IOConfigDirectory *directory )
{
IOConfigDirectory * oldDirectory = fDirectory;
directory->retain();
fDirectory = directory;
if( oldDirectory )
oldDirectory->release();
return kIOReturnSuccess;
}
IOFireWireBus * IOFireWireNub::getBus() const
{
return (IOFireWireBus *)fControl;
}
IOFireWireController * IOFireWireNub::getController() const
{
return fControl;
}
const CSRNodeUniqueID& IOFireWireNub::getUniqueID() const
{
return fUniqueID;
}
void IOFireWireNub::setNodeFlags( UInt32 flags )
{
}
void IOFireWireNub::clearNodeFlags( UInt32 flags )
{
}
UInt32 IOFireWireNub::getNodeFlags( void )
{
return 0;
}