Writing a Start I/O RoutineThe remainder of this chapter discusses the development of a programmed I/O driver for a parallel port. For simplicity, this driver ignores many of the details that would have to be considered if writing a commercial driver. Execution ContextThe I/O manager calls the driver's Start I/O routine (described in Table 8.4) either when a Dispatch routine calls IoStartPacket (if the device was idle), or when some other part of the driver calls IoStartNextPacket. In either case, Start I/O runs at DISPATCH_LEVEL IRQL, so it must not do anything that causes a page fault. What the Start I/O Routine DoesA driver's Start I/O routine is responsible for doing any function code-specific processing needed by the current IRP and then starting the actual device operation. In general terms, a Start I/O routine will do the following:
To guarantee proper synchronization, any of these steps that access data shared with the ISR should be performed inside the SynchCritSection routine rather than in Start I/O itself.
|