IOFireWireUnit.cpp [plain text]
#define DEBUGGING_LEVEL 0 // 1 = low; 2 = high; 3 = extreme
#define DEBUGLOG kprintf
#include <IOKit/assert.h>
#include <IOKit/IOMessage.h>
#include <IOKit/firewire/IOFireWireUnit.h>
#include <IOKit/firewire/IOFireWireDevice.h>
#include <IOKit/firewire/IOFireWireController.h>
#include <IOKit/firewire/IOConfigDirectory.h>
OSDefineMetaClassAndStructors(IOFireWireUnit, IOFireWireNub)
OSMetaClassDefineReservedUnused(IOFireWireUnit, 0);
OSMetaClassDefineReservedUnused(IOFireWireUnit, 1);
bool IOFireWireUnit::init(OSDictionary *propTable, IOConfigDirectory *directory)
{
if(!IOFireWireNub::init(propTable))
return false;
directory->retain();
fDirectory = directory;
return true;
}
bool IOFireWireUnit::attach(IOService *provider)
{
fDevice = OSDynamicCast(IOFireWireDevice, provider);
if(!fDevice)
return false;
if( !IOFireWireNub::attach(provider))
return (false);
fControl = fDevice->getController();
fDevice->getNodeIDGeneration(fGeneration, fNodeID, fLocalNodeID);
return(true);
}
IOReturn IOFireWireUnit::message( UInt32 mess, IOService * provider,
void * argument )
{
if(provider == fDevice &&
(kIOMessageServiceIsResumed == mess ||
kIOMessageServiceIsSuspended == mess ||
kIOMessageServiceIsRequestingClose == mess ||
kIOFWMessageServiceIsRequestingClose == mess)) {
fDevice->getNodeIDGeneration(fGeneration, fNodeID, fLocalNodeID);
messageClients( mess );
return kIOReturnSuccess;
}
return IOService::message(mess, provider, argument );
}
bool IOFireWireUnit::matchPropertyTable(OSDictionary * table)
{
if (!IOFireWireNub::matchPropertyTable(table)) return false;
bool res = compareProperty(table, gFireWireUnit_Spec_ID) &&
compareProperty(table, gFireWireUnit_SW_Version) &&
compareProperty(table, gFireWireVendor_ID) &&
compareProperty(table, gFireWire_GUID);
return res;
}
bool IOFireWireUnit::handleOpen( IOService * forClient,
IOOptionBits options,
void * arg )
{
if ( isOpen() )
return false ;
bool ok;
ok = fDevice->open(this, options, arg);
if(ok)
ok = IOFireWireNub::handleOpen(forClient, options, arg);
return ok;
}
void IOFireWireUnit::handleClose( IOService * forClient,
IOOptionBits options )
{
IOFireWireNub::handleClose(forClient, options);
fDevice->close(this, options);
}