Home > Store

Programmer's Guide to SCSI, The

Register your product to gain access to bonus material or receive a coupon.

Programmer's Guide to SCSI, The


  • Sorry, this book is no longer in print.
Not for Sale


  • Copyright 1998
  • Dimensions: 7-3/8" x 9-1/4"
  • Edition: 1st
  • Book
  • ISBN-10: 0-201-18538-5
  • ISBN-13: 978-0-201-18538-6

The Programmer's Guide to SCSI offers a concise tutorial and reference to the Small Computer Systems Interface (SCSI), the standard interface for high-performance computer peripherals. Geared specifically for programmers who are writing drivers or creating applications that support SCSI devices, this book presents comprehensive SCSI hardware and software information within the context of software development. It will help you find your way through this complex topic and ease your learning curve by providing expert advice, tips, and techniques for more effective SCSI programming.

The Programmer's Guide to SCSI covers both high- and low-level programming topics. Specifically, you will find coverage of:

  • SCSI in general, including an explanation of its design philosophy, evolution, and transaction model
  • SCSI-2 features, including faster transfers, wider data paths, and other specialized capabilities
  • SCSI-3, including Fast-20 and Fast-40 SCSI, serial SCSI, fibre channel, P1394, and plug-and-play SCSI
  • The Advanced SCSI Programming Interface (ASPI) and the ASPI32 extensions under Windows 95 andWindows NT
  • The Windows NT built-in SCSI Pass-Through Interface
  • Low-level programming using SCRIPTS
  • SCSI target mode programming
  • SCSI support under different UNIX implementations
  • SCSI debugging and troubleshooting

In addition, this book develops an ASPI class library and uses it to create a SCSI snooper application under Windows. The library can also be extended for use in your own projects.

This book's clear presentation of SCSI eliminates wading through densely packed hardware documentation and lets you approach the topic with better direction to gain a fuller understanding.



CD Contents

Untitled Document Download the CD Contents related to this title.


Web Resources

Click below for Web Resources related to this title:
Supporting Web Site

Sample Content

Table of Contents


Intended Audience.

How This Book is Organized.

What You Will Need.


About the Authors.

Brian Sawert.

Larry Martin.

Gary Field.


An Overview of SCSI Technology.

The SCSI Solution.


SCSI-1 Features.

Intelligent Devices.

Multitasking I/O.

Synchronous Data Transfer.

Multiple Device Types on a Single Interface.

The Birth of SCSI-2.

New Features in SCSI-2.

Fast SCSI.

Wide SCSI.

Fast Wide SCSI.

Queued I/O Processes.

New Command Sets.

Improved SCSI-1 Features.

Data Parity Required.

Message Support Required.

Terminator Power Provided by Initiator.

SCSI-3 on the Horizon.

Fast-20 and Fast-40 SCSI.

Serial SCSI Standards.

Fibre Channel.

Serial Standard Architecture.


Layered Architecture.

Plug and Play SCSI.

SCSI Fundamentals.

SCSI Transactions — An Overview.

SCSI Phases.

SCSI Phases.

Bus Free.




Message Out.


Data In and Data Out.


Message In.

Phase Sequence.

SCSI Messages.

Message Types.

The Identify Message.

Extended Messages.

Synchronous Data Transfer Request.

Wide Data Transfer Request.

Other Common Messages.

No Operation.


Bus Device Reset.


Ignore Wide Residue.

Queue Tag Messages.

Simple Queue Tag.

Head of Queue Tag.

Ordered Queue Tag.

SCSI Commands.

Command Structure.

Operation Codes.

Logical Unit Number.

Command Parameters.

Control Field.

Parameter Lists.

Byte Order.

Mandatory SCSI Commands.

Test Unit Ready.


Example - Iomega Zip Drive.

Optional Commands.

Device Type Specific Commands.

Mode Select.

Mode Sense.

Mode Sense Data Format.

Example - Iomega Zip Drive.

Reading and Writing.



Other Commands.

Status, Sense, and Errors.


Status Codes.

Sense Data.

Sense Key.

Unit Attention.

Additional Sense Codes.

Example - Iomega Zip Drive.

ASPI — The Advanced SCSI Programming Interface.

What is ASPI?

Why should I use ASPI?

ASPI Concepts.

Adapter and Device Addressing.

Issuing SCSI Commands.

Building the SCSI Request Block.

Sending an SRB to the ASPI Manager.

Waiting for an SRB to Complete.

Processing Returned Status Information.

Adapter Specific Properties.

Connecting to the ASPI Manager.

ASPI Commands.

Host Adapter Inquiry (SC_HA_INQUIRY).

Get Device Type (SC_GET_DEV_TYPE).

Execute SCSI Command (SC_EXEC_SCSI_CMD).


Reset SCSI Device (SC_RESET_DEV).


Get/Set Timeouts (SC_GETSET_TIMEOUTS).

ASPI Error and Status Codes.

ASPI SRB Status (SRB_Status).




















Host Adapter Status (SRB_HaStat).












Target Device Status (SRB_TargStat)

Additional ASPI for Win32 Functions.

Low Level SCSI Programming with SCRIPTS.

Working with SCRIPTS.

An Overview of SCRIPTS.

SCRIPTS Instructions.

Logical Operators and Conditional Tests.

Embedding SCRIPTS in C Code.

Changing Run-Time Parameters.


Table Indirect Addressing.

Detecting SCRIPTS Program Completion.

Polling for Completion.

Hardware Interrupt on Completion.

Initialization and Housekeeping.

PCI BIOS Functions.

Initializing SCSI Control Registers.

Sample Code.

Generic SCRIPTS Code.

SCSI Target Mode Programming.


Handling SCSI Phases.

Target-mode API.

Adapter Inquiry (TSPI_CMD_AdapterInfo).

Attach LUN (TSPI_CMD_AttachLUN).

Detach LUN (TSPI_CMD_DetachLUN).

Get Event (TSPI_CMD_GetEvent).

Read Data From Host (TSPI_CMD_ ReadFromHost).

Write Data To Host (TSPI_CMD_ WriteToHost).

Complete Command (TSPI_CMD_CompleteCommand).

Send Message To Host (TSPI_CMD_SendMessage).

Get Message From Host (TSPI_CMD_GetMessage).

Disconnect (TSPI_CMD_Disconnect).

Reconnect (TSPI_CMD_Reconnect).

Connecting to the TSPI Manager.

Using the TSPI Interface.

SCSI Support Under Windows.

ASPI for Windows 3.x.

ASPI for Win32 (Windows 95 and NT).

The Windows 95 and NT SCSI Model.

Windows NT SCSI Pass-Through Interface.






Unix SCSI Implementations.

A Brief Description of UNIX Device Drivers.

Comparison of UNIX Implementations.

The Linux SCSI Disk Driver.

The Linux SCSI Pass-through Driver.

Example SCSI Pass-through Application Program.



Troubleshooting and Common Mistakes.

Start With a Clean Hardware Layer.

SCSI Bus Termination.

SCSI Termination Power.

Be Cautious With Cables.

Don’t Take Documentation at Face Value.

Watch Out for Platform Dependencies.

SCSI Byte Order.

ASPI Byte Order.

Structure Alignment.

Buffer Alignment.

Debugging Tools.

Interactive Command Utilities.

Virtual Devices.

SCSI Bus Analyzers.

Keep a Record.

Sample Application — SCSI Snooper.

An Overview of the SCSI Snooper.

The ASPI Class Library.

The ScsiInterface Class.

The ScsiDevice Class.

The ScsiCmdBlock Class.

Initializing the ScsiInterface Class.

Executing a ScsiCmdBlock.

Using the ASPI Class Library.

Deriving SCSI Device Types.

The SCSI Snooper Application Framework.

SCSI Snooper Application Structure.

Appendix A — Glossary of Acronyms.

General Terms.

SCSI-2 Definitions.

SCSI-2 Protocols.

SCSI-3 Definitions.

SCSI-3 Architecture.

SCSI-3 Command Sets.

SCSI-3 Protocols.

SCSI Software Interfaces.

Appendix B — SCSI Resources.


Magazines and Journals.

Online Information.

Web Sites.

Usenet Newsgroups.

FTP Sites.

Bulletin Board Systems.

Manufacturer Contacts.

Appendix C — Installing the Windows NT ASPI32 Service.



In the years since the Small Computer Systems Interface (SCSI) first appeared, it has gained wide acceptance as the interface standard for high-performance computer peripherals. Once confined to mainframes and high-end workstations, SCSI devices are now supported by most desktop operating systems running on personal computers.

There is a reason for this near universal support. The SCSI standard was designed as a high-performance interface to a wide range of devices types. Disk drives, optical and tape drives, scanners, and printers all come equipped with SCSI interfaces. As faster machines become more common, the demand for faster peripherals follows. SCSI technology offers a way to meet this demand.

Though manufacturers and end users have embraced the Small Computer Systems Interface, information about programming SCSI devices is still scarce. This book attempts to fill that gap by describing SCSI from a programmer's point of view.

Intended Audience

This book is intended as a tutorial and a reference for programmers writing software to support SCSI peripherals. Whether you are writing low-level code for a SCSI device driver or high-level code for an application, you will find information you can use.

Maybe you have waded through the details of the ANSI specification documents. Maybe you have tried to decipher another programmer's source code. There is no doubt that learning the fundamentals of SCSI programming through trial and error can be a source of endless frustration. Our goal is to plant a few guideposts to steer you in the right direction, so as to flatten the learning curve for this complex but fascinating technology.

The presentation is slanted toward software development. Information about signal characteristics, timing protocols, and hardware details only appear when they directly relate to a programming task. We assume that if you are reading this book, you're more comfortable with a keyboard than a soldering iron. We also assume some experience with C, C++, and assembly language.

How This Book Is Organized

This book begins with an overview of SCSI. We describe the design philosophy behind the standard, and how it has evolved to incorporate new features and capabilities. We also describe variations of the SCSI standard that offer faster transfers, wider data paths, or other features.

Anyone working with SCSI must understand some fundamental concepts. How do SCSI devices communicate? How are commands executed and data transferred? What roles do the initiator and the target play? We address these questions by describing the SCSI transaction model. This provides a foundation for a more detailed discussion of the elements of a SCSI transaction.

Next we present a layered approach to SCSI programming, starting with high-level programming interfaces. We explore the Advanced SCSI Programming Interface (ASPI) under DOS and Windows, and ASPI32 extensions under Windows 95 and NT.

Windows NT offers its own built-in SCSI support. We explore how it works by examining the Windows NT device model and how the ASPI layer uses it.

Then we tackle more advanced material as we look at low-level programming using common SCSI I/O processors and scripting languages such as Symbios Logic's SCRIPTS. We demonstrate both initiator and target operations.

SCSI enjoys wide support on UNIX systems. Unfortunately, the specifics of SCSI support differ greatly between UNIX implementations. The UNIX chapter highlights SCSI support under different systems, then focuses on SCSI under Linux. This platform is widely available, and open enough to encourage experimentation.

Last of all, we develop a SCSI class library and use it to develop a sample application under Windows. This should encourage you to use and extend the library for your own projects.

The final chapter offers advice in troubleshooting and debugging. Appendix B lists SCSI resources in print and electronic form.

What You Will Need

The sample code in this book was designed for portability. We developed most of the code using Microsoft Visual C++. The SCRIPTS sample code uses Borland's C++ compiler and Turbo Assembler. Either should port with little effort. The sample application uses Microsoft's Foundation Classes library, also available with other compilers. The Linux code uses the compiler that comes with the operating system.

We recommend using an Iomega Zip drive as a test device for the sample code. Some of the samples demonstrate disk drive operations. When testing these, it's nice to have something besides your system disk to work with.

Zip drives come in SCSI or parallel port versions. The parallel port device uses an ASPI compatible driver.

The low-level code uses the Symbios Logic SCRIPTS compiler and host adapters equipped with 53C8XX family processors. The compiler is available from the Symbios Logic FTP site. The code should be compatible with other adapters in the same family. If your host adapter uses a chip from another manufacturer, you will not be able to use this code. If you wish to contact Symbios Logic, refer to the manufacturer listing in Appendix B.

The ASPI code will work with almost any host adapter that comes with an ASPI compatible driver. For more advanced work, you may wish to purchase the ASPI Developer's Kit from Adaptec. To contact Adaptec, refer to the manufacturer listing in Appendix B.

For any serious work with SCSI, you will need a copy of the ANSI SCSI-2 specification document. Though we cover SCSI fundamentals in this book, and probe the depths of some programming issues, we can't duplicate all the details that the specification covers. Consider this book a supplement to the ANSI document, which is available from Global Engineering Documents. You'll find them listed in Appendix B.


This book would not have been possible without contributions from many people. Kathleen Tibbetts, formerly an editor at Addison-Wesley, had faith in the project from the beginning.

Pamela Thompson at Earle Associates and Lauren Uddenberg at Symbios Logic went above and beyond the call of duty to provide support and information about Symbios products.

Thanks go to Mike Berhan and Dan Polfer of Adaptec for reviewing the ASPI-related material. Thanks also to John Lohmeyer, chairman of the T10 Technical Committee, for his comments and critiques of the material covering the SCSI specifications.

Special thanks go to contributing authors Larry Martin and Gary Field. Larry shares his invaluable programming experience in the chapters on ASPI, Windows device support, and SCSI target mode. Gary, who maintains the SCSI FAQ for the comp.periphs.scsi newsgroup, shares his considerable knowledge of UNIX support for SCSI in a chapter devoted to the subject.

Most important, I wish to acknowledge the inspiration and encouragement that my wife, Mary, provided throughout this project.



Submit Errata

More Information

Unlimited one-month access with your purchase
Free Safari Membership