This appendix contains the following information:
A.1 Designing a SCSI Class Driver
A.1.2 Supporting SCSI-Specific Functionality
A.1.3 SCSI Class Driver's DriverEntry Routine
A.1.3.1 SCSI Class Driver's GetInquiryData Routine
A.1.3.2 SCSI Class Driver's ClaimDevice Routine
A.1.3.3 SCSI Class Driver's GetCapabilities Routine
A.1.3.4 Setting up Device Extensions
A.1.4 SCSI Class Driver's Dispatch Routines
A.1.4.1 Handling Requests to SCSI Peripherals
A.1.4.2 Handling SCSI Pass-Through Requests
A.1.4.3 Queueing SCSI Requests
A.1.4.4 SCSI Class Driver's BuildSrb Routine
A.1.4.5 SCSI Class Driver's SplitTransferRequest Routine
A.1.5 SCSI Class Driver's IoCompletion Routines
A.1.5.1 SCSI Class Driver's ReleaseQueue Routine
A.1.5.2 SCSI Class Driver's InterpretRequestSense Routine
A.1.5.3 SCSI Class Driver's RetryRequest Routine
A.2 Designing a SCSI Filter Driver
A.2.2 Supporting SCSI-Specific Functionality
A.2.3 SCSI Filter Driver's DriverEntry Routine
A.2.4 SCSI Filter Driver's Dispatch Routines
A.2.5 SCSI Filter Driver's IoCompletion Routines
A.3 Designing a SCSI Tape Miniclass Driver
A.3.1 Using the Tape Class Driver
A.3.2 Supplying Required and Optional Miniclass Routines
A.3.3 Storing Miniclass Context in Optional Extensions
A.3.4 Processing Tape Device Control Requests
A.4 Designing a SCSI Miniport Driver
A.4.1 Required and Optional SCSI Miniport Routines
A.4.2 SCSI Miniport Driver's DriverEntry Routine
A.4.2.1 Calling ScsiPortInitialize
A.4.2.2 Return from DriverEntry
A.4.3 SCSI Miniport Driver's HwScsiFindAdapter Routine
A.4.3.1 Calling ScsiPortXxx from HwScsiFindAdapter
A.4.3.2 Port-Driver-Supplied ConfigInfo for HwScsiFindAdapter
A.4.3.3 Setting up ConfigInfo in HwScsiFindAdapter
A.4.3.4 Setting Again and Returning from HwScsiFindAdapter
A.4.3.5 Return from HwScsiFindAdapter to ScsiPortInitialize
A.4.4 SCSI Miniport Driver's HwScsiInitialize Routine
A.4.5 SCSI Miniport Driver's HwScsiStartIo Routine
A.4.5.2 Handling SRB_FUNCTION_EXECUTE_SCSI
A.4.5.3 Handling SRB_FUNCTION_ABORT_COMMAND
A.4.5.4 Handling SRB_FUNCTION_RESET_BUS
A.4.5.5 Handling SRB_FUNCTION_FLUSH and SRB_FUNCTION_SHUTDOWN
A.4.5.6 Handling SRB_FUNCTION_IO_CONTROL
A.4.5.7 Handling Unsupported SRB_FUNCTION_XXX
A.4.5.8 Return from HwScsiStartIo
A.4.5.9 Other SRB_FUNCTION_XXX Requests
A.4.6 SCSI Miniport Driver's HwScsiDmaStarted Routine
A.4.7 SCSI Miniport Driver's HwScsiResetBus Routine
A.4.8 SCSI Miniport Driver's HwScsiInterrupt Routine
A.4.8.1 Deferring Interrupt-Driven I/O from HwScsiInterrupt
A.4.8.2 SCSI Miniport Driver's HwScsiEnableInterruptsCallback Routine
A.4.8.3 SCSI Miniport Driver's HwScsiDisableInterruptsCallback Routine
A.4.9 SCSI Miniport Driver's HwScsiTimer Routine
A.4.10 SCSI Miniport Driver's HwScsiAdapterState Routine
A.4.11 Error Handling in SCSI Miniport Drivers
This appendix contains guidelines for designing the following kinds of Windows NT® kernel-mode SCSI drivers:
·A class driver for a new type of peripheral device
·A filter driver for a peripheral device of a type that already has a class driver
·An OS-independent tape miniclass driver for a vendor-specific tape device
·An OS-independent miniport driver for a vendor-specific HBA
·A miniport driver for a nonSCSI mass-storage adapter
I/O Request Handling in Layered SCSI Drivers
Windows NT class and filter drivers for SCSI peripheral devices act as an interface between any intermediate or highest-level drivers layered above the class or filter driver and the system-supplied SCSI port driver. That is, SCSI class drivers translate the standard IRPs they get into IRPs with system-defined SCSI request blocks (SRBs) before sending each IRP on to the system port driver. Each SRB contains a SCSI-II command descriptor block (CDB), as well as members that identify the target device for the requested operation.
In turn, the system-supplied, SCSI port driver passes SRBs with CDBs on to OS-independent, HBA-specific miniport drivers. The port driver acts as an interface between all SCSI class drivers and all HBA-specific miniport drivers.
In addition, the Windows NT SCSI port driver can act as an interface between a SCSI mass-storage class driver and a miniport that controls a nonSCSI mass-storage device of the same type. For example, rather than writing a standard NT driver for a new disk-array controller, a driver writer can save considerable design, development, and debugging effort by writing a pseudoSCSI miniport driver that links itself to the system SCSI port driver and uses the interface it provides. This technique requires such a miniport to translate incoming SCSI commands into device-specific commands and to support higher-level NT drivers as if it were a SCSI HBA miniport. On the other hand, the system-supplied port and class drivers would handle much necessary work on such a pseudoSCSI miniport's behalf, including registry accesses during initialization, all resource and object allocations, synchronization, presizing requested transfers to suit the capabilities of the miniport's device, and retrying requests.
For more detailed information about SRBs, see the Kernel-Mode Driver Reference. For device-type-specific information about CDBs, consult the ANSI X3.131-199X SCSI-II standard.
System Header Files
The system-supplied SCSI drivers include the header file scsi.h, which contains SCSI-II-compliant definitions for CDBs and other structures used by most SCSI-II-compliant drivers. This header file includes srb.h, which defines the interfaces provided by the system SCSI port driver.
System-supplied class and filter drivers also can include the header file class.h so they can call the ScsiClassXxx routines provided by class.c. The Windows NT DDK provides class.h and class.c as sample source code. However, class.c should not be considered a system-supplied library for all future SCSI class drivers; both class.h and class.c are subject to change without notice.
OS-independent SCSI miniport drivers, which can be designed to run both with Microsoft® Windows NT and with future x86-only Microsoft Windows® systems, include the system-supplied header files miniport.h and scsi.h, which includes srb.h.