*** Generic SCSI class driver sample ***
*** Written by Thomas Nielsen, DMC   ***
*** Release date: 06/04-1993         ***


This sample (hopefully) demonstrates how to write a custom SCSI class driver for
various SCSI devices running under Windows NT, october release.
I have tried to insert as many comments as possible without making the code too
un-readable.
The generic sample consists of the following files:

   SCANNER.C   (Generic SCSI Class driver - finds all SCSI scanner devices
                connected to the SCSI bus)
   SCANNER.RC  (Resource file for the SCSI Class driver)
   MAKEFILE    (Makefile for the Class driver - use the Build utility to build
                the Class driver).
   SOURCES     (Specifies the environment needed for the Build utility)

   \WIN32\DEV.C    (Win32 sample how to access the SCSI Class driver including
                    sample code how to send SCSI TestUnitReady and Inquiry commands).
   \WIN32\MAKEFILE (Makefile for the Win32 application)


The Class driver sample and the Win32 needs the October SDK plus the October DDK in
order to compile/link sucessfully. As soon as I receive the March DDK, there will be
a new revision of the sample..... (-:

The Class driver sample searches the installed SCSI adapters, and then searches the
SCSI bus for "unclaimed" devices (devices not already owned by another class driver -
such as the CD-ROM device, etc.). The class driver then enumerates each found device
as "Scanner0", "Scanner1", etc.
The Class driver creates a device object for each found scanner and in the end creates
a symbolic link in order to have Win32 to recognize the scanner devices (so you can
access the device via CreateFile("\\\\.\\Scanner0"...

I have included a sample in the SCANNER.C file that demonstrates how to send user-
defined ioctls to the class driver using the DeviceIoControl API. To test it, insert
the ioctl code (in the specific case: 100) instead of the the IOCTL_SCSI_PASS_THROUGH
in the DeviceIoControl call.
The class driver then builds an SCSI srb and passes it via the SendSrbSynchronous to
the appropriate function in the CLASS.C file. Please feel free to extend the class
driver with more ioctl codes....

Note: The maximum block transfer is limited by the SCSI adapter capabilities.
      The normal max. block size = 64K plus the pagesize = 4K = 68K
      It is the class drivers responsibility to break down larger requests into
      smaller blocks.

Installation of the class driver:

  1. Copy the class driver (scsiscan.sys) into the \WINNT\SYSTEM\DRIVERS directory
  2. Start the Regedit utility
  3. Go to \HKEY_LOCALMACHINE\SYSTEM\CurrentControlSet\Services
  4. Add new key "Scsiscan"
  5. Add the following values under the Scsiscan key:
     Type: REG_DWORD: 0x1         /* Device driver */
     Group: REG_SZ: SCSI Class    /* Member of the SCSI class driver group */
     ErrorControl: REG_DWORD: 0x1 /* The system will boot even if this driver */
                                  /* fails to load !!!                        */
     DependOnGroup: REG_MULTI_SZ: SCSI miniport  /* The driver will only be loaded */
                                                 /* if there is an installed SCSI  */
                                                 /* adapter - quite vital (-:      */
     Start: REG_DWORD: 0x2        /* Non-boot related driver - ie. is not vital */
                                  /* for the system in order to work properly   */


  8. Quit the Regedit utility
  7. Re-boot the system - the driver will the be loaded - otherwise you might need
     to activate the Kernel debugger (KD).

The Class driver and the Win32 sample have been sucessfylly tested on both I386
and R3000/R4000 machines with different SCSI controllers and SCSI devices.

Hope this can help you developing other SCSI class drivers. Don't hesitate to drop me
a message if you have any questions or problems...


Thomas Nielsen
CIS mail: 100065, 2167
Fax: +45 66 14 71 81
