IOFWUserPseudoAddressSpace.h [plain text]
#ifndef __IOFWUserClientPsduAddrSpace_H__
#define __IOFWUserClientPsduAddrSpace_H__
#import <IOKit/firewire/IOFireWireFamilyCommon.h>
#import <IOKit/firewire/IOFWAddressSpace.h>
#import "IOFireWireLibPriv.h"
using namespace IOFireWireLib ;
typedef union IOFWPacketHeader_t
{
typedef enum
{
kFree = 0,
kStopPacket = 'stop',
kBadPacket = ' bad',
kIncomingPacket = 'pckt',
kSkippedPacket = 'skip',
kReadPacket = 'read',
kLockPacket = 'lock'
} QueueTag ;
struct
{
QueueTag type ;
IOFWPacketHeader_t* next ;
OSAsyncReference* whichAsyncRef ;
UInt32 argCount ;
UInt32 args[9] ;
} CommonHeader ;
struct
{
QueueTag type ;
IOFWPacketHeader_t* next ;
OSAsyncReference* whichAsyncRef ;
UInt32 argCount ;
UInt32 commandID ; UInt32 packetSize ; UInt32 packetOffset ; UInt32 nodeID ;
UInt32 speed ;
UInt32 addrHi ;
UInt32 addrLo ;
UInt32 isLock ;
UInt32 generation ;
IOFWRequestRefCon reqrefcon ;
} IncomingPacket ;
struct SkippedPacket_t
{
QueueTag type ;
IOFWPacketHeader_t* next ;
OSAsyncReference* whichAsyncRef ;
UInt32 argCount ;
UInt32 commandID ; UInt32 skippedPacketCount ;
} SkippedPacket ;
struct ReadPacket_t
{
QueueTag type ;
IOFWPacketHeader_t* next ;
OSAsyncReference* whichAsyncRef ;
UInt32 argCount ;
UInt32 commandID ; UInt32 packetSize ; UInt32 packetOffset ; UInt32 nodeID ;
UInt32 speed ;
UInt32 addrHi ;
UInt32 addrLo ;
IOFWRequestRefCon reqrefcon ;
UInt32 generation ;
} ReadPacket ;
public:
IOFWPacketHeader_t() ;
} IOFWPacketHeader ;
inline IOByteCount& IOFWPacketHeaderGetSize(IOFWPacketHeader_t* hdr) ;
inline IOByteCount& IOFWPacketHeaderGetOffset(IOFWPacketHeader_t* hdr) ;
inline void InitIncomingPacketHeader(
IOFWPacketHeader_t* header,
IOFWPacketHeader_t* next,
const IOByteCount len,
const IOByteCount offset,
OSAsyncReference* ref,
UInt16 nodeID,
const IOFWSpeed& speed,
const FWAddress& addr,
const bool isLock = false) ; inline void InitSkippedPacketHeader(
IOFWPacketHeader* header,
const union IOFWPacketHeader_t* next,
const IOByteCount offset,
OSAsyncReference* ref) ;
inline void InitReadPacketHeader(
IOFWPacketHeader* header,
IOFWPacketHeader* next,
UInt32 len,
UInt32 offset,
OSAsyncReference* ref,
void* refCon,
UInt16 nodeID,
IOFWSpeed& speed,
FWAddress addr,
IOFWRequestRefCon reqrefcon) ;
inline void InitLockPacketHeader(
IOFWPacketHeader* header,
IOFWPacketHeader* next,
IOByteCount len,
IOByteCount offset,
OSAsyncReference* ref,
UInt16 nodeID,
IOFWSpeed& speed,
FWAddress addr,
const UInt32 generation,
IOFWRequestRefCon reqrefcon) ;
inline Boolean IsSkippedPacketHeader(const union IOFWPacketHeader_t* header) ;
inline Boolean IsFreePacketHeader(const union IOFWPacketHeader_t* header) ;
class IOFireWireUserClient ;
class IOFWUserPseudoAddressSpace: public IOFWPseudoAddressSpace
{
OSDeclareDefaultStructors(IOFWUserPseudoAddressSpace)
public:
#if IOFIREWIREUSERCLIENTDEBUG > 0
virtual bool serialize(OSSerialize *s) const;
#endif
virtual void free() ;
void exporterCleanup ();
virtual IOReturn activate() ;
virtual void deactivate() ;
bool completeInit( IOFireWireUserClient* userclient, AddressSpaceCreateParams* params ) ;
bool initPseudo( IOFireWireUserClient* userclient, AddressSpaceCreateParams* params ) ;
bool initFixed( IOFireWireUserClient* userclient, AddressSpaceCreateParams* params ) ;
virtual UInt32 doLock(
UInt16 nodeID,
IOFWSpeed & speed,
FWAddress addr,
UInt32 inLen,
const UInt32 * newVal,
UInt32 & outLen,
UInt32 * oldVal,
UInt32 type,
IOFWRequestRefCon refcon) ;
UInt32 doPacket(
UInt16 nodeID,
IOFWSpeed& speed,
FWAddress addr,
UInt32 len,
const void* buf,
IOFWRequestRefCon reqrefcon,
IOFWPacketHeader::QueueTag tag,
UInt32* oldVal = NULL) ;
const FWAddress& getBase() { return fAddress ; }
const UInt32 getUserRefCon() { return fUserRefCon ;}
const IOFireWireUserClient& getUserClient() { return *fUserClient ;}
static UInt32 pseudoAddrSpaceReader(
void* refCon,
UInt16 nodeID,
IOFWSpeed& speed,
FWAddress addr,
UInt32 len,
IOMemoryDescriptor** buf,
IOByteCount* offset,
IOFWRequestRefCon reqrefcon) ;
static UInt32 pseudoAddrSpaceWriter(
void* refCon,
UInt16 nodeID,
IOFWSpeed& speed,
FWAddress addr,
UInt32 len,
const void* buf,
IOFWRequestRefCon reqrefcon) ;
void setAsyncRef_Packet(
OSAsyncReference inAsyncRef) ;
void setAsyncRef_SkippedPacket(
OSAsyncReference inAsyncRef) ;
void setAsyncRef_Read(
OSAsyncReference inAsyncRef) ;
void clientCommandIsComplete(
FWClientCommandID inCommandID,
IOReturn inResult ) ;
void sendPacketNotification(
IOFWPacketHeader* inPacketHeader) ;
private:
IOMemoryDescriptor* fPacketQueueBuffer ; IOLock* fLock ;
UInt32 fUserRefCon ;
IOFireWireUserClient* fUserClient ;
IOFWPacketHeader* fLastWrittenHeader ;
IOFWPacketHeader* fLastReadHeader ;
UInt32 fBufferAvailable ; FWAddress fAddress ;
OSAsyncReference fSkippedPacketAsyncNotificationRef ;
OSAsyncReference fPacketAsyncNotificationRef ;
OSAsyncReference fReadAsyncNotificationRef ;
bool fWaitingForUserCompletion ;
bool fUserLocks ;
UInt32 fFlags ;
Boolean fPacketQueuePrepared ;
Boolean fBackingStorePrepared ;
} ;
#endif //__IOFWUserClientPsduAddrSpace_H__