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

Book

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

Description

  • 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.



0201185385B04062001

Downloads

CD Contents

Untitled Document Download the CD Contents related to this title.

Extras

Web Resources

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

Sample Content

Table of Contents



Preface.


Intended Audience.


How This Book is Organized.


What You Will Need.


Acknowledgements.


About the Authors.


Brian Sawert.


Larry Martin.


Gary Field.


Introduction.


An Overview of SCSI Technology.


The SCSI Solution.


SCSI-1.


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.


P1394.


Layered Architecture.


Plug and Play SCSI.


SCSI Fundamentals.


SCSI Transactions — An Overview.


SCSI Phases.


SCSI Phases.


Bus Free.


Arbitration.


Selection.


Reselection.


Message Out.


Command.


Data In and Data Out.


Status.


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.


Abort.


Bus Device Reset.


Disconnect.


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.


Inquiry.

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.


Read.


Write.


Other Commands.


Status, Sense, and Errors.


Status.


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).


Abort SRB (SC_ABORT_SRB).


Reset SCSI Device (SC_RESET_DEV).


Rescan SCSI Bus (SC_RESCAN_SCSI_BUS).


Get/Set Timeouts (SC_GETSET_TIMEOUTS).


ASPI Error and Status Codes.


ASPI SRB Status (SRB_Status).

SS_PENDING.

SS_COMP.

SS_ERR.

SS_INVALID_CMD.

SS_INVALID_HA.

SS_NO_DEVICE.

SS_INVALID_SRB.

SS_FAILED_INIT.

SS_ASPI_IS_BUSY.

SS_BUFFER_TOO_BIG.

SS_BUFFER_ALIGN.

SS_SECURITY_VIOLATION.

SS_ABORTED.

SS_ABORT_FAIL.

SS_NO_ASPI.

SS_ILLEGAL_MODE.

SS_MISMATCHED_COMPONENTS.

SS_NO_ADAPTERS.

SS_INSUFFICIENT RESOURCES.



Host Adapter Status (SRB_HaStat).

HASTAT_OK.

HASTAT_SEL_TO.

HASTAT_DO_DU.

HASTAT_BUS_FREE

HASTAT_PHASE_ERR.

HASTAT_TIMEOUT.

HASTAT_COMMAND_TIMEOUT.

HASTAT_MESSAGE_REJECT.

HASTAT_BUS_RESET.

HASTAT_PARITY_ERROR.

HASTAT_REQUEST_SENSE_FAILED.



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.

Patching.

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.


Hardware.


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.


IOCTL_SCSI_GET_INQUIRY_DATA.


IOCTL_SCSI_GET_CAPABILITIES.


IOCTL_SCSI_GET_ADDRESS.


IOCTL_SCSI_RESCAN_BUS.


IOCTL_SCSI_PASS_THROUGH and IOCTL_SCSI_PASS_THROUGH_DIRECT.


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.


Summary.


Acknowledgements.


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.

Books.

Magazines and Journals.

Online Information.

Web Sites.

Usenet Newsgroups.

FTP Sites.

Bulletin Board Systems.

Manufacturer Contacts.



Appendix C — Installing the Windows NT ASPI32 Service.


0201185385T04062001

Preface

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.

Acknowledgments

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.



0201185385P04062001

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020