IOFWUserPHYPacketListener.h [plain text]
#ifndef _IOKIT_IOFWUSERPHYPACKETLISENER_H_
#define _IOKIT_IOFWUSERPHYPACKETLISENER_H_
#import "IOFireWireUserClient.h"
#import <IOKit/firewire/IOFWPHYPacketListener.h>
#pragma mark -
class IOFWUserPHYPacketListener : public IOFWPHYPacketListener
{
OSDeclareDefaultStructors( IOFWUserPHYPacketListener );
protected:
enum ElementState
{
kFreeState = 0,
kPendingState = 1
};
enum ElementType
{
kTypeNone = 0,
kTypeData = 1,
kTypeSkipped = 2
};
class PHYRxElement
{
public:
PHYRxElement * next;
PHYRxElement * prev;
ElementState state;
ElementType type;
UInt32 data1;
UInt32 data2;
inline UInt32 getSkippedCount( void )
{
return data1;
}
inline void setSkippedCount( UInt32 count )
{
data1 = count;
}
};
protected:
IOFireWireUserClient * fUserClient;
UInt32 fMaxQueueCount;
UInt32 fAllocatedQueueCount;
OSAsyncReference64 fCallbackAsyncRef;
OSAsyncReference64 fSkippedAsyncRef;
PHYRxElement * fElementWaitingCompletion;
PHYRxElement * fFreeListHead; PHYRxElement * fFreeListTail;
PHYRxElement * fPendingListHead; PHYRxElement * fPendingListTail;
IOLock * fLock;
public:
static IOFWUserPHYPacketListener * withUserClient( IOFireWireUserClient * inUserClient, UInt32 queue_count );
virtual bool initWithUserClient( IOFireWireUserClient * inUserClient, UInt32 queue_count );
virtual void free( void );
static void exporterCleanup( const OSObject * self );
IOReturn setPacketCallback( OSAsyncReference64 async_ref,
mach_vm_address_t callback,
io_user_reference_t refCon );
IOReturn setSkippedCallback( OSAsyncReference64 async_ref,
mach_vm_address_t callback,
io_user_reference_t refCon );
void clientCommandIsComplete( FWClientCommandID commandID );
protected:
virtual void processPHYPacket( UInt32 data1, UInt32 data2 );
void sendPacketNotification( IOFWUserPHYPacketListener::PHYRxElement * element );
IOReturn createAllCommandElements( void );
void destroyAllElements( void );
PHYRxElement * allocateElement( void );
PHYRxElement * allocateDataElement( void );
void deallocateElement( PHYRxElement * element );
void addElementToPendingList( PHYRxElement * element );
void removeElementFromPendingList( PHYRxElement * element );
};
#endif