IOFireWireUserClient.h [plain text]
#import "FWDebugging.h"
#import "IOFireWireLibPriv.h"
#import <IOKit/IOMemoryCursor.h>
#import <IOKit/IOUserClient.h>
#import <IOKit/firewire/IOFWCommand.h>
using namespace IOFireWireLib ;
class IOFireWireDevice;
class IOFWIsochChannel ;
class IOFWUserObjectExporter ;
class IOFireWireUserClient ;
class IOFWBufferFillIsochPort ;
class IOFireWireNub ;
#if IOFIREWIREUSERCLIENTDEBUG > 0
class IOFWUserDebugInfo : public OSObject
{
OSDeclareDefaultStructors( IOFWUserDebugInfo ) ;
private :
IOFireWireUserClient * fUserClient ;
public:
virtual bool init( IOFireWireUserClient & userClient ) ;
virtual bool serialize( OSSerialize * s ) const ;
virtual void free () ;
} ;
#endif
#pragma mark -
class IOFireWireUserClient : public IOUserClient
{
OSDeclareDefaultStructors(IOFireWireUserClient)
friend class IOFWUserDebugInfo ;
private:
IOService * fObjectTable[3] ;
task_t fTask;
const IOExternalMethod * fMethods ;
const IOExternalAsyncMethod * fAsyncMethods ;
IOFWUserObjectExporter * fExporter ;
mach_port_t fNotificationPort ;
UInt32 fNotificationRefCon ;
OSAsyncReference64 fBusResetAsyncNotificationRef ;
OSAsyncReference64 fBusResetDoneAsyncNotificationRef ;
IONotifier* fNotifier ;
IOService* fOpenClient ;
bool fUnsafeResets ;
IOFireWireNub * fOwner ;
bool fClippedMaxRec;
unsigned fSelfOpenCount ;
#if IOFIREWIREUSERCLIENTDEBUG > 0
IOFWUserDebugInfo * fDebugInfo ;
#endif
public:
virtual void free () ;
virtual IOReturn setProperties ( OSObject * properties ) ;
virtual bool initWithTask( task_t owningTask, void * securityToken, UInt32 type, OSDictionary * properties );
virtual bool start ( IOService * provider );
virtual void stop ( IOService * provider );
virtual IOReturn message(
UInt32 type,
IOService* provider,
void* argument );
virtual IOReturn externalMethod( uint32_t selector,
IOExternalMethodArguments * arguments,
IOExternalMethodDispatch * dispatch,
OSObject * target,
void * reference);
virtual IOReturn clientClose ( void );
virtual IOReturn clientDied ( void );
inline static IOReturn sendAsyncResult64 (OSAsyncReference64 reference,
IOReturn result,
io_user_reference_t args[],
UInt32 numArgs)
{ return IOUserClient::sendAsyncResult64(reference, result, args, numArgs) ; }
IOReturn registerNotificationPort (
mach_port_t port,
UInt32 type,
UInt32 refCon ) ;
const task_t getOwningTask () const {return fTask;}
IOFWUserObjectExporter * getExporter() { return fExporter; }
IOFireWireNub * getOwner () const { return fOwner ; }
#pragma mark -
void initMethodTable() ;
void initAsyncMethodTable() ;
#pragma mark -
IOReturn userOpen() ;
IOReturn userOpenWithSessionRef(IOService* session) ;
IOReturn seize(IOOptionBits inFlags ) ;
IOReturn userClose() ;
#pragma mark -
IOReturn copyToUserBuffer (
IOVirtualAddress kernelBuffer,
mach_vm_address_t userBuffer,
IOByteCount bytes,
IOByteCount & bytesCopied ) ;
IOReturn copyUserData (
mach_vm_address_t userBuffer,
mach_vm_address_t kernBuffer,
mach_vm_size_t bytes ) const ;
#pragma mark -
IOReturn readQuad ( const ReadQuadParams* inParams, UInt32* outVal ) ;
IOReturn read ( const ReadParams* inParams, IOByteCount* outBytesTransferred ) ;
IOReturn writeQuad ( const WriteQuadParams* inParams ) ;
IOReturn write ( const WriteParams* inParams, IOByteCount* outBytesTransferred ) ;
IOReturn compareSwap ( const CompareSwapParams* inParams, UInt32* oldVal) ;
#pragma mark -
IOReturn busReset ();
IOReturn getGenerationAndNodeID(
UInt32* outGeneration,
UInt32* outNodeID) const ;
IOReturn getLocalNodeID(
UInt32* outLocalNodeID) const ;
IOReturn getResetTime(
AbsoluteTime* outResetTime) const ;
IOReturn releaseUserObject (
UserObjectHandle obj ) ;
#pragma mark -
IOReturn getOSStringData(
UserObjectHandle inStringRef,
UInt32 inStringLen,
mach_vm_address_t inStringBuffer,
UInt32* outStringLen) ;
IOReturn getOSDataData(
UserObjectHandle inDataRef,
IOByteCount inDataLen,
mach_vm_address_t inDataBuffer,
IOByteCount* outDataLen) ;
#pragma mark -
IOReturn localConfigDirectory_Create (
UserObjectHandle * dir ) ;
IOReturn localConfigDirectory_addEntry_Buffer (
UserObjectHandle dirHandle,
int key,
char * buffer,
UInt32 kr_size,
const char * descCString,
UInt32 descLen ) const ;
IOReturn localConfigDirectory_addEntry_UInt32 (
UserObjectHandle dirHandle,
int key,
UInt32 value,
const char * descCString,
UInt32 descLen ) const ;
IOReturn localConfigDirectory_addEntry_FWAddr (
UserObjectHandle dirHandle,
int key,
const char * descCString,
UInt32 descLen,
FWAddress * value ) const ;
IOReturn localConfigDirectory_addEntry_UnitDir (
UserObjectHandle dirHandle,
int key,
UserObjectHandle valueHandle,
const char * descCString,
UInt32 descLen ) const ;
IOReturn localConfigDirectory_Publish (
UserObjectHandle dir ) const ;
IOReturn localConfigDirectory_Unpublish (
UserObjectHandle dir ) const ;
#pragma mark -
IOReturn addressSpace_Create (
AddressSpaceCreateParams * params,
UserObjectHandle * outAddressSpaceHandle ) ;
IOReturn addressSpace_GetInfo (
UserObjectHandle addrSpace,
AddressSpaceInfo * outInfo ) ;
IOReturn addressSpace_ClientCommandIsComplete (
UserObjectHandle inAddrSpaceRef,
FWClientCommandID inCommandID,
IOReturn inResult ) ;
IOReturn setAsyncStreamRef_Packet (
OSAsyncReference64 asyncRef,
UserObjectHandle asyncStreamListenerHandle,
mach_vm_address_t inCallback,
io_user_reference_t inUserRefCon,
void*,
void*,
void* ) ;
IOReturn setAsyncStreamRef_SkippedPacket (
OSAsyncReference64 asyncRef,
UserObjectHandle inAsyncStreamListenerRef,
mach_vm_address_t inCallback,
io_user_reference_t inUserRefCon,
void*,
void*,
void*) ;
IOReturn setAsyncRef_Packet(
OSAsyncReference64 asyncRef,
UserObjectHandle addrSpace,
mach_vm_address_t inCallback,
io_user_reference_t inUserRefCon,
void*,
void*,
void* ) ;
IOReturn setAsyncRef_SkippedPacket(
OSAsyncReference64 asyncRef,
UserObjectHandle inAddrSpaceRef,
mach_vm_address_t inCallback,
io_user_reference_t inUserRefCon,
void*,
void*,
void*) ;
IOReturn setAsyncRef_Read(
OSAsyncReference64 asyncRef,
UserObjectHandle inAddrSpaceRef,
mach_vm_address_t inCallback,
io_user_reference_t inUserRefCon,
void*,
void*,
void*) ;
IOReturn setAsyncRef_BusReset(
OSAsyncReference64 asyncRef,
mach_vm_address_t inCallback,
io_user_reference_t inUserRefCon,
void*,
void*,
void*,
void*) ;
IOReturn setAsyncRef_BusResetDone(
OSAsyncReference64 asyncRef,
mach_vm_address_t inCallback,
io_user_reference_t inUserRefCon,
void*,
void*,
void*,
void*) ;
#pragma mark -
IOReturn physicalAddressSpace_Create (
mach_vm_size_t size,
mach_vm_address_t backingStore,
UInt32 flags,
UserObjectHandle * outKernAddrSpaceRef ) ;
IOReturn physicalAddressSpace_GetSegments (
UserObjectHandle addressSpaceHandle,
UInt32 inSegmentCount,
mach_vm_address_t outSegments,
UInt32* outSegmentCount) ;
#pragma mark -
IOReturn userAsyncCommand_Submit(
OSAsyncReference64 asyncRef,
CommandSubmitParams * inParams,
CommandSubmitResult * outResult,
IOByteCount inParamsSize,
IOByteCount* outResultSize) ;
static void userAsyncCommand_ReadWriteCompletion (
void * refcon,
IOReturn status,
IOFireWireNub * device,
IOFWCommand * fwCmd ) ;
#pragma mark -
IOReturn configDirectory_Create (
UserObjectHandle * outDirRef ) ;
IOReturn configDirectory_GetKeyType (
UserObjectHandle dirRef,
int key,
IOConfigKeyType * type ) const ;
IOReturn configDirectory_GetKeyValue_UInt32 (
UserObjectHandle dirHandle,
int key,
UInt32 wantText,
UInt32 * outValue,
UserObjectHandle * outStringHandle,
UInt32 * outStringLen ) const ;
IOReturn configDirectory_GetKeyValue_Data (
UserObjectHandle inDirRef,
int key,
UInt32 wantText,
GetKeyValueDataResults * results ) const ;
IOReturn configDirectory_GetKeyValue_ConfigDirectory (
UserObjectHandle dirRef,
int key,
UInt32 wantText,
UserObjectHandle * outValue,
UserObjectHandle * outString,
UInt32 * outStringLen ) const ;
IOReturn configDirectory_GetKeyOffset_FWAddress(
UserObjectHandle inDirRef,
int key,
UInt32 wantText,
GetKeyOffsetResults * results ) const ;
IOReturn configDirectory_GetIndexType(
UserObjectHandle inDirRef,
int index,
IOConfigKeyType * outType ) const ;
IOReturn configDirectory_GetIndexKey(
UserObjectHandle dirRef,
int index,
int * outKey ) const ;
IOReturn configDirectory_GetIndexValue_UInt32(
UserObjectHandle dirRef,
int index,
UInt32 * outKey) const ;
IOReturn configDirectory_GetIndexValue_Data(
UserObjectHandle dirRef,
int index,
UserObjectHandle * outDataRef,
IOByteCount * outDataLen ) const ;
IOReturn configDirectory_GetIndexValue_String(
UserObjectHandle dirRef,
int index,
UserObjectHandle * outString,
UInt32 * outStringLen ) const;
IOReturn configDirectory_GetIndexValue_ConfigDirectory(
UserObjectHandle dirRef,
int index,
UserObjectHandle * outDirRef ) const ;
IOReturn configDirectory_GetIndexOffset_FWAddress (
UserObjectHandle inDirRef,
int index,
FWAddress * address ) const ;
IOReturn configDirectory_GetIndexOffset_UInt32 (
UserObjectHandle inDirRef,
int index,
UInt32 * outValue ) const ;
IOReturn configDirectory_GetIndexEntry (
UserObjectHandle dirRef,
int index,
UInt32 * outValue ) const ;
IOReturn configDirectory_GetSubdirectories (
UserObjectHandle dirHandle,
UserObjectHandle * outIteratorHandle ) const ;
IOReturn configDirectory_GetKeySubdirectories (
UserObjectHandle dirHandle ,
int key,
UserObjectHandle* outIteratorHandle ) const ;
IOReturn configDirectory_GetType (
UserObjectHandle dirRef,
int * outType ) const ;
IOReturn configDirectory_GetNumEntries (
UserObjectHandle dirRef,
int * outNumEntries ) const ;
#pragma mark -
IOReturn localIsochPort_GetSupported (
UserObjectHandle inPortRef,
IOFWSpeed * outMaxSpeed,
UInt32 * outChanSupportedHi,
UInt32 * outChanSupportedLo ) const ;
IOReturn localIsochPort_Create (
LocalIsochPortAllocateParams * params,
UserObjectHandle * portRef ) ;
IOReturn localIsochPort_SetChannel (
UserObjectHandle portHandle,
UserObjectHandle channelHandle ) ;
IOReturn setAsyncRef_DCLCallProc (
OSAsyncReference64 asyncRef,
UserObjectHandle portRef ) ;
#pragma mark -
IOReturn isochChannel_Create (
bool inDoIRM,
UInt32 inPacketSize,
IOFWSpeed inPrefSpeed,
UserObjectHandle* outIsochChannelRef) ;
IOReturn isochChannel_AllocateChannelBegin(
UserObjectHandle channelRef,
UInt32 speed,
UInt32 chansHi,
UInt32 chansLo,
UInt32 * outSpeed,
UInt32 * outChannel ) ;
IOReturn setAsyncRef_IsochChannelForceStop(
OSAsyncReference64 asyncRef,
UserObjectHandle channel ) ;
#pragma mark -
#pragma mark -
#if IOFIREWIREUSERCLIENTDEBUG > 0
inline IOFWUserDebugInfo * getStatistics() const { return fDebugInfo ; }
#endif
#pragma mark -
IOFWReadCommand* createReadCommand(
UInt32 generation,
FWAddress devAddress,
IOMemoryDescriptor* hostMem,
FWDeviceCallback completion,
void * refcon ) const ;
IOFWReadQuadCommand* createReadQuadCommand(
UInt32 generation,
FWAddress devAddress,
UInt32 * quads,
int numQuads,
FWDeviceCallback completion,
void * refcon ) const ;
IOFWWriteCommand* createWriteCommand(
UInt32 generation,
FWAddress devAddress,
IOMemoryDescriptor* hostMem,
FWDeviceCallback completion,
void* refcon ) const ;
IOFWWriteQuadCommand* createWriteQuadCommand(
UInt32 generation,
FWAddress devAddress,
UInt32* quads,
int numQuads,
FWDeviceCallback completion,
void * refcon ) const ;
IOFWCompareAndSwapCommand* createCompareAndSwapCommand(
UInt32 generation,
FWAddress devAddress,
const UInt32 * cmpVal,
const UInt32 * newVal,
int size,
FWDeviceCallback completion,
void * refcon ) const ;
#pragma mark -
IOReturn firelog( const char* string, IOByteCount bufSize ) const ;
IOReturn getBusGeneration( UInt32* outGeneration ) ;
IOReturn getLocalNodeIDWithGeneration( UInt32 generation, UInt32* outLocalNodeID ) ;
IOReturn getRemoteNodeID( UInt32 generation, UInt32* outRemoteNodeID ) ;
IOReturn getSpeedToNode( UInt32 generation, UInt32* outSpeed ) ;
IOReturn getSpeedBetweenNodes( UInt32 generation, UInt32 fromNode, UInt32 toNode, UInt32* outSpeed ) ;
#pragma mark -
IOReturn getIRMNodeID( UInt32 generation, UInt32* irmNodeID ) ;
#pragma mark -
IOReturn clipMaxRec2K( Boolean clipMaxRec ) ;
void s_userBufferFillPacketProc(
IOFWBufferFillIsochPort * port,
IOVirtualRange packets[],
unsigned packetCount ) ;
IOReturn getSessionRef( IOFireWireSessionRef * sessionRef ) ;
IOReturn asyncStreamListener_Create (
FWUserAsyncStreamListenerCreateParams* params,
UserObjectHandle* outAsyncStreamListenerHandle );
IOReturn asyncStreamListener_ClientCommandIsComplete (
UserObjectHandle asyncStreamListenerHandle,
FWClientCommandID inCommandID );
IOReturn asyncStreamListener_GetOverrunCounter (
UserObjectHandle asyncStreamListenerHandle,
UInt32 *overrunCounter );
IOReturn asyncStreamListener_SetFlags (
UserObjectHandle asyncStreamListenerHandle,
UInt32 flags );
IOReturn asyncStreamListener_GetFlags (
UserObjectHandle asyncStreamListenerHandle,
UInt32 *flags );
IOReturn asyncStreamListener_TurnOnNotification (
UserObjectHandle asyncStreamListenerHandle );
IOReturn asyncStreamListener_TurnOffNotification (
UserObjectHandle asyncStreamListenerHandle );
IOReturn allocateIRMBandwidthInGeneration(UInt32 bandwidthUnits, UInt32 generation) ;
IOReturn releaseIRMBandwidthInGeneration(UInt32 bandwidthUnits, UInt32 generation) ;
IOReturn allocateIRMChannelInGeneration(UInt8 isochChannel, UInt32 generation) ;
IOReturn releaseIRMChannelInGeneration(UInt8 isochChannel, UInt32 generation) ;
IOReturn irmAllocation_Create(Boolean releaseIRMResourcesOnFree, UserObjectHandle* outIRMAllocationHandle);
IOReturn irmAllocation_AllocateResources(UserObjectHandle irmAllocationHandle, UInt8 isochChannel, UInt32 bandwidthUnits);
IOReturn irmAllocation_DeallocateResources(UserObjectHandle irmAllocationHandle);
Boolean irmAllocation_areResourcesAllocated(UserObjectHandle irmAllocationHandle, UInt8 *pIsochChannel, UInt32 *pBandwidthUnits);
void irmAllocation_setDeallocateOnRelease(UserObjectHandle irmAllocationHandle, Boolean doDeallocationOnRelease);
IOReturn irmAllocation_setRef(OSAsyncReference64 asyncRef,
UserObjectHandle irmAllocationHandle,
io_user_reference_t inCallback,
io_user_reference_t inUserRefCon);
IOReturn createAsyncCommand( OSAsyncReference64 asyncRef,
CommandSubmitParams * params,
UserObjectHandle * kernel_ref );
IOReturn createVectorCommand( UserObjectHandle * kernel_ref );
public:
static void setAsyncReference64(OSAsyncReference64 asyncRef,
mach_port_t wakePort,
mach_vm_address_t callback, io_user_reference_t refcon)
{
IOUserClient::setAsyncReference64( asyncRef, wakePort, callback, refcon );
}
IOReturn createPHYPacketListener( UInt32 queue_count, UserObjectHandle * kernel_ref );
} ;