Muokkaa

Jaa


DispatchRead, DispatchWrite, and DispatchReadWrite Routines

A driver's DispatchRead and DispatchWrite routines handle IRPs with I/O function codes of IRP_MJ_READ and IRP_MJ_WRITE, respectively. Alternatively, a combined DispatchReadWrite routine can handle IRPs for both of these I/O function codes.

Every driver of a device from which data can be transferred to the system must have a DispatchRead routine. Every driver of a device to which data can be transferred from the system must have a DispatchWrite routine. Any driver that transfers data in both directions can have a combined DispatchReadWrite routine.

Lower-level drivers handle IRP_MJ_READ and IRP_MJ_WRITE requests asynchronously. Therefore, DispatchRead and/or DispatchWrite routines in highest-level drivers must pass these requests on for further processing, provided that the request has valid parameters in that driver's I/O stack location of the IRP.

Whether a driver sets up its device objects for buffered or direct I/O affects how it handles transfer requests. In particular, a driver that uses direct I/O to do DMA operations might need to split up large transfer requests into a sequence of smaller transfer operations in order to satisfy an IRP_MJ_READ or IRP_MJ_WRITE request. For more information, see Input/Output Techniques.

The following subsections discuss some of the design and implementation considerations for DispatchReadWrite routines in lowest-level device drivers that use buffered I/O and direct I/O, as well as in higher-level drivers layered above them:

Handling Transfers Asynchronously

DispatchReadWrite Using Buffered I/O

DispatchReadWrite Using Direct I/O

DispatchReadWrite in Higher-Level Drivers

Summary of Read/Write Dispatch Routines