The Isousb driver
- The isousb driver is function driver, based on the
Windows Driver Model (WDM).
- Supports Plug and Play(PnP), Power
Management(PM), Windows Management Instrumentation (WMI) and the Selective
Suspend (SS) features.
- This sample is based off the selSusp sample
in the DDK. Please refer the selSusp sample and the DDK docs to understand the
handling of PnP, PM, WMI and SS features and implementations.
- The USB device used for this sample is a
generic Intel I82930 USB evaluation board programmed with a simple loopback
test using a 64KB circular buffer. None of the code in the sample is specific
to this controller chip
This section describes the driver routines that
allow a user-mode application to perform isoch reads and writes or stream
transfers. The isoch read/write is performed by opening a handle to the device
and using the standard Win32 Read/Write command. The stream transfer is a
continuous streaming of isoch IN data which can be explicitly initiated/stopped
using the driver-supported IOCTLs from the user application.
Isousb Reads/Writes and Stream Transfers
Requests |
Dispatch Routines |
IRP_MJ_CREATE |
IsoUsb_DispatchCreate() |
IRP_MJ_CLOSE |
IsoUsb_DispatchClose() |
IRP_MJ_READ |
IsoUsb_DispatchReadWrite() |
IRP_MJ_WRITE |
IsoUsb_DispatchReadWrite() |
IOCTL_ISOUSB_START_ISO_STREAM |
IsoUsb_StartIsoStream() |
IOCTL_ISOUSB_STOP_ISO_STREAM |
IsoUsb_StopIsoStream() |
Notes
- The IsoUsb_DispatchCreate() allows a user-mode app. to open handles to the
device or to the pipe.
- Pipe # 5 and Pipe # 6 correspond to the Isoch IN and Isoch OUT
respectively. The driver does not hard-code the pipe # for reads and writes.
- The IsoUsb_DispatchClose() closes the
handles to the pipe or the device
Stream Transfers
- The driver routines which implement this functionality are:
IsoUsb_StartIsoStream()
IsoUsb_StopIsoStream()
IsoUsb_InitializeStreamUrb()
IsoUsb_IsoIrp_Complete()
IsoUsb_ProcessTransfer()
IsoUsb_StreamObjectCleanup()
- The stream transfer can be initiated from a device control request.
- The stream transfer comprises of continuous streaming IN of data.
- The stream transfer circulates ISOUSB_MAX_IRP
number of requests at any time.
- The stream transfer stops on receiving an explicit device control
request or when the user-mode app. terminates or stops.
- The stream transfer context information is maintained in the ISOUSB_STREAM_OBJECT
structure. This structure is saved in the FileObject pointer.
- There are ISOUSB_MAX_IRP number of Irp/Urb pairs which are re-circulated
and used for transfers. The ISOUSB_TRANSFER_OBJECT structure maintains
context information for each of the Irp/Urb pair.
- In order to stop or abort the transfer, the
routine IsoUsb_StreamObjectCleanup
cancels the re-circulating Irps and waits on an event triggered by the
completion routine for the last cancelled Irp. Thereafter, it proceeds to
release memory allocation for the stream object and the transfer objects.
- Since the driver saves the stream object
structure in the FileObject, it is multi-threaded safe accross applications,
but with a major caveat. The user applications should not use the same handle
to initiate multiple stream transfers. This functionality can be easily
supported by forming a list of stream-object structures in the FileObject
(rather than storing a single stream object structure).
Isoch Reads/Writes
- The Isoch read/write transfer requires an Irp/Urb
pair with the function code of URB_FUNCTION_ISOCH_TRANSFER.
- There is an upper bound on the number of packets that can be transferred
with each of the Irp/Urb pair and is given as 255. This calls for creating
multiple subsidiary Irp/Urb pairs to transfer the requested length of data.
- The IsoUsb_DispatchReadWrite
creates the required number of subsidiary Irp/Urb pairs,
initializes them and sets a completion routine (IsoUsb_SinglePairComplete)
for each of the Irp in the pair
- The dispatch routine sets a cancellation
routine (IsoUsb_CancelReadWrite)
for the original read/write Irp and pends the Irp.
- The dispatch routine now passes the
subsidiary Irp/Urb pair down the stack.
- It is possible to abort the read/write transfers at any point. It is the
responsibility of the driver to cancel/free the Irp/Urb pairs, release all
resources and terminate gracefully.
- The IsoUsb_DispatchReadWrite,
IsoUsb_SinglePairComplete
and
IsoUsb_CancelReadWrite
routines are well annotated with comments to aid understanding.
- Since the driver does not save the read-write
context information in the driver, but passes it to the completion routine, it
is multithreaded safe.
High Speed Isoch Reads/Writes
- The DDK sample has been updated for high
speed isoch transfers.
- There are two significant differences between
high speed and full speed transfers:
a. The upper bound on the number of packets that can be transferred with each
Irp/Urb pair is 1024.
b. The number of packets sent down with each Irp/Urb pair should be a multiple
of 8.
- The
PerformHighSpeedIsochTransfer gives one
implementation of creating multiple of 8 packets.
Known Bugs
- When the Intel I82930 evaluation board is
used to perform loopback transfers with OUT transfers not in multiple of 8,
the IN pipe is stalled. This can be attributed to the firmware error.
Resetting the pipe does not solve this problem. This requires reconfiguring
the device or driver unload/load.
RwIso.exe
RwIso.exe is a console application used to initiate isochronous transfer and
obtain a dump of information on the device's I/O endpoints. The application also
demonstrates how to use GUID-based device names and pipe names generated by the
operating system using the SetupDiXXX user-mode APIs.