Linux Step By Steps

Linux Step By Steps

Module Topology: The SCSI Interface

The IOMEGA Zip parallel interface is a scsi device trying to get out. This is quite common for parallel devices other than printers.

Therefore, the kernel scsi modules, specifically sd.o (the scsi disk module) is employed.

Programming Interface.

The large quantity of scsi type devices 'out there' share common characteristics in their initialisation phase. Linux provides a Scsi_Host_Template that the programmer fills in with all necessary detail. The programmer then simply applies the following to his code.

#include "/usr/src/linux/drivers/scsi/sd.h"
#include "/usr/src/linux/drivers/scsi/hosts.h"

#ifdef MODULE
Scsi_Host_Template driver_template = ZIP;
#include "/usr/src/linux/drivers/scsi/scsi_module.c"
#endif

This relieves the programmer of all the details necessary to merge the driver into the kernel. Specifically, the very standard

init_module() in the included file activates further functions from the template. Thus

#define ZIP { 

name:      "Iomega VPI0/VPI2", \
detect:  zip_detect, \ initialise
release:  zip_release, \ kill
queuecommand:  zip_queuecommand, \ normal ops
command:  zip_command, \ obsolete
eh_abort_handler:  zip_abort, \
eh_bus_reset_handler:  zip_reset, \
eh_host_reset_handler:  zip_reset, \
eh_device_reset_handler:  NULL, \
bios_param:  zip_biosparam, \
proc_dir: &proc_scsi_zip, \
proc_info:  zip_proc_info, \
this_id:  -1, \
sg_tablesize:  SG_ALL, \
cmd_per_lun:  1, \
use_clustering:  ENABLE_CLUSTERING 
}

Although the Scsi_Host_Template is large, and contains included structures, it is only necessary to preset those values that must be preset. It is not necessary to have knowledge of the template itself.

The primary interest here is the two functions scsi_detect, and scsi_quecommand. detect(), IS the intialisation function for the zip module and quecommand() is the standard method for the scsi layers to communicate with the zip drive(s).