IOUSBInterfaceUserClient.h [plain text]
#include <IOKit/IOUserClient.h>
#include <IOKit/usb/IOUSBUserClient.h>
#include <IOKit/IOCommandPool.h>
enum
{
kSizeToIncrementLowLatencyCommandPool = 10
};
struct AsyncPB {
OSAsyncReference fAsyncRef;
UInt32 fMax;
IOMemoryDescriptor *fMem;
IOUSBDevRequestDesc req;
};
struct IsoAsyncPB {
OSAsyncReference fAsyncRef;
int frameLen; void * frameBase; IOMemoryDescriptor *dataMem;
IOMemoryDescriptor *countMem;
IOUSBIsocFrame frames[0];
};
typedef struct LowLatencyUserClientBufferInfo LowLatencyUserClientBufferInfo;
struct LowLatencyUserClientBufferInfo
{
UInt32 cookie;
UInt32 bufferType;
void * bufferAddress;
UInt32 bufferSize;
IOMemoryDescriptor * bufferDescriptor;
IOMemoryDescriptor * frameListDescriptor;
IOMemoryMap * frameListMap;
IOVirtualAddress frameListKernelAddress;
LowLatencyUserClientBufferInfo * nextBuffer;
};
class IOUSBLowLatencyCommand : public IOCommand
{
OSDeclareAbstractStructors(IOUSBLowLatencyCommand)
private:
OSAsyncReference fAsyncRef;
IOByteCount fFrameLength; void * fFrameBase; IOMemoryDescriptor * fDataBufferDescriptor;
public:
static IOUSBLowLatencyCommand * NewCommand(void);
void SetAsyncReference(OSAsyncReference ref);
void SetFrameLength(IOByteCount frameLength) { fFrameLength = frameLength; }
void SetFrameBase(void * frameBase) { fFrameBase = frameBase; }
void SetDataBuffer(IOMemoryDescriptor * dataMem) {fDataBufferDescriptor = dataMem; }
void GetAsyncReference(OSAsyncReference *ref) { *ref = fAsyncRef; }
IOByteCount GetFrameLength(void) { return fFrameLength; }
void * GetFrameBase(void){ return fFrameBase; }
IOMemoryDescriptor * GetDataBuffer(void){ return fDataBufferDescriptor; }
};
class IOUSBInterfaceUserClient : public IOUserClient
{
OSDeclareDefaultStructors(IOUSBInterfaceUserClient)
private:
IOUSBInterface * fOwner;
task_t fTask;
const IOExternalMethod *fMethods;
const IOExternalAsyncMethod *fAsyncMethods;
IOCommandGate *fGate;
UInt32 fNumMethods;
UInt32 fNumAsyncMethods;
UInt32 fOutstandingIO;
mach_port_t fWakePort;
bool fDead;
bool fNeedToClose;
IOCommandPool * fFreeUSBLowLatencyCommandPool;
UInt32 fCurrentSizeOfCommandPool;
IOWorkLoop * fWorkLoop;
LowLatencyUserClientBufferInfo * fUserClientBufferInfoListHead;
static const IOExternalMethod sMethods[kNumUSBInterfaceMethods];
static const IOExternalAsyncMethod sAsyncMethods[kNumUSBInterfaceAsyncMethods];
virtual void SetExternalMethodVectors(void);
void IncreaseCommandPool();
virtual void stop(IOService * provider);
virtual bool start( IOService * provider );
virtual bool finalize(IOOptionBits options);
virtual void free();
virtual bool willTerminate( IOService * provider, IOOptionBits options );
virtual bool didTerminate( IOService * provider, IOOptionBits options, bool * defer );
virtual IOReturn open(bool seize);
virtual IOReturn close(void);
virtual bool initWithTask(task_t owningTask, void *security_id, UInt32 type);
virtual IOExternalMethod* getTargetAndMethodForIndex(IOService **target, UInt32 index);
virtual IOExternalAsyncMethod* getAsyncTargetAndMethodForIndex(IOService **target, UInt32 index);
virtual IOReturn clientClose( void );
virtual IOReturn clientDied( void );
virtual IOUSBPipe* GetPipeObj(UInt8 pipeNo);
virtual IOReturn DoIsochPipeAsync(OSAsyncReference asyncRef, IOUSBIsocStruct *stuff, IODirection direction);
virtual IOReturn DoLowLatencyIsochPipeAsync(OSAsyncReference asyncRef, IOUSBLowLatencyIsocStruct *stuff, IODirection direction);
virtual IOReturn GetDevice(io_service_t *device);
virtual IOReturn SetAlternateInterface(UInt8 altInterface);
virtual IOReturn GetFrameNumber(IOUSBGetFrameStruct *data, UInt32 *size);
virtual IOReturn GetMicroFrameNumber(IOUSBGetFrameStruct *data, UInt32 *size);
virtual IOReturn GetBandwidthAvailable(UInt32 *bandwidth);
virtual IOReturn GetFrameListTime(UInt32 *microsecondsInFrame);
virtual IOReturn GetEndpointProperties(UInt8 alternateSetting, UInt8 endpointNumber, UInt8 direction, UInt32 *transferType, UInt32 *maxPacketSize, UInt32 *interval);
virtual IOReturn GetPipeProperties(UInt8 pipeRef, UInt32 *direction, UInt32 *number, UInt32 *transferType, UInt32 *maxPacketSize, UInt32 *interval);
virtual IOReturn ReadPipe(UInt8 pipeRef, UInt32 noDataTimeout, UInt32 completionTimeout, void *buf, UInt32 *size);
virtual IOReturn ReadPipeOOL(IOUSBBulkPipeReq *reqIn, UInt32 *sizeOut, IOByteCount inCount, IOByteCount *outCount);
virtual IOReturn WritePipe(UInt8 pipeRef, UInt32 noDataTimeout, UInt32 completionTimeout, void *buf, UInt32 size);
virtual IOReturn WritePipeOOL(IOUSBBulkPipeReq *req, IOByteCount inCount);
virtual IOReturn GetPipeStatus(UInt8 pipeRef);
virtual IOReturn AbortPipe(UInt8 pipeRef);
virtual IOReturn ResetPipe(UInt8 pipeRef);
virtual IOReturn SetPipeIdle(UInt8 pipeRef);
virtual IOReturn SetPipeActive(UInt8 pipeRef);
virtual IOReturn ClearPipeStall(UInt8 pipeRef, bool bothEnds);
virtual IOReturn SetPipePolicy(UInt8 pipeRef, UInt16 maxPacketSize, UInt8 maxInterval);
virtual IOReturn ControlRequestIn(UInt32 param1, UInt32 param2, UInt32 noDataTimeout, UInt32 completionTimeout, void *buf, UInt32 *size);
virtual IOReturn ControlRequestOut(UInt32 param1, UInt32 param2, UInt32 noDataTimeout, UInt32 completionTimeout, void *buf, UInt32 size);
virtual IOReturn ControlRequestInOOL(IOUSBDevReqOOLTO *req, UInt32 *sizeOut, IOByteCount inCount, IOByteCount *outCount);
virtual IOReturn ControlRequestOutOOL(IOUSBDevReqOOLTO *req, IOByteCount inCount);
virtual IOReturn SetAsyncPort(OSAsyncReference asyncRef);
virtual IOReturn ControlAsyncRequestOut(OSAsyncReference asyncRef, IOUSBDevReqOOLTO *reqIn, IOByteCount inCount);
virtual IOReturn ControlAsyncRequestIn(OSAsyncReference asyncRef, IOUSBDevReqOOLTO *reqIn, IOByteCount inCount);
virtual IOReturn AsyncReadPipe(OSAsyncReference asyncRef, UInt32 pipe, void *buf, UInt32 size, UInt32 noDataTimeout, UInt32 completionTimeout);
virtual IOReturn AsyncWritePipe(OSAsyncReference asyncRef, UInt32 pipe, void *buf, UInt32 size, UInt32 noDataTimeout, UInt32 completionTimeout);
virtual IOReturn ReadIsochPipe(OSAsyncReference asyncRef, IOUSBIsocStruct *stuff, UInt32 sizeIn);
virtual IOReturn WriteIsochPipe(OSAsyncReference asyncRef, IOUSBIsocStruct *stuff, UInt32 sizeIn);
virtual IOReturn LowLatencyReadIsochPipe(OSAsyncReference asyncRef, IOUSBLowLatencyIsocStruct *stuff, UInt32 sizeIn);
virtual IOReturn LowLatencyWriteIsochPipe(OSAsyncReference asyncRef, IOUSBLowLatencyIsocStruct *stuff, UInt32 sizeIn);
void DecrementOutstandingIO(void);
void IncrementOutstandingIO(void);
UInt32 GetOutstandingIO(void);
virtual IOReturn LowLatencyPrepareBuffer(LowLatencyUserBufferInfo *dataBuffer);
virtual IOReturn LowLatencyReleaseBuffer(LowLatencyUserBufferInfo *dataBuffer);
virtual void AddDataBufferToList( LowLatencyUserClientBufferInfo * insertBuffer );
virtual LowLatencyUserClientBufferInfo * FindBufferCookieInList( UInt32 cookie);
virtual bool RemoveDataBufferFromList( LowLatencyUserClientBufferInfo *removeBuffer);
virtual void ReleasePreparedDescriptors();
static void ReqComplete(void *obj, void *param, IOReturn status, UInt32 remaining);
static void IsoReqComplete(void *obj, void *param, IOReturn res, IOUSBIsocFrame *pFrames);
static void LowLatencyIsoReqComplete(void *obj, void *param, IOReturn res, IOUSBLowLatencyIsocFrame *pFrames);
static IOReturn ChangeOutstandingIO(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3);
static IOReturn GetGatedOutstandingIO(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3);
};