SCSI (pronounced scuzzy) TUTORIAL By Daniel L. Miller, MD, BSEE 11 West Wedgewood Glen The Woodlands, TX 77381 copyright 9-5-87 daniel l. miller HAL PC MEMBER This article combines two interests in that it fits into both the advanced pc hardware series and the Texas computer firm series. The article format is an expanded outline to save printed space. 1 Operational Description The Small Computer Serial Interface is an input/output channel bus specification. The specification allows up to eight bus controllers to exchange control packets and bytes of data between any two pairs of controllers. 2 Examples of Data Exchange Workstation to hard disc, optical disc and high density floppy. Workstation is the bus master the peripheral devices are individually accessed. One initiator , 3 targets. Several workstations accessing a bank of hard discs for fast data retrieval with interleaved seeks and queed commands. Multiple initiators, multiple targets. Each drive disconnects from the bus during long seeks, while other drives transfer data and then reconnects when ready to transmit data. 3 Rates of data exchange Data rate of readily available bus interface chips 12 - 15 megabits per second. NCR 5380 / NCR 5385 Logic Devices L5380 32 megabits / sec 4 Controller Selection Bus controllers are free to access the bus to try to gain control to initiate a data exchange. Bus arbitration is according to a fixed priority 0 - 7 rating. If two devices request access the lower priority device must wait. 5 How many devices. The specification allows 8 controllers to be selected from 8 data lines -- one line per each device. Two additional lines select up to 4 devices for each controller. Up to eight bus controllers each controlling up to 4 devices totals 32 devices. A proposed extension allows binary decoding of the selection lines to allow 64 controllers. ( Ampro SCSI+ protocol, Ampro advertises in Byte ) 6 Accessing the Bus The scsi interface protocal may be implemented with a dedicated cpu and 4 input and 4 output data latches. ( Novix Beta Board ) However, scsi bus interface chips with data latches are readily available both in TTL and CMOS configuration. NCR, Toshiba 2nd source and similar purpose chips are available from Adaptec and Western digital. Emulex has announced a vlsi chip scsi processor which they claim can implement bus sequences without external microprocessor intervention. The NCR chip is programmed by addressing register select lines and storing a byte in the controll register and if appropriate in the data register. A programming manual lists the possible commands. The chip will perform aribitration logic and drive the bus and detect protocol errors ( called phase errors in the NCR literature ) and parity errors. Data ready and error conditions are flagged by an inerrupt line. A register holds a code to identify the type of error detected to be read by the host cpu for error interrupt handling routines. The interface chip has handshake signals to operate efficiently with a DMA controller to move blocks of data into or out of a section of memory. The dma is a dedicated cpu chip that generates addresses for moving data sequentially into or out of memory. 6.5 Terminology Initiator - the device that begins an interchange Target - The device that is selected by the initiator Host - In the configuration of a computer sending data to one or more disk drives, "host" refers to the main workstation computer. Controller - any device that connects to the scsi bus connects through a controller. Device - Each controller on the bus can control up to 4 devices. Each device can be individually addressed, so a device connected to one controller can specifically talk with a device on another controller. Devices connected to the same controller cannot talk to each other over the scsi bus. The devices are also called "Logical Units" or LUN's because they are addressed and specified by 2 bits in each command sent over the bus, rather than being selected by a hardware bus line. SASI - sasi stands for Sugart Associates System Interface, a single host multiple target ( non arbitrating ) interface which was the precursor to the SCSI specifications. SCSI - Small Computer System Interface, the current standard specification is the ANSI (American National Standards Institute) version X3.131, 1986. Embedded Controller- some drives have a scsi interface built into the drive electronics mounted in or on the drive itself. This will be referred to as a "scsi drive." SCSI controller - a scsi interface board that then connects with up to four devices like esdi drives or st412/506 drives or optical drives. ( The scsi controller is made to talk to regular devices, like the drives in a xt or at computer.) Scsi controllers are made for optical drives, tape systems, ESDI and st412/506 hard discs. 7 Data Transfer Protocol The initiating controller first gains control of the bus and gets the attention of its target controller. The target then takes control of the data exchange and asks the initiator what it wants to do. ie give a command, send or receive data. The initiator responds and the target aknowleges receipt of command and transmits or recieves data, under control of the target controller. The target will indicate with a message that it has successfully completed its mission. Bus phases BUS FREE phase SELECTION phase COMMAND phase -- DATA phase |-----These are the information transfer STATUS phase | phases. MESSAGE phase --| ARBITRATION phase (optional) | |-for multiple hosts RESELECTION phase (optional) |---optional-| for multidrive high bus performance 7.5 DATA EXCHANGE WALKTHROUGH An example of a simple data interchange between an initiating host PC and a target hard disc drive. To send a block of data to a disk drive a pc first checks the bus busy line. When the line indicates the bus is free, the pc will send its identification code over the data lines and pull the bus control lines. If there is more than one device desiring to use the bus at the same time, the device with the highest priority always wins. There is no inherent mechanism to insure fairness or to force a round robin to prevent one device from tying up the bus. After gaining control of the bus the pc will select its target device by activating one of eight lines. The device selected then takes control of the data interchange, and will remain in control until the end of the exchange. The target asks the pc for a command. The pc responds with a command block to read 10 blocks beginning with block 5. The target acknowledges and translates the logical block numbers to absolute sectors, seeks and reads the sectors, performs error correction and transmits the data byte by byte with a handshake acknowlegement after each byte. When it is finished it requests to send its status and transmits a status report, if the status is good and the data does not have to be retransmitted the drive then requests to send a message and reports completion. 8 SCSI Command Format When the target requests a command, the initiator responds by sending out 5 bytes ( 40 bits ) of command information. These bits are used to specify the command and identify the logical device. There is a SCSI COMMON COMMAND SET specification The purpose of the specification was to "Allow true second sourcing of SCSI hardware." However, because there are still multiple ways to do certain commands and vendor specific functions, hard disc interchangeability has not yet been achieved. From the end user point of view, one can't unplug one scsi drive and replace it with one from another manufacturer and expect it to work without rewriting the device driver software for formats and the message handling scsi driver routines. The set of 40 bits is called a command block. The first byte specifies the class of commands or opcode. Some Common Command Set Opcodes are the following: Opcode 00 (hex) TEST UNIT READY 03 FORMAT UNIT 08 READ 0A WRITE 0B SEEK Since the drive controller electronics is on the drive side of the SCSI BUS the data is organized by the drive controller and requested by block number. The controller translates the block number to the track and sector information used to step to the data. This permits flexibility for the drive manufacturer. A drive with an embedded SCSI controller can reallocate bad blocks internally and substitute blocks automatically from a spare track. The meaning of the remaining bits varies for each opcode. The Write Command, opcode 0A, for example BYTE 0 opcode 1A (00001010) BYTE 1 Logical unit number in bits 5-6, bits 1-4 specify logical block address BYTE 2 logical block address BYTE 3 logical block address BYTE 4 Bits 2 to 5 specify the transfer length BYTE 5 Bits 7 and 6 are vendor unique, bit one is a flag, bit 0 a link 9 SCSI Hardware Bus Specification 25 signal lines; 25 ground lines Signals may assume true or false values. Signal assertion (true)is 0 v. Signal negation (false) is 2.5 to 5.25 V dc ( Bus driver chips typically invert the signal so bus voltage levels are typically the reverse of normal logic levels input to the on chip or input to the bus drivers where +5 V is true.) SCSI BUS SIGNALS Busy indicates the bus is in use Select used by the host to select the drive Control/Data This signal is driven by the target (like a disc drive and indicates whetehr CONTROL or DATA information is on the DATA bus. A true value indicates a control signal is on the bus. Input/Output This signal is driven by the target (disc drive) and controls the direction of data movement on the DATA bus with respect to the host. A true value indicates input to the host. Message This signal is driven by the target (disc drive) during the message phase. Request This signal is driven by the target (disc drive) and indictes a request for a data transfer handsake acknowlegement. Acknowledge This signal is driven by the host and acknowleges a a data transfer handshake. Attention This signal is driven by the host to indicate a condition needing attention. Reset This forces a reset of devices on the bus. Data lines (8) Parity line (1) This line may be used by the devices to signal a parity error in the received data or command. Bus Power lines 10 SCSI CATALOG HOST BOARDS for the IBM PC, XT, AT, ... IBMetc...COMPAC... CLONES... Drop in boards for the pc,xt,at and 386 IBM, Intel, Compac and close clones are available from Advanced Storage Concepts and Hudson and Supinger and Future Domain. Hudson and Supinger is of interest in that they supply an example dos driver program in C language although their prom routines remain proprietary. ADVANCED STORAGE CONCEPTS (The Houston based company in this article.) sources a board that just drops into the pc XT AT or 386 and uses an included self installing device driver to configure the board and install itself as a DOS device driver. I have had one operating in my XT for a year with no problem. Included software functions set up drives of any size and get around the dos 32 megabyte max drive size "limit". Operation is transparent. And from my keyboard and application programs I can't tell that I'm using a scsi disc. The short slot size board has a eeprom that remembers the configuration so there are no jumpers or switches to set. The proms and driver source code are proprietary. Many ( 30+ ) scsi drives are supported. The installation program has the data on file for the drives like the number of logical blocks and the message codes returned and the format commands so the user only has to pick the drive name and model from a menu and the program does all the work. The installation program has nice colors and jazz and looks like something well done in Turbo Pascal and has a good feel to it. Advanced Storage Concepts does systems integration for large oem's and drive manufacturers and systems suppliers, but did not seem to mind my bothering them. At one time they had advertised in PC Tech magazine. National Memory Systems sells scsi drive systems and boards primarily for minicomputers and super micros and IBM comptible scsi systems. SCSI drives are available from a variety of commercial electronics suppliers including Arrow and Hallmark and Dallas Digital and Quality Components in Richardson. Integrated scsi controllers built into disc drives are made by many drive manufactureres including Quantum, Maxtor, Rodime, Teac, Kodak, Fujitsu, C. Itoh, NEC, Seagate, Shugart Associates (who originated the SCSI specifications in conjunction with NCR and Ampro), and Connor Periferals. A partial list of devices with scsi interfaces include 5 1/4 inch drives up to 760 meg from Maxtor, Quantum, NEC Toshiba, Fujitsu, Connor Periferals, plus about 10 others. 5 1/4 inch floppy drives up to 12 (twelve is correct !) megabytes from Verbatim (now a Kodak data division). 3 1/4 inch drives up to 170 meg from Maxtor. Miniature lightweight Connor Periferal 40 and 80 meg drives. Optical Write once read many time discs from ( 5 1/4) Optotech in Denver 200 meg per side and Kodak at 1.2 gigabytes in a 12 inch disc. SCSI controllers made to connect a scsi bus to up to 4 drives using the esdi or 502 interface are available. These controller boards would be used to hook the hundreds of cheap drives available for the pc xt or ps2 computers to a scsi bus. Manufactureres of these controller boards include Adaptec, Emulex, and OMTI. SCSI computer motheroards with a built in scsi chip set and the system proms or operating system has the software, interrupt handlers, and message handlers to talk to at least one brand of scsi drive. These computers include the Macintosh Plus, The Amiga, Steve Ciarcia's Micromint's SB180FX, PC TECH SUPER 10 MHZ AT clone and their 386 machine, The Slicer, The Semidisc 64180, Chicago Computer's 68000 machine. Drop me a note if you need a commercial address or telephone number.