IOFireWireSBP2Target.cpp [plain text]
#include <IOKit/IOMessage.h>
#define FIREWIREPRIVATE
#include <IOKit/firewire/IOFireWireController.h>
#undef FIREWIREPRIVATE
#include <IOKit/firewire/IOConfigDirectory.h>
#include <IOKit/firewire/IOFireWireDevice.h>
#include <IOKit/IODeviceTreeSupport.h>
#include <IOKit/sbp2/IOFireWireSBP2LUN.h>
#include <IOKit/sbp2/IOFireWireSBP2Target.h>
#include "FWDebugging.h"
const OSSymbol *gCommand_Set_Spec_ID_Symbol = NULL;
const OSSymbol *gCommand_Set_Symbol = NULL;
const OSSymbol *gModule_Vendor_ID_Symbol = NULL;
const OSSymbol *gCommand_Set_Revision_Symbol = NULL;
const OSSymbol *gIOUnit_Symbol = NULL;
const OSSymbol *gFirmware_Revision_Symbol = NULL;
const OSSymbol *gDevice_Type_Symbol = NULL;
const OSSymbol *gGUID_Symbol = NULL;
const OSSymbol *gUnit_Characteristics_Symbol = NULL;
const OSSymbol *gManagement_Agent_Offset_Symbol = NULL;
const OSSymbol *gFast_Start_Symbol = NULL;
OSDefineMetaClassAndStructors(IOFireWireSBP2Target, IOService);
OSMetaClassDefineReservedUnused(IOFireWireSBP2Target, 0);
OSMetaClassDefineReservedUnused(IOFireWireSBP2Target, 1);
OSMetaClassDefineReservedUnused(IOFireWireSBP2Target, 2);
OSMetaClassDefineReservedUnused(IOFireWireSBP2Target, 3);
OSMetaClassDefineReservedUnused(IOFireWireSBP2Target, 4);
OSMetaClassDefineReservedUnused(IOFireWireSBP2Target, 5);
OSMetaClassDefineReservedUnused(IOFireWireSBP2Target, 6);
OSMetaClassDefineReservedUnused(IOFireWireSBP2Target, 7);
OSMetaClassDefineReservedUnused(IOFireWireSBP2Target, 8);
bool IOFireWireSBP2Target::start( IOService *provider )
{
fProviderUnit = OSDynamicCast(IOFireWireUnit, provider);
if (fProviderUnit == NULL)
return false;
ExpansionData * exp_data = (ExpansionData*) IOMalloc( sizeof(ExpansionData) );
if( !exp_data )
{
return false;
}
bzero( exp_data, sizeof(ExpansionData) );
fExpansionData = exp_data;
fControl = fProviderUnit->getController();
fFlags = kIOFWSBP2FailsOnBusResetsDuringIO;
fOpenFromTarget = false;
fOpenFromLUNCount = 0;
fIOCriticalSectionCount = 0;
if( gCommand_Set_Spec_ID_Symbol == NULL )
gCommand_Set_Spec_ID_Symbol = OSSymbol::withCString("Command_Set_Spec_ID");
if( gCommand_Set_Symbol == NULL )
gCommand_Set_Symbol = OSSymbol::withCString("Command_Set");
if( gModule_Vendor_ID_Symbol == NULL )
gModule_Vendor_ID_Symbol = OSSymbol::withCString("Vendor_ID");
if( gCommand_Set_Revision_Symbol == NULL )
gCommand_Set_Revision_Symbol = OSSymbol::withCString("Command_Set_Revision");
if( gIOUnit_Symbol == NULL )
gIOUnit_Symbol = OSSymbol::withCString("IOUnit");
if( gFirmware_Revision_Symbol == NULL )
gFirmware_Revision_Symbol = OSSymbol::withCString("Firmware_Revision");
if( gDevice_Type_Symbol == NULL )
gDevice_Type_Symbol = OSSymbol::withCString("Device_Type");
if( gGUID_Symbol == NULL )
gGUID_Symbol = OSSymbol::withCString("GUID");
if( gUnit_Characteristics_Symbol == NULL )
gUnit_Characteristics_Symbol = OSSymbol::withCString("Unit_Characteristics");
if( gManagement_Agent_Offset_Symbol == NULL )
gManagement_Agent_Offset_Symbol = OSSymbol::withCString("Management_Agent_Offset");
if( gFast_Start_Symbol == NULL )
gFast_Start_Symbol = OSSymbol::withCString("Fast_Start");
if (IOService::start(provider))
{
IOFireWireController * controller = fProviderUnit->getController();
IOService * fwim = (IOService*)controller->getLink();
OSObject * prop = NULL;
UInt32 byteCount1, byteCount2;
byteCount1 = 0;
prop = fwim->getProperty( "FWMaxAsyncReceiveBytes" );
if( prop )
{
byteCount1 = ((OSNumber*)prop)->unsigned32BitValue();
if( byteCount1 != 0 )
{
byteCount1 -= 32;
}
}
byteCount2 = 0;
prop = fwim->getProperty( "FWMaxAsyncReceivePackets" );
if( prop )
{
UInt32 packetCount = ((OSNumber*)prop)->unsigned32BitValue();
if( packetCount != 0 )
{
byteCount2 = (packetCount - 1) * 512; }
}
UInt32 size = byteCount1 < byteCount2 ? byteCount1 : byteCount2;
if( size != 0)
setProperty( "SBP2ReceiveBufferByteCount", size, 32 );
scanForLUNs();
}
else
return false;
FWKLOG( ( "IOFireWireSBP2Target<0x%08lx> : started\n", (UInt32)this ) );
fExpansionData->fStarted = true;
return true;
}
void IOFireWireSBP2Target::stop( IOService *provider )
{
FWKLOG( ( "IOFireWireSBP2Target<0x%08lx>::stop\n", (UInt32)this ) );
IOService::stop(provider);
}
void IOFireWireSBP2Target::free( void )
{
FWKLOG( ( "IOFireWireSBP2Target<0x%08lx>::free\n", (UInt32)this ) );
if( fIOCriticalSectionCount != 0 )
{
IOLog( "IOFireWireSBP2Target<0x%08lx>::free - fIOCriticalSectionCount == %d!\n", (UInt32)this, fIOCriticalSectionCount );
}
while( fIOCriticalSectionCount != 0 )
{
fIOCriticalSectionCount--;
fControl->enableSoftwareBusResets();
}
if( fExpansionData )
{
IOFree( fExpansionData, sizeof(ExpansionData) );
fExpansionData = NULL;
}
IOService::free();
}
IOReturn IOFireWireSBP2Target::message( UInt32 type, IOService *nub, void *arg )
{
IOReturn res = kIOReturnUnsupported;
FWKLOG( ("IOFireWireSBP2Target<0x%08lx> : message 0x%x, arg 0x%08lx\n", (UInt32)this, type, arg) );
res = IOService::message(type, nub, arg);
if( kIOReturnUnsupported == res )
{
switch (type)
{
case kIOMessageServiceIsTerminated:
FWKLOG( ( "IOFireWireSBP2Target<0x%08lx> : kIOMessageServiceIsTerminated\n", (UInt32)this ) );
res = kIOReturnSuccess;
break;
case kIOMessageServiceIsSuspended:
FWKLOG( ( "IOFireWireSBP2Target<0x%08lx> : kIOMessageServiceIsSuspended\n", (UInt32)this ) );
res = kIOReturnSuccess;
break;
case kIOMessageServiceIsResumed:
FWKLOG( ( "IOFireWireSBP2Target<0x%08lx> : kIOMessageServiceIsResumed\n", (UInt32)this ) );
configurePhysicalFilter();
res = kIOReturnSuccess;
break;
default: break;
}
}
if( type != kIOMessageServiceIsTerminated &&
type != (UInt32)kIOMessageFWSBP2ReconnectFailed &&
type != (UInt32)kIOMessageFWSBP2ReconnectComplete )
{
messageClients( type, arg );
}
return res;
}
IOFireWireUnit * IOFireWireSBP2Target::getFireWireUnit( void )
{
return fProviderUnit;
}
bool IOFireWireSBP2Target::handleOpen( IOService * forClient, IOOptionBits options, void * arg )
{
bool ok = true;
FWKLOG(( "IOFireWireSBP2Target<0x%08lx>::handleOpen entered fOpenFromLUNCount = %d, fOpenFromTarget = %d\n", (UInt32)this, fOpenFromLUNCount, fOpenFromTarget ));
IOFireWireSBP2LUN * lunClient = OSDynamicCast( IOFireWireSBP2LUN, forClient );
if( lunClient != NULL )
{
if( fOpenFromTarget )
return false;
if( fOpenFromLUNCount == 0 )
{
ok = fProviderUnit->open(this, options, arg);
if( ok )
{
fOpenFromLUNCount++;
ok = IOService::handleOpen( this, options, arg );
FWKLOG(( "IOFireWireSBP2Target<0x%08lx>::handleOpen called open\n", (UInt32)this ));
}
}
else
{
fOpenFromLUNCount++;
}
}
else
{
if( fOpenFromLUNCount != 0 )
return false;
if( !fOpenFromTarget ) {
ok = fProviderUnit->open(this, options, arg);
if( ok )
{
fOpenFromTarget = true;
ok = IOService::handleOpen( forClient, options, arg );
FWKLOG(( "IOFireWireSBP2Target<0x%08lx>::handleOpen called open\n", (UInt32)this ));
}
}
else
ok = false; }
FWKLOG(( "IOFireWireSBP2Target<0x%08lx>::handleOpen - exit handleOpen fOpenFromLUNCount = %d, fOpenFromTarget = %d\n", (UInt32)this, fOpenFromLUNCount, fOpenFromTarget ));
return ok;
}
void IOFireWireSBP2Target::handleClose( IOService * forClient, IOOptionBits options )
{
FWKLOG(( "IOFireWireSBP2Target<0x%08lx>::handleClose enter handleClose fOpenFromLUNCount = %d, fOpenFromTarget = %d\n", (UInt32)this, fOpenFromLUNCount, fOpenFromTarget ));
IOFireWireSBP2LUN * lunClient = OSDynamicCast( IOFireWireSBP2LUN, forClient );
if( lunClient != NULL )
{
if( fOpenFromLUNCount != 0 ) {
fOpenFromLUNCount--;
if( fOpenFromLUNCount == 0 ) {
IOService::handleClose( this, options);
fProviderUnit->close(this, options);
FWKLOG(( "IOFireWireSBP2Target<0x%08lx>::handleClose - called close\n", (UInt32)this ));
}
}
}
else
{
if( fOpenFromTarget ) {
fOpenFromTarget = false;
IOService::handleClose(forClient, options);
fProviderUnit->close(this, options);
FWKLOG(( "IOFireWireSBP2Target<0x%08lx>::handleClose - called close\n", (UInt32)this ));
}
}
FWKLOG(( "IOFireWireSBP2Target<0x%08lx>::handleClose - exit handleClose fOpenFromLUNCount = %d, fOpenFromTarget = %d\n", (UInt32)this, fOpenFromLUNCount, fOpenFromTarget ));
}
bool IOFireWireSBP2Target::handleIsOpen( const IOService * forClient ) const
{
if( fOpenFromLUNCount != 0 )
{
IOFireWireSBP2LUN * lunClient = OSDynamicCast( IOFireWireSBP2LUN, forClient );
return (lunClient != NULL );
}
if( fOpenFromTarget )
{
return IOService::handleIsOpen( forClient );
}
return false;
}
void IOFireWireSBP2Target::scanForLUNs( void )
{
IOReturn status = kIOReturnSuccess;
IOReturn tempStatus = kIOReturnSuccess;
LUNInfo info;
info.cmdSpecID = 0;
info.cmdSet = 0;
info.vendorID = 0;
info.softwareRev = 0;
info.firmwareRev = 0;
info.lun = 0;
info.devType = 0;
info.unitCharacteristics = 0;
info.managementOffset = 0;
info.revision = 0;
info.fastStartSupported = false;
info.fastStart = 0;
IOConfigDirectory * directory;
IOFireWireDevice * device = NULL;
IOService * providerService = fProviderUnit->getProvider();
if( providerService == NULL )
status = kIOReturnError;
if( status == kIOReturnSuccess )
{
device = OSDynamicCast( IOFireWireDevice, providerService );
if( device == NULL )
status = kIOReturnError;
FWKLOG( ("IOFireWireSBP2Target<0x%08lx> : unit = 0x%08lx, provider = 0x%08lx, device = 0x%08lx\n", (UInt32)this, fProviderUnit, providerService, device) );
}
if( status == kIOReturnSuccess )
{
status = device->getConfigDirectory( directory );
FWKLOG( ( "IOFireWireSBP2Target<0x%08lx> : status = %d\n", (UInt32)this, status ) );
}
if( status == kIOReturnSuccess )
tempStatus = directory->getKeyValue( kConfigModuleVendorIdKey, info.vendorID );
status = fProviderUnit->getConfigDirectory( directory );
FWKLOG( ( "IOFireWireSBP2Target<0x%08lx> : status = %d\n", (UInt32)this, status ) );
if( status == kIOReturnSuccess )
status = directory->getKeyValue( kCmdSpecIDKey, info.cmdSpecID );
if( status == kIOReturnSuccess )
status = directory->getKeyValue( kCmdSetKey, info.cmdSet );
if( status == kIOReturnSuccess )
status = directory->getKeyValue( kUnitCharacteristicsKey, info.unitCharacteristics );
status = directory->getKeyValue( kManagementAgentOffsetKey, info.managementOffset );
if( status == kIOReturnSuccess )
{
IOService *parent = this;
while(parent) {
if(parent->inPlane(gIODTPlane))
break;
parent = parent->getProvider();
}
if(parent) {
char location[9];
sprintf(location, "%lx", info.managementOffset);
attachToParent(parent, gIODTPlane);
setLocation(location, gIODTPlane);
setName("sbp-2", gIODTPlane);
}
}
if( status == kIOReturnSuccess )
tempStatus = directory->getKeyValue( kRevisionKey, info.revision );
if( status == kIOReturnSuccess && info.revision != 0 )
{
tempStatus = directory->getKeyValue( kFastStartKey, info.fastStart );
if( tempStatus == kIOReturnSuccess )
{
info.fastStartSupported = true;
}
}
if( status == kIOReturnSuccess )
tempStatus = directory->getKeyValue( kSoftwareRevKey, info.softwareRev );
if( status == kIOReturnSuccess )
tempStatus = directory->getKeyValue( kFirmwareRevKey, info.firmwareRev );
FWKLOG( ( "IOFireWireSBP2Target<0x%08lx> : status = %d, cmdSpecID = %d, cmdSet = %d, vendorID = %d, softwareRev = %d, firmwareRev = %d\n",
(UInt32)this, status, info.cmdSpecID, info.cmdSet, info.vendorID, info.softwareRev, info.firmwareRev ) );
if( status == kIOReturnSuccess )
{
for( int pos = 0; pos < directory->getNumEntries(); pos++ )
{
UInt32 key;
tempStatus = directory->getIndexEntry( pos, key );
FWKLOG( ( "IOFireWireSBP2Target<0x%08lx> : tempStatus = %d, pos = %d, key = %d\n",
(UInt32)this, tempStatus, pos, key ) );
if( tempStatus == kIOReturnSuccess && key >> kConfigEntryKeyValuePhase == kLUNKey )
{
UInt32 data;
tempStatus = directory->getIndexValue( pos, data );
if( tempStatus == kIOReturnSuccess )
{
info.lun = data & 0x0000ffff;
info.devType = (data & 0x001f0000) >> 16;
FWKLOG( ( "IOFireWireSBP2Target<0x%08lx> : cmdSpecID = %d, cmdSet = %d, vendorID = %d, softwareRev = %d\n",
(UInt32)this, info.cmdSpecID, info.cmdSet, info.vendorID, info.softwareRev ) );
FWKLOG( ( "IOFireWireSBP2Target<0x%08lx> : firmwareRev = %d, lun = %d, devType = %d\n",
(UInt32)this, info.firmwareRev, info.lun, info.devType ) );
FWKLOG( ( "IOFireWireSBP2Target<0x%08lx> : unitCharacteristics = %d, managementOffset = %d,\n",
(UInt32)this, info.unitCharacteristics, info.managementOffset ) );
FWKLOG( ( "IOFireWireSBP2Target<0x%08lx> : revision = %d, fastStartSupported = %d, fastStart = 0x%08lx\n",
(UInt32)this, info.revision, info.fastStartSupported, info.fastStart ) );
if( (info.cmdSpecID & 0x00ffffff) || (info.cmdSet & 0x00ffffff) )
{
createLUN( &info );
}
}
}
}
}
if( status == kIOReturnSuccess )
{
OSIterator * directoryIterator;
IOConfigDirectory * lunDirectory;
UInt32 lunValue;
status = directory->getKeySubdirectories( kLUNDirectoryKey, directoryIterator );
while( (lunDirectory = OSDynamicCast(IOConfigDirectory,directoryIterator->getNextObject())) != NULL )
{
if( info.revision != 0 )
{
tempStatus = directory->getKeyValue( kFastStartKey, info.fastStart );
if( tempStatus == kIOReturnSuccess )
{
info.fastStartSupported = true;
}
}
tempStatus = lunDirectory->getKeyValue( kLUNKey, lunValue );
if( tempStatus == kIOReturnSuccess )
{
info.lun = lunValue & 0x0000ffff;
info.devType = (lunValue & 0x001f0000) >> 16;
FWKLOG( ( "IOFireWireSBP2Target<0x%08lx> : cmdSpecID = %d, cmdSet = %d, vendorID = %d, softwareRev = %d\n",
(UInt32)this, info.cmdSpecID, info.cmdSet, info.vendorID, info.softwareRev ) );
FWKLOG( ( "IOFireWireSBP2Target<0x%08lx> : firmwareRev = %d, lun = %d, devType = %d\n",
(UInt32)this, info.firmwareRev, info.lun, info.devType ) );
FWKLOG( ( "IOFireWireSBP2Target<0x%08lx> : revision = %d, fastStartSupported = %d, fastStart = 0x%08lx\n",
(UInt32)this, info.revision, info.fastStartSupported, info.fastStart ) );
if( (info.cmdSpecID & 0x00ffffff) || (info.cmdSet & 0x00ffffff) )
{
createLUN( &info );
}
}
}
directoryIterator->release();
}
OSObject *prop;
if( status == kIOReturnSuccess )
{
prop = OSNumber::withNumber( info.cmdSpecID, 32 );
setProperty( gCommand_Set_Spec_ID_Symbol, prop );
prop->release();
prop = OSNumber::withNumber( info.cmdSet, 32 );
setProperty( gCommand_Set_Symbol, prop );
prop->release();
prop = OSNumber::withNumber( info.vendorID, 32 );
setProperty( gModule_Vendor_ID_Symbol, prop );
prop->release();
prop = OSNumber::withNumber( info.softwareRev, 32 );
setProperty( gCommand_Set_Revision_Symbol, prop );
prop->release();
prop = OSNumber::withNumber( info.firmwareRev, 32 );
setProperty( gFirmware_Revision_Symbol, prop );
prop->release();
prop = OSNumber::withNumber( info.devType, 32 );
setProperty( gDevice_Type_Symbol, prop );
prop->release();
prop = fProviderUnit->getProperty(gGUID_Symbol);
if( prop )
setProperty( gGUID_Symbol, prop );
prop = fProviderUnit->getProperty(gFireWireModel_ID);
if( prop )
setProperty( gFireWireModel_ID, prop );
prop = fProviderUnit->getProperty(gFireWireProduct_Name);
if( prop )
setProperty( gFireWireProduct_Name, prop );
prop = fProviderUnit->getProperty(gFireWireVendor_Name);
if( prop )
setProperty( gFireWireVendor_Name, prop );
registerService();
}
}
IOReturn IOFireWireSBP2Target::createLUN( LUNInfo * info )
{
IOReturn status = kIOReturnSuccess;
OSDictionary * propTable = OSDictionary::withCapacity(7);
OSObject *prop;
if( propTable )
{
prop = OSNumber::withNumber( info->cmdSpecID, 32 );
propTable->setObject( gCommand_Set_Spec_ID_Symbol, prop );
prop->release();
prop = OSNumber::withNumber( info->cmdSet, 32 );
propTable->setObject( gCommand_Set_Symbol, prop );
prop->release();
prop = OSNumber::withNumber( info->vendorID, 32 );
propTable->setObject( gModule_Vendor_ID_Symbol, prop );
prop->release();
prop = OSNumber::withNumber( info->softwareRev, 32 );
propTable->setObject( gCommand_Set_Revision_Symbol, prop );
prop->release();
prop = OSNumber::withNumber( info->firmwareRev, 32 );
propTable->setObject( gFirmware_Revision_Symbol, prop );
prop->release();
prop = OSNumber::withNumber( info->lun, 32 );
propTable->setObject( gIOUnit_Symbol, prop );
prop->release();
prop = OSNumber::withNumber( info->devType, 32 );
propTable->setObject( gDevice_Type_Symbol, prop );
prop->release();
prop = OSNumber::withNumber( info->unitCharacteristics, 32 );
propTable->setObject( gUnit_Characteristics_Symbol, prop );
prop->release();
prop = OSNumber::withNumber(info->managementOffset, 32 );
propTable->setObject( gManagement_Agent_Offset_Symbol, prop );
prop->release();
if( info->fastStartSupported )
{
prop = OSNumber::withNumber( info->fastStart, 32 );
propTable->setObject( gFast_Start_Symbol, prop );
prop->release();
}
prop = fProviderUnit->getProperty(gGUID_Symbol);
if( prop )
propTable->setObject( gGUID_Symbol, prop );
prop = fProviderUnit->getProperty(gFireWireModel_ID);
if( prop )
propTable->setObject( gFireWireModel_ID, prop );
prop = fProviderUnit->getProperty(gFireWireProduct_Name);
if( prop )
propTable->setObject( gFireWireProduct_Name, prop );
prop = fProviderUnit->getProperty(gFireWireVendor_Name);
if( prop )
propTable->setObject( gFireWireVendor_Name, prop );
IOFireWireSBP2LUN * newLUN = new IOFireWireSBP2LUN;
if( newLUN != NULL )
{
bool success = true;
if( success )
success = newLUN->init(propTable);
if( success )
success = newLUN->attach(this);
if( success )
newLUN->registerService();
FWKLOG( ( "IOFireWireSBP2Target<0x%08lx> : created LUN object - success = %d\n", (UInt32)this, success ) );
if( !success )
status = kIOReturnError;
newLUN->release();
}
propTable->release();
}
return status;
}
bool IOFireWireSBP2Target::matchPropertyTable(OSDictionary * table)
{
if( !IOService::matchPropertyTable(table) )
return false;
bool res = compareProperty(table, gCommand_Set_Spec_ID_Symbol) &&
compareProperty(table, gCommand_Set_Symbol) &&
compareProperty(table, gModule_Vendor_ID_Symbol) &&
compareProperty(table, gCommand_Set_Revision_Symbol) &&
compareProperty(table, gFirmware_Revision_Symbol) &&
compareProperty(table, gDevice_Type_Symbol) &&
compareProperty(table, gGUID_Symbol) &&
compareProperty(table, gFireWireModel_ID);
return res;
}
void IOFireWireSBP2Target::setTargetFlags( UInt32 flags )
{
fFlags |= flags;
FWKLOG(( "IOFireWireSBP2Target<0x%08lx>::setTargetFlags 0x%08lx\n", (UInt32)this, fFlags ));
configurePhysicalFilter();
}
void IOFireWireSBP2Target::clearTargetFlags( UInt32 flags )
{
fFlags &= ~flags;
FWKLOG(( "IOFireWireSBP2Target<0x%08lx>::clearTargetFlags 0x%08lx\n", (UInt32)this, fFlags ));
configurePhysicalFilter();
}
UInt32 IOFireWireSBP2Target::getTargetFlags( void )
{
return fFlags;
}
void IOFireWireSBP2Target::configurePhysicalFilter( void )
{
bool disablePhysicalAccess = false;
if( fExpansionData == NULL )
return;
if( !fExpansionData->fStarted )
return;
if( fFlags & kIOFWSBP2FailsOnAckBusy )
{
IOFireWireController * controller = fProviderUnit->getController();
IOService * fwim = (IOService*)controller->getLink();
UInt32 deviceCount = 0;
OSData * data = (OSData*)controller->getProperty( "FireWire Self IDs" );
UInt32 numIDs = data->getLength() / sizeof(UInt32);
UInt32 *IDs = (UInt32*)data->getBytesNoCopy();
UInt32 i;
for( i = 0; i < numIDs; i++ )
{
UInt32 current_id = IDs[i];
if( (current_id & kFWSelfIDPacketType) == 0 &&
(current_id & kFWSelfID0L) )
{
deviceCount++;
}
}
if( (deviceCount > 2) && (fwim->getProperty( "PhysicalUnitBlocksOnReads" ) != NULL) )
{
disablePhysicalAccess = true;
}
}
if( disablePhysicalAccess )
{
FWKLOG(( "IOFireWireSBP2Target<0x%08lx>::configurePhysicalFilter disabling physical access for unit 0x%08lx\n", (UInt32)this, fProviderUnit ));
fProviderUnit->setNodeFlags( kIOFWDisableAllPhysicalAccess );
}
else
{
FWKLOG(( "IOFireWireSBP2Target<0x%08lx>::configurePhysicalFilter enabling physical access for unit 0x%08lx\n", (UInt32)this, fProviderUnit ));
fProviderUnit->clearNodeFlags( kIOFWDisableAllPhysicalAccess );
}
}
IOReturn IOFireWireSBP2Target::beginIOCriticalSection( void )
{
IOReturn status = kIOReturnSuccess;
FWKLOG(( "IOFireWireSBP2Target<0x%08lx>::beginIOCriticalSection\n", (UInt32)this ));
if( fFlags & kIOFWSBP2FailsOnBusResetsDuringIO )
{
FWKLOG(( "IOFireWireSBP2Target<0x%08lx>::beginIOCriticalSection fControl->disableSoftwareBusResets()\n", (UInt32)this ));
status = fControl->disableSoftwareBusResets();
if( status == kIOReturnSuccess )
{
fIOCriticalSectionCount++;
}
}
FWKLOG(( "IOFireWireSBP2Target<0x%08lx>::beginIOCriticalSection status = 0x%08lx\n", (UInt32)this, (UInt32)status ));
return status;
}
void IOFireWireSBP2Target::endIOCriticalSection( void )
{
FWKLOG(( "IOFireWireSBP2Target<0x%08lx>::endIOCriticalSection\n", (UInt32)this ));
if( fFlags & kIOFWSBP2FailsOnBusResetsDuringIO )
{
FWKLOG(( "IOFireWireSBP2Target<0x%08lx>::endIOCriticalSection fControl->enableSoftwareBusResets()\n", (UInt32)this ));
if( fIOCriticalSectionCount != 0 )
{
fIOCriticalSectionCount--;
fControl->enableSoftwareBusResets();
}
else
{
IOLog( "IOFireWireSBP2Target<0x%08lx>::endIOCriticalSection - fIOCriticalSectionCount == 0!\n", (UInt32)this );
}
}
}