SCSI debugging tool

SCSI debugging tool

The Sdebug tool is provided as part of the O5hbacert package available from the HDK homepage. Sdebug is a script that can be used to debug the commands sent between a SCSI peripheral device and the SCSI host adapter. ``Host adapter communication with peripheral driver'' explains how SCSI peripheral drivers communicate with SCSI host adapter drivers. The Sdebug tool traces this communication and can help debug SCSI drivers.

SCSI peripheral drivers normally call the appropriate SCSI host adapter's xx_entry( ) routine. Sdebug works by intercepting messages to a particular SCSI peripheral. Sdebug is written to intercept messages to the first SCSI tape drive listed in the mscsi(F) file, but could easily be modified to work for multiple SCSI peripherals.

The tool takes advantage of the fact that the link kit for all systems includes a minimal C compiler. Files such as /etc/conf/pack.d/first/space.c. are automatically compiled when you link a kernel. The firstinit( ) routine in first/space.c file is the first function called through the io_init[] switch at startup. It can therefore be used to apply any patches to the system before other drivers are initialized. It goes on to call the first_init( ) routine in Driver.o.

For Sdebug, firstinit( ) has been modified so that it alters the Stpcfg[] array to call a new function, Sdebug_entry( ), instead of eiad_entry( ). Sdebug_entry( ), in turn, prints out the desired debugging information and then calls the xx_entry( ) routine of the adapter that was originally listed in Stpcfg[].

Sdebug intercepts the communication that occurs between a SCSI peripheral driver and a SCSI host adapter driver by altering the SCSI peripheral's scsi_dev_cfg(F_SCSI) table. Recall that each device in the mscsi file is built into a corresponding xxcfg[] array. For example, if the mscsi file contains a SCSI tape at SCSI target id 2, Logical Unit Number 0, the kernel will contain a table called Stpcfg that describes that tape drive's configuration. If mscsi has multiple SCSI tapes, then Stpcfg[] has multiple entries.

One of the pieces of information contained in each entry of the xxcfg[] table is a function pointer to the xx_entry( ) routine of the adapter listed in mscsi. For example, our Stpcfg[] table would have said to use the routine eiad_entry( ) when communicating with the SCSI tape drive.

See the README file in the /usr/hbacert/Sdebug directory after the package is installed for instructions about running the Sdebug tool.

© 2005 The SCO Group, Inc. All rights reserved.