Title: The Programmer's Guide to SCSI
Author: Brian Sawert
Publisher: Addison-Wesley, 1998
Pages: 292, with CD-ROM
ISBN: 0-201-18538-5
Price: $39.95As is the case with most standards, the SCSI standard does not guarantee "seamless interoperability" among components. What it does give you is a fighting chance of getting devices to communicate. The early SCSI specification left much to the imagination of the designer. This may explain why Apple Computer's first version of SCSI used a cable layout incompatible with everyone else's. (Then again, maybe Apple was just being Apple.) The original SCSI spec was so poorly understood that a kind of folklore most of it wrong rose up around the subject of proper cable termination. Chaos reigned.
Things are much better today, thanks to tighter standards, and in large part to ASPI, the Advanced SCSI Programming Interface. ASPI is a layer of standard calls that covers a multitude of implementation dependencies. But the author of this book still calls SCSI programming mostly an art. He claims that one of the biggest problems for the SCSI programmer today is the lack of reliable documentation. In a chapter on "Troubleshooting Common Mistakes" he implies that one of those mistakes is putting too much faith in manufacturer documentation, likening its trustworthiness to that of a supermarket tabloid. So the ideal SCSI programmer would seem to be part hardware nut and part detective, willing to conduct experiments to determine how a particular SCSI system really works.
Even so, this book is not aimed at bit twiddlers. It is written for C and C++ programmers who are most comfortable handling device unpleasantries through an API, and who, presumably, don't wish to make SCSI programming their life's work. Sawert devotes a long chapter to ASPI, which is probably the simplest method of SCSI programming. This chapter is well written and provides lots of informative tables and sample code along the way. Unfortunately, ASPI is very much a PC API. ASPI never caught on in the Unix world.
Sawert does not neglect Unix, however. He provides tables for AIX, HPUX, SCO, Solaris, Digital Unix, and Linux, listing features of those operating systems that impinge upon SCSI development. Some of those features include locations of critical files, APIs, kernel characteristics, and sources of documentation. The tables won't tell you enough to write a Unix SCSI driver, but they might make a handy reference later on. The book then devotes many pages to the implementation of a couple of Linux SCSI drivers.
There are two interesting chapters for the hard-core SCSI programmer. One deals with programming Symbios Logic's SCRIPTS SCSI engine, a processor specialized to handle SCSI protocols. The other chapter deals with "target-mode" SCSI programming, a don't-try-this-at-home sort of activity that you should be able to avoid unless you're developing SCSI peripherals.
The last chapter of the book presents a sample application, a "SCSI Snooper," for Windows 95 and NT. The sample application is built atop an ASPI class library, also written by the author and covered in this chapter. This class library is heavily dependent on MFC, so the author apparently did not intend it as a cross-platform framework.
The CD-ROM includes source code for sample applications; the ASPI class library; scripts for the Symbios Logic processor; a version of the SCSI-1, SCSI-2, and SCSI-3 draft specifications; a SCSI FAQ; more documentation; pointers to websites basically, gobs of support. This book/CD is crammed with information, code, and straightforward advice.
SCSI programming isn't for everyone. The most likely reader of this book will be someone who has never been happy with indirect access to I/O, and who wants to circumvent the meddling of the operating system. If you are such a person, maybe you've already grabbed direct control of the parallel and serial ports. You will find the SCSI ports to be a bit trickier. This would be a good book to get you started and to keep your frustration to a tolerable level.
Marc Briand is Editor-in-Chief of C/C++ Users Journal. He loves programming, writing, and too many other things for his own good. However, he hates to work, which is why he is an editor. He may be reached at mbriand@mfi.com.