IOUSBController



Member Functions

AcquireDeviceZero

public:

virtual IOReturn AcquireDeviceZero();

Get the device zero lock - call this before resetting a device, to ensure there's only one device with address 0


ConfigureDeviceZero

public:

IOReturn ConfigureDeviceZero(UInt8 maxPacketSize, UInt8 speed);

create a pipe to the default pipe for the device at address 0

Parameters

NameDescription
maxPacketSizemax packet size for the pipe
speedDevice speed

GetBandwidthAvailable

public:

virtual UInt32 GetBandwidthAvailable() = 0;

Returns the available bandwidth (in bytes) per frame for isochronous transfers.

Result: maximum number of bytes that a new iso pipe could transfer per frame given current allocations.

GetDeviceZeroDescriptor

public:

IOReturn GetDeviceZeroDescriptor(IOUSBDeviceDescriptor *desc);

read the device descriptor of the device at address 0

Parameters

NameDescription
descpointer to descriptor

GetFrameNumber

public:

virtual UInt64 GetFrameNumber() = 0;

Returns the full current frame number.

Result: The frame number.

GetFrameNumber32

public:

virtual UInt32 GetFrameNumber32() = 0;

Returns the least significant 32 bits of the frame number.

Result: The lsb 32 bits of the frame number.

MakeDevice

public:

IOUSBDevice *MakeDevice(IOUSBDeviceDescriptor *desc, UInt8 speed, UInt32 power);

Create a new device object for the device currently at address 0. This routine calls SetDeviceZeroAddress() with a new, unique, address for the device and adds the device into the registry.

Parameters

NameDescription
descDevice descriptor of the device
speedDevice speed
powerBus power available to the device
Result: Pointer to the newly-created device, 0 if the object coudn't be created.

ReleaseDeviceZero

public:

virtual void ReleaseDeviceZero(void);

Release the device zero lock - call this to release the device zero lock, when there is no longer a device at address 0


SetDeviceZeroAddress

public:

IOReturn SetDeviceZeroAddress(USBDeviceAddress address, UInt8 maxPacketSize, UInt8 speed);

Set the device address of the device currently at address 0. When this routine returns, it's safe to release the device zero lock.

Parameters

NameDescription
addressNew address for the device
maxPacketSizemaximum packet size for the default pipe
speedspeed of the device

WaitForReleaseDeviceZero

public:

void WaitForReleaseDeviceZero();

Block until the device zero lock is released


abortPipe

public:

virtual IOReturn abortPipe(USBDeviceAddress address, Endpoint * endpoint);

Abort pending I/O to/from the specified endpoint, causing them to complete with return code kIOReturnAborted

Parameters

NameDescription
addressAddress of the device on the USB bus
endpointdescription of endpoint

clearPipeStall

public:

virtual IOReturn clearPipeStall(USBDeviceAddress address, Endpoint * endpoint);

Clear a pipe stall.

Parameters

NameDescription
addressAddress of the device on the USB bus
endpointdescription of endpoint

closePipe

public:

virtual IOReturn closePipe(USBDeviceAddress address, Endpoint * endpoint);

Close a pipe to the specified device endpoint

Parameters

NameDescription
addressAddress of the device on the USB bus
endpointdescription of endpoint

deviceRequest

public:

virtual IOReturn deviceRequest(IOUSBDevRequest * request, IOUSBCompletion * completion, USBDeviceAddress address, UInt8 epNum);

Make a control request to the specified endpoint There are two versions of this method, one uses a simple void * to point to the data portion of the transfer, the other uses an IOMemoryDescriptor to point to the data.

Parameters

NameDescription
requestparameter block for the control request
completiondescribes action to take when the request has been executed
addressAddress of the device on the USB bus
epNumendpoint number

isocIO

public:

virtual IOReturn isocIO(IOMemoryDescriptor * buffer, UInt64 frameStart, UInt32 numFrames, IOUSBIsocFrame *frameList, USBDeviceAddress address, Endpoint * endpoint, IOUSBIsocCompletion * completion);

Read from or write to an isochronous endpoint

Parameters

NameDescription
bufferplace to put the transferred data
frameStartUSB frame number of the frame to start transfer
numFramesNumber of frames to transfer
frameListBytes to transfer and result for each frame
addressAddress of the device on the USB bus
endpointdescription of endpoint
completiondescribes action to take when buffer has been filled

openPipe

public:

virtual IOReturn openPipe(USBDeviceAddress address, UInt8 speed, Endpoint *endpoint);

Open a pipe to the specified device endpoint

Parameters

NameDescription
addressAddress of the device on the USB bus
speedof the device: kUSBHighSpeed or kUSBLowSpeed
endpointdescription of endpoint to connect to

read

public:

virtual IOReturn read(IOMemoryDescriptor * buffer, USBDeviceAddress address, Endpoint * endpoint, IOUSBCompletion * completion);

Read from an interrupt or bulk endpoint

Parameters

NameDescription
bufferplace to put the transferred data
addressAddress of the device on the USB bus
endpointdescription of endpoint
completiondescribes action to take when buffer has been filled

resetPipe

public:

virtual IOReturn resetPipe(USBDeviceAddress address, Endpoint * endpoint);

Abort pending I/O and clear stalled state - this method is a combination of abortPipe and clearPipeStall

Parameters

NameDescription
addressAddress of the device on the USB bus
endpointdescription of endpoint

write

public:

virtual IOReturn write(IOMemoryDescriptor * buffer, USBDeviceAddress address, Endpoint * endpoint, IOUSBCompletion * completion);

Write to an interrupt or bulk endpoint

Parameters

NameDescription
bufferplace to get the transferred data
addressAddress of the device on the USB bus
endpointdescription of endpoint
completiondescribes action to take when buffer has been emptied

Member Data

Endpoint

public:
  struct  Endpoint  {
  IOUSBEndpointDescriptor  *descriptor;
  UInt8  number;
  UInt8  direction;  //  in,  out
  UInt8  transferType;  //  cntrl,  bulk,  isoc,  int
  UInt16  maxPacketSize;
  UInt8  interval;
  };

Describes an endpoint of a device. Simply an easier to use version of the endpoint descriptor.

Fields

NameDescription
descriptorThe raw endpoint descriptor.
numberEndpoint number
directionEndpoint direction: kUSBOut, kUSBIn, kUSBAnyDirn
transferTypeType of endpoint: kUSBControl, kUSBIsoc, kUSBBulk, kUSBInterrupt
maxPacketSizeMaximum packet size for endpoint
intervalPolling interval in milliseconds (only relevent for Interrupt endpoints)

© 2000 Apple Computer, Inc. — (Last Updated 2/23/2000)