Download as pdf or txt
Download as pdf or txt
You are on page 1of 50

H Hard Disk Drive Controllers

H.l The IDE Interface Commands


The specifications cylinder, head, sector number and sector size are called the sector ihti-
jWiO?L

The data and status registers are together called the AT task file.
Before you can access a register you have to determine whether the BSY bit in the status
register flf7h) is cleared.
The transfer of a command byte to the command register (lf7h) starts the corresponding
command; therefore you have to load the parameter registers with the necessary values in
advance.
All sector and format data is read and written via the data register (IfOh) by means of
programmed I/O (PIO); a data exchange is only possible if the BSY bit in the status register
is cleared and the DRQ bit is set.
The DRQ bit remains set until the sector, format and, eventually, ECC data are completely
read or written.
Read and write commands can last across several sectors, starting with the start sector if the
value in the sector number register (lflh) is larger than 1; a value of 0 in this register means z
that the corresponding command is executed for 256 sectors.
After command completion, the status register (lf7h) and, eventually, the error register
(lflh) contain status information, which enables you to confirm the correct execution of the
command or to determine the reason for a malfunction or command abortion.
If erroneous read data is correctable by the ECC bytes, the controller sets the CORR error bit
in the status register (If/h), but the command execution is not aborted.
The sector identification after command completion or abortion indicates the last handled
sector or the sector where the error occurred, respectively.
Most IDE hard disks can be operated in native and translation mode: in native mode the
logical drive geometry coincides with the physical geometry; in translation mode the trans-
lation logic of the controller translates the physical geometry to a completely different logical
geometry.
Be careful when using the format command because drives in translation mode can behave
unpredictably if you program this command; the IDE hard disk comes preformatted with the
best interleave factor; the dynamic bad sector remapping remaps defect sectors to good ones,
and later reformatting of the drive is therefore unnecessary.
The multiple sector commands read sector and write secbr issue an interrupt 76h via IRQ14
before or after processing each sector.

1185
1186 Appendix H

- The result phase of each command starts with a hardware interrupt via IRQ14.

- The IDE interface supports two physical drives at most; the master (drive select 0) and the
slave (drive select 1).

- For the IDE interface, the eight’commands of the original AT are required; in H.1.4 you will
find the additional optional commands that were introduced with the new IDE specification.

H.l.l Summary of the Listed Commands

- required commands
calibrate drive
read sector
write sector
verify sector
format track
seek
diagnostics
set drive parameters

- optional commands
read sector buffer
write sector buffer
identify drive

H.1.2 Required Commands

Calibrate Drive flxh)

This command moves the read/write heads to cylinder 0. After issuing the command by trans-
ferring the command byte to the command register, the controller sets the BSY bit in the status
register and moves the head to track 0. When the seek is complete the controller clears the BSY
bit and issues a hardware interrupt via IRQl4. After a seek error, the command can be used to
recalibrate the drive.

Command Phase

AT Task File Bit


Ftegtster j6/514/312jlLO
Command (117h) : 0 0 1 x x x x
n Y ”

X: v a l u e s ineignificant (recomlnendation: 0)
DR”: d r i v e
l=SlaVe 0=IME!ter
Hard Disk Drive Controllers 1187

Result Phase

NTO: l=track 0 not found O.no error


AFT: command abortion
l=command aborted O=conrmand completed
NID: l=ID mark not found O.no error
DRY: calibrated drive
l.slave o-master
HD,-ED,: active head (unchanged)
BSY: busy
l=drive busy O.drive not busy
P.DY: ready
l.driva ready O=not ready
SKC: seek
1=comp1ete O=in progress
DRQ: data request
l-data can be transferred O=no data access possible
ERR: error
l=error register contains additional error information
X: unused, invalid

Read Sector (2xh)


This command reads l-256 sectors according to the value in the sector count register; a value of
0 means 256 sectors. The first sector is specified by the sector number, cylinder MSB, cylinder
LSB, and head registers. After transfer of the command code, the controller sets the BSY bit in
the status register, and the addressed drive carries out an implicit seek, activates the corres-
ponding read/write head, and reads the sector, eventually together with the ECC bytes, into
the sector buffer. After the read of each sector the DRQ bit is set, and the controller issues a
hardware interrupt 76h via IRQ14. The interrupt handler transfers the sector data into main
memory. If all data words are transferred and at least one more sector is to be read, the con-
troller sets the BSY bit again, clears DRQ and reads the next sector, etc. The sector identification
is automatically updated, and always indicates the currently processed sector.
If a non-correctable data error occurs, the controller aborts the command and the sector identi-
fication defines the sector with the error. If the data error can be corrected by the ECC bytes,
only the CORR bit in the status register is set, but the command is not aborted. If the long-bit
L is set the controller executes a read-long command and the sector data, together with its ECC
bytes, are read. In this case, the controller does not carry out an ECC check. DRQ is active until
the last ECC byte is read by the host. The ECC data is transferred byte by byte, all other data
is transferred word by word (16 bits).
1188 Appendix H

Command Phase

Cylnder MSB (lf5h) / 0 0 0 0 0 0 c9 G3


Drive/Head (116h) 11 0 1 DFtV H& H& HD, Hq

L: long-bit
l=sector data and ECC bytes are read O=only sector data is read
R: retry disable
l=automatic command retry is not executed
O=automatic command retry is executed
S,-S,: *ector number
c,-c,: cylinder number (lo-bit binary number)
DRV: drive
l-slave o=master
HD,-HD,: head number (binary number)
OOOO=head 0 OOOl-head 1 OOlO=head 2 ... llll.head 15

Result Phase

AT Task File 811


Register 716151413121110
Error (lflh) NCM x AET x NID x UNCEW

Sector Number (lf3h) S, S, S, S4 S, S2 S, So

l ' in the ca8e of command abortion, the register indicates the number of sectors still to be read
NDM: l=data address mark not found o=no error
ABT: command abortion
l=command aborted O=conmand completed
NID: l=ID mark not found O=no error
IJNMC: l=uncorrectable data error O=no or correctable data error
BBK: l=sector marked bad by host o-no error
C,-C,, S,-S,. HD,-HD,: sector identification of sector last read
DRV : drive
l.=s1ave oanaster
BSY: busy
l-drive is busy O=drive not busy
RDY : ready
l=drive ready O=not ready
DRQ : data
l=can be transferred O.no data access possible
cm: correctable data error
l=occurred O.no data error
Hard Disk Drive Controllers 1189

lzerror register contains additional error information


X: unused, invalid

Write Sector (3xh)

This command writes l-256 sectors according to the value in the sector count register onto disk.
The first sector is specified by the sector number, cylinder LSB, cylinder MSB, and head regis-
ters. After the transfer of the command code, the controller sets the BSY bit in the status register,
the addressed drive carries out an implicit seek and prepares the sector buffer for receiving the
write data from main memory. Afterwards, the controller sets the DRQ bit and clears the BSY
bit. The CPU now must transfer the sector data, eventually together with the ECC bytes, via the
data register (IfOh) into the sector buffer. When the write data is transferred the controller clears
the DRQ bit and sets the BSY bit again. Then the drive writes the data onto disk. If at least one
more sector is to be written, the controller sets the DRQ bit, clears the BSY bit, and issues a
hardware interrupt 76h via IRQ14. The interrupt handler now transfers the write data for the
next sector from main memory t6 the data register, etc. The sector identification is automatically
updated, and always indicates the current processed sector. After all sectors are written, the
controller once again issues an-interrupt via IRQ upon entering the result phase.

If a write error occurs, the controller aborts the command and the sector identification defines
the sector with the error. If the long-bit L is set the controller carries out a write-long command,
and the sector data together with the ECC bytes is written. In this case, the controller does not
generate the ECC byte itself, but writes the transferred byte onto disk without any change. DRQ
is active until the last ECC byte is transferred by the host. The ECC data is transferred byte by
byte, all other data is transferred word by word (16 bits).

Command Phase

AT Task Fdn Rit

L: long bit
lssector data and ECC bytes are written O=only sector data is written
R: retry disable
l=automatic command retry is not executed
O.automatic command retry is executed
s,-s,: sector number
c,-c,: cylinder number (lo-bit binary number,
DRY : drive
l=L%lZW.3 o=mastar
HD,-HD,: head number (binary number)
OOOO.head 0 OOOl=heed 1 OOlO.haad 2 ... llll-head 15
1190 Appendix H

Result Phase

l ' in the case of command abortion, the register indicates the number of sectore still to be
written
N7Bf: l=data address mark not found o.no error
AN: command abortion
lxxmmand aborted O=conmand completed
NID: l.ID mark not found o=no error
BBK: l=sector marked bad by host o=no error
C&-C,, .9,-S,, HII,-HD,: .sector identification of sector last written
DR": drive
?.=slave O=IiW3teX
BSY: busy
&drive is busy O=drive not busy
RDY: ready
l.drive ready O=not ready
WiT: write fault
lzoccurred o=no write fault
IX-Q: data
l.can be transferred O=no data access possible
ERR: error
l=error register contains additional error information
LX: unused, invalid

Verify Sector (4xh)

This command checks one or more sectors. The controller reads one or more sectors into the
sector buffer and performs the ECC check, but doesn’t transfer the read sector data to main
memory. Therefore, the check is carried out based on the ECC bytes only; the written sector data
is not compared with the data in an external buffer. At the beginning of the result phase, the
command generates a hardware interrupt 76h via IRQ14. Between the individual sector checks
no interrupts are issued.
Hard Disk Drive Controllers 1191

Command Phase

AT Task File Bit


Register 7~6~5~4~3~2~1~0
Command (lffh) 0 1 0 0 0 0 0 R
Sector Count (112h) Number of Sectors to Verify
Sector Number (lf3h) S, S, S5 S., S, S, S, So
Cylinder LSS (lf4h) C, Cs C5 C, CI C1 C, C0
Cylinder MSB (lf5h) 0 0 0 0 0 0 Cs CB
Drive/Head (lf6h) 1 0 1 DFW H&H&HD,HCp

R: retry disable
l=automatic command retry is not executed
O=automatic command retry is executed
s,-s,: *ectclr number
c,-c,: cylinder number (lo-bit binary number)
DR” : drive
Lslave o=master
SD,-SD,: head number (binary number)
OOOO=head 0 OOOl=head 1 OOlO=head 2 ... llll=head 15

Result Phase

l I in the case of command abortion, the register indicates the number of sectors still to be
verified
NDM: l.data address mark not found o=no error
ABT: command abortion
l.command aborted O=command completed
MD: l=ID mark not found o=no error
DNC: Luncorrectable data error O=no or correctable data error
BBK: l.sector marked bad by host o=no error
c,-c,, q-s,, SD,-SD,: sector identification of sector verified last
DR": drive
l.slave o=master
BSY: busy
l=drive itl busy O=drive not busy
RDY: ready
l-drive ready O=not ready
DRQ: data
l=can be transferred O=no data acce8s possible
COR: correctable data error
l=occurred O=no data error
ERR: error
l-error register contains additional error infonaation
X: unused, invalid
1192 Appendix H

Format Track (50h)


This command formats one track of the hard disk. On most IDE drives the command can be
used in native and translation modes, but the behaviour is rather different in these modes.
In native mode a low-level formatting of the addressed track is carried out. Immediately after
you have passed the command byte, the controller sets the BSY bit and prepares the sector
buffer for receiving the format data from the CPU. Then the controller clears the BSY bit, sets
the DRQ bit, and waits for the transfer of 256 words with format data from the CPU. The CPU
may now transfer the data via the data register (IfOh) to the sector buffer. The format data
consists of two bytes for every sector of the track, where the low byte indicates the sector flag
and the high byte the sector number. A sector flag OOh means a sector to format normally; a
value 80h indicates a sector which has to be marked as bad. The format data is written into the
format buffer with the low byte, that is, the sector flag, first. Note that the format buffer always
has to contain 512 bytes, even if the number of sectors per track is less than 256. The remaining
format bytes are ignored by the controller, but have to be transferred so that the controller sets
the BSY bit and starts the format operation.
If the transfer of the format data is complete, the DRQ bit is cleared and the BSY bit is set. The
controller now starts the format operation of the addressed track. After detecting the index
pulse which indicates the physical beginning of the track, the ID fields of the sectors are rewrit-
ten and the sector data fields are filled with the byte values 6ch corresponding to the character
c(l>~. By means of the ID fields sectors or complete tracks can be marked as bad. After the
formatting, the controller clears the BSY bit and issues a hardware interrupt 76h via IRQ14.
For a format operation in native mode you must therefore know the physical drive geometry
very well. On a drive with zone recording, for example, it is absolutely necessary that you know
all the borders of the individual zones and the number of sectors of each zone. You must
transfer this number to the sector count register.
When formatting in translation mode the controller writes only the sector data filled with the
byte values 6ch; the ID marks are not changed. That is actually not a real formatting operation,
because the structure of the volume is not changed. For example it is not possible to adjust the
interleave value by this. For the number of sectors per track in this case you have to specify the
logical sector number per track; the borders of the zone recording are insignificant. With other
values most controllers respond with an error message ID mark not found and abort the format-
ting operation. In some cases, the controller can do something unpredictable. Low level format-
ting of IDE hard disks in translation mode is therefore very critical, and the normally very
useful tools such as DiskManager or PCTools are of no value. To overwrite all sectors with 512
bytes 6ch has the same effect as a format operation in translation mode.
Hard Disk Drive Controllers 1193

Command Phase

~
Cylinder LSB (114h) C7 Cc C, C4 C, C, C, Co

c,-c,: cylinder number (lo-bit binary number)


mv: drive
l=SlaVe O=master
HD,-HD,: head number (binary number)
OOOO=head 0 OOOl=head 1 OOlO.head 2 ... llll=head 15

Result Phase

NEW: l=data address mark not found o=no error


ABT: command abortion
l=comnd aborted O=conmand completed
HID: l=ID mark not found o=no error
C,-C,, .9-S,, HD,-HD,: sector identification of sector formatted last
DRV: drive
l=SZlFWt? o.master
BSY: busy
l=drive is busy O=drive not busy
RDY: ready
l-drive ready O=not ready
DRQ: data
l=can be transferred 0x10 data access possible
ERR: error
l=error register contains additional error information
; x: unused. invalid

Seek (7xh)

This command moves the read/write heads to the programmed track and selects the addressed
head. Immediately after transfer of the command code, the controller sets the BSY bit and
executes the seek. If the seek is completed correctly, the controller clears the BSY bit, sets the
SKC bit, and issues a hardware interrupt 76h via IRQl4. Note that the disk need not be format-
! ted for carrying out the command correctly. In translation mode the passed logical cylinder
i, number is converted to a physical cylinder number, and the head is moved to the physical
1 cylinder.
1194 Appendix H

Command Phase

Cylinder L S B (114h) CT CS C5 Cd C
~~

q-c,: cylinder number (lo-bit binary number)


DR": drive
l=SlaVe 0=Ul?.L3ter
HD,-HD,: head number (binary number)
OOOO=head 0 OOOl=head 1 OOlO=bead 2 ... llll-head 15
X: unused, invalid

Result Phase

~1

KM: l=data address mark uot found o=no error


NTO: l=track 0 not found o=no error
AB'I': command abortion
l=command aborted O-command completed
NID: l=ID mark not found O=no error
C,-C,, HD,-HD,: track identification of sector where head is moved to
DEW: drive
1=s1ave 0=IlEltlter
BSY: busy
l=drive is busy O.drive not busy
RDY: ready
l=drive ready Osnot ready
SW: seek
1=comp1ete O=in progress
DRQ: data
l=can be transferred O.no data access possible
ERR: error
l=error register contains additional error information
X: unused, invalid

Diagnostics (90h)

This command starts the controller-internal diagnostics routine to check the controller ek-
tronics. The CPU can issue this command if the BSY bit is cleared. The RDY bit concerns
only the drives, and is insignificant for the diagnostics command because only the conlroller
and not the mechanical drives are checked. Note that the diagnostic information is returned in
the error register (lflh). The meaning of the individual error bits differs from the normal case;
Hard Disk Drive Controllers 1195

furthermore, after the completion of the diagnostics command the ERR bit in the status register
(lf7h) is always equal to 0. The seven low-order bits in the error register contain a binary
diagnostics code for the master drive; the high-order bit indicates a summary error code for the
slave drive.
Command Phase

AT Task File
j615141312/1/0

Result Phase

slave diagnostics code


Ozslave o.k. or slave not present
l=error of slave in at least one diagnostics function
binary master diagnostics code
l=master drive o.k.
Z=fomatting circuit error in master drive
3=buffer error in master drive
4=ECC logic error in master drive
S.microprocessor error in master drive
6zinterface circuit error in master drive
busy
l=drive is busy O-drive not busy
data
l=can be transferred O=no data access possible
unused, invalid

Set Drive Parameters (91h)

This command sets the logical geometry of the addressed drive. In the sector count register you
specify the number of logical sectors per logical track, and in the drive/head register you
specify the number of logical heads of the drive. In translation mode the translation logic of the
controller then translates the logical geometry to the real physical geometry of the drive. In
translation mode, the drive uses this logical geometry to carry out those commands involving
a disk access. The number of logical cylinders of the drive is an automatic result of the request
that the number of all logical sectors cannot be larger than the physical sectors actually present.
A change of the logical geometry of a hard disk, where data is already stored, inevitably results
in a complete data loss as the changed geometry destroys the logical structure of the file system.
1196 Appendix H

Command Phase

DR” : drive
1.s1ave Ormaster
IID,-I-ID,: number of logical heads of the drive

Result Phase

AT Task File
Register

busy
l-drive is busy O.drive not busy
ready
kdrive ready O.not ready
PRO : data
l.can be transferred O=no data access possible
XC: unused, invalid

H.1.3 Optional Commands

The following three commands are supported by most of the IDE hard disk drives, although
they are optional commands and were not implemented in the original AT controller.

Read Sector Buffer (e4h)

This command reads out the contents of the controller’s sector buffer. Immediately after you
have passed the command code, the controller sets the BSY bit and prepares the buffer for a
read operation by the CPU. Afterwards, the BSY bit is cleared, the DRQ bit is set, and the
controller issues a hardware interrupt 76h via IRQ14. The CPU now can read the sector buffer
and transfer the data to main memory. The command serves mainly for checking the data path
between controller and main memory. You can use the command in self-programmed diagnos-
tic routines to determine the source of drive faults.

Command Phase

AT Task File Bit


Register 71615j4j312jljO
Command (lfi’h) 1 1 1 0 0 1 0 0
Drive/Head (lf6h) I o I DRV x x x x
7

DR”: drive
l.RlWJE o=master
Hard Disk Drive Controllers 1197

Result Phase

AT Task File
Register 7\6j5,4B;3,2,110
St&IS (lf7h) ESYFDY x xDi=iQxxx

BSY: busy
l=drive is busy Ocdrive not busy
RDY: ready
l=drive ready O.not ready
DRQ: data
l=can be transferred O=no data access possible
X: unused, invalid

Write Sector Buffer (e8h)

This command writes data into the controller’s sector buffer. Immediately after passing the
command code the controller sets the BSY bit and prepares the buffer for a write operation by
the CPU. Afterwards, the BSY bit is cleared, the DRQ bit is set, and the controller issues a
hardware interrupt 76h via IRQ14. The CPU can now transfer data from main memory to the
sector buffer. The command serves mainly for checking the data path between controller and
main memory. You can use the command in self-programmed diagnostic routines to determine
the source of drive faults.

Command Phase

AT Task File Bit


Register /6/51413121110
Command (lf7h) : 1 1 0 1 0 0 0
Drive/Head flf6hl I n ,n!=wx x x x

DRV: drive
l=slWJe o=master

Result Phase

AT Task File Bit


Register 716151413/211/O
Status (lf7h) [BSYFfDY x x DRQ x x x

BSY : busy
l=dsive ia busy Czdrive not busy
RDY : ready
l=drive ready O=not ready
DRO : data
l.can be transferred O=no data acce88 possible
F.: unused, invalid

Identify Drive (ech)

This command reads parameters and other information from the addressed drive. Immediately
after you have passed the command code, the controller sets the BSY bit, loads the information
, into the sector buffer, and prepares the buffer for a read operation by the CPU. Afterwards, the
1198 Appendix H

BSY bit is cleared, the DRQ bit is set, and the controller issues a hardware interrupt 76h via
IRQ14. The interrupt handler has to read all 256 data words of 16 bits each out of the sector
buffer. The structure df the 512 byte information is shown in Table H.l.

Command Phase ,

AT Task File Bit


Register 716/5/413/21110
C o m m a n d (lf7h) 1 1 1 0 1 1 0 0
Drive/Head (Iffih~ , n , -I ‘I II II Y

DR”: drive
l.SlaVe o=master

Result Phase

AT Task File Bit


Register 7~6~5~4~3~2~1~0
status flffh~ IBSYF(DY x XDlwX x x

xx: busy
l.drive is busy O.drive not busy
RDY: ready
l=drive ready O=not ready
DRQ: data
l.can be transferred O-no data access possible
X: unused, invalid

Word’) Meaning

00 configuratior?
01 number of physical cylinders
02 reserved
03 number of heads
04 number of unformatted bytes per physical track
05 number of unformatted bytes per sector
06 number of physical sectors per track
07-09 reserved for manufacturer
lo-19 ASCII serial number
20 buffer type (01 h=one-way, OZh=bidirectional, 03h=cache buffer)
21 buffer size/5 12
22 number of ECC bytes which are transferred in
read/write-long operation
23-26 ASCII identification of controller firmware
27-46 ASCII model number
47 bit 0..7: number of sectors between two Interrupts (multiple sector
reads/writes only), bit 8.. 15: reserved
48 bit 0: 1=32-bit VO, O=no 32-bit VO. bit 7..1: reserved
49 bit 0..7: reserved, bit 8: l=DMA, O=no DMA, bit 9: l=LBA, O=no LBA
50 reserved

Table H.1: Sector buffer identific&on irrformation


Hard Disk Drove Controllers 1199

Word” Meaning
51 bit O..J: reserved, brt 6.15: PI0 cycle time (0=600 ns, 1=380 ns, 2=240 ns, 3=180 ns)
52 bit 0..7: reserved, bit 8..15: DMA cycle time CO=960 ns, 1=380 ns, 2=240 ns, 3=150 ns)
53 reserved
54 number of logical cylinders
55 number of logical heads
56 number of logrcal sectors per logical track
57-58 bytes per logical sector
59 bit 0..7: number of sectors between two interrupts, brt K.15: reserved
60-61 sectors addressable in LBA mode
62 single DMA: bit O..J=supported modes, brt 8..15=active mode
63 multiple DMA: bit O..7=supported modes, bit 8..15=active mode
64-127 reserved
128-159 manufacturer
160-255 resewed

‘) 16-bit words
” bit structure:
0 reserved
1 l=hard-sectored dwe
2 1 -soft-sectored
3 l=FiLL/ARLL format
4 l=head w/Itch delay=1 5 ps
5 l=power-down mode implemented
6 l=hard disk
7 l=removable storage device drwe (usually CD-ROM)
8 l=internal data transfer rate < 5 Mbits/s
9 1=5 Mbits/s < data transfer rate < 10 Mbits/s
10 l=data transfer rate > 10 Mbits/s
11 l=rotatlon deviation > 0 5% (notebook)
12-15 reserved

Table H.l: cont.

; H.1.4 Optional IDE Commands


s
I In the following table you will find all IDE commands, together with the hex command codes,
s which are optional according to the newest IDE interface specification.
1
1
F Command Command code

check for active, Idle, standby, sleep 98 e5


identify drive ec
idle 97 e3
idle Immediate 95 el
read sector buffer e4
read sector with DMA (with retry) ca
read sector with DMA (without retry) c9
read multiple sectors c4
set features ef
set multiple mode c6
I
1200 Appendix H

Command Command code


set sleep mode 99 e6
set standby mode 96 e2
standby immediate 94 e0
write sector buffer , e8
write sector with DMA (with retry) ca
write sector with DMA (wtthout retry) cb
write multtple sectors c5
wnte same sector e9
write verification 3c
achnowledge medium change db
lock drive door de
unlock drive door df
avallable for manufacturer 9a. cO-c3, 8&8f, f5-f
reserved all other codes

H.2 SCSI Commands


All reserved fields have to be set to 0.

LSB characterizes the least significant byte, MSB the most significant byte of a multiple byte
quantity.

The command codes are uniformly 6, 10 or 12 bytes long.

A command is executed in the following phases: transfer of the command code from the
initiator to the target in the command phase + transfer of the parameters and/or data from
the initiator to the target in the data-out phase -+ transfer of the result data from the target
to the initiator in the data-in phase + transfer of the status from the target to the initiator
in the status phase + transfer of messages from the target to the initiator in the message
phase.

LUN indicates the logical unit within one target or one logical unit which is connected to the
target. Examples are two hard disks (LLJNs) which are connected to one SCSI controller
(target).

SCSI manages all drives by means of so-called logicnl blocks which are contiguous and equal
in size. It is the job of the target to convert the logical block address, for example in the case
of a hard disk, into physical cylinder, head, and sector numbers.

The error codes are provided at two levels: as a status key which indicates the error group;
and the status code with a detailed error description.
Hard Disk Drive Controllers 1201

H.2.1 Summary of Listed Commands

Detailed are only the required and the most important optional SCSI commands for disk drives
(hard disks). An extensive discussion of all SCSI device classes would go far beyond the scope
of this book. If you are interested in programming scanners, CD-ROMs and other devices, I have
to direct you to the (now widely available) specialized literature on these topics. For disk drives
only 6 and 10 byte commands are available.
- 6-byte commands
test unit ready (OOh)
rezero unit (Olh)
request sense (03h)
format unit (04h)
reassign blocks (07h)
read (08h)
write (Oah)
seek (Obh)
inquiry (12h)
mode select (15h)
reserve (16h)
release (17h)
mode sense (lab)
start/stop (lbh)
send diagnostic (ldh)
- IO-byte commands
read capacity (25h)
read (28h)
write (2ah)
seek (2bh)
write and verify (2eh)
verify (2fh)
read defect data (37h)
write buffer (3bh)
read buffer (3ch)
read long (3eh)
write long (3fh)
change definition (40h)
mode select (55h)
mode sense (5ah)
The following table lists all SCSI-II commands for the ten device classes disk drive, tape drive,
printer, processor device, WORM, CD-ROM, scanner, optical storage device, media changer and
i communication device. The column with the detailed SCSI commands is emboldened.
1202 Appendix H

Command Length” Code Class”


DD TD Pr PD WO CD S C OS MC Co
Test Unit Ready 6 OOh x x x x x x xx x x
RewindlRezero Unit 6 Olh 0 X M- 0 0 -0 0 -
Request Sense 6 03h x x x x x x xx x x
Format/Format Unit 6 04h X-O-- --O--
Read Block Limits 6 05h M X M M M M--M-
Reassign Blocks 6 07h O M M - 0 --OM-
Read 6 08h 0 X MO 0 0 - 0 M X
Write 6 Oah 0 xxx0 0 -0 MX
Seek 6 Obh 0 - 0 - O O-OM-
Read Reverse 6 Ofh MOMMMM--M-
Write FilemarkGynchronize Buffer 6 10h M X O M O M-_ _ _
Space 6 llh M X M M M M--- -
Inquiry 6 12h x x x x x x x x x x
Venfy 6 13h M O M M M M--- -
Recover Buffered Data 6 14h MOOMMM----
Mode Select 6 15h 0 x 0 - 0 0 00 0 0
Reserve 6 16h x x x - x xxxo-
Release 6 17h x x x - x xxxo-
COPY 6 18h 0 0 00 0 0 00 - -
Erase 6 19h M X M M M M--- -
Mode Sense 6 lah 0 x 0 - 0 0 00 0 0
Load/Unload/Scan/Stop/Start 6 lbh 0 0 o- 0 0 00 - -
Receive Diagnostic Results 6 lch 0 0 00 0 0 00 0 0
Send Diagnostic 6 ldh x x x x x x x x x x
Present/Allow Medium Removal 6 leh 00--o 0 -0 0 -
Set Window 10 24h M__-MMX__-
Get Window 10 25h - - -- - - O_ - -
Read Capacity 10 26h X-_-X X-X_-
Read 10 28h x - - - x x x x - 0
Write 10 2ah x - -- x - o x - -
Seek 10 2bh 0 o - - o 0 -0 0 -
Erase 10 2ch M-_-- _-O_-
Read Updated Block 10 2dh M - _ - O _-O_ _
Write and Verify 10 2eh O - _ - O --O__
Verify 10 2fh o - - - o 0 -0 - -
Search Data High 10 30h 0 - -- 0 0 -0 - -
Search Data Equal 10 32h 0 - -- 0 0 -0 - -
Search Data Low 10 33h o - - - o 0 -0 - -
Set Limits 10 34h 0 - -- 0 0 -0 - -
Synchronize Cache 10 35h 0 - -- 0 0 -0 - -
Lock/Unlock Cache 10 36h 0 - -- 0 0 -0 - -
Read Defect Data 10 37h 0-_-- - - O - -
Medium Scan 10 38h 0 - - o - -
Compare 10 39h 0 0 00 0 0 00 - -
Copy and Venfy 10 3ah 0 0 00 0 ooo--
Write Buffer 10 3bh 0 0 00 0 0 00 0 0
Read Buffer 10 3ch 0 0 00 0 o o o - -
Update Block 10 3dh - 0 - -0 - -
Read Long 10 3eh 0 - -- 0 0 -0 - -
Write Long 10 3fh o---o --(_
Hard Disk Drive Controllers 1203

Command Length” Code Class”


DD TD Pr PD WO CD S C OS MC Co
Change Definition 10 40h 0 0 0 0 0 0 0 0 0 0
.Write Same 10 41h ()____ _----
Read Sub-Channel 10 42h - - -_ - o----
Read Tot 10 43h - - -- - 0 -- - _
Read Header 10 44h - - -_ - 0 -- - -
Play Audio 10 45h - ()----
Play Audio MSF 10 47h - - -- - 0 -_ - _
Play Audio Track index 10 48h - - -- - () -- - -
Play Track Relative 10 49h - ()_-__
Pause/Resume 10 4bh - - -- - IJ -- - -
Mode Select 10 55h 0 0 o- 0 0 00 0 0
Mode Sense 10 5ah 0 0 o- 0 0 00 0 0
Move Medium/Play Audio 12 a5h - - -- - 0 -- x -
Exchange Medium 12 a6h - - - - - --_ 0 -
Read 12 a8h - - -- 0 o - o - 0
Play Track Relative 12 a9h - o----
Write 12 aah 0 - - o - o
Erase 12 ach - - - - - - -0 - _
Write and Verify 12 aeh 0 - - o - -
Verify 12 afh 0 o - o - -
Set Limits 12 b3h 0 o - o - -
Request Volume Address 12 b5h - - - - - - - - 0 -
Read Defect Data 12 b7h ---_- - -0 - _

‘) length of SCSI command in bytes (6-byte. lo-byte, or 12.byte command)


” DD=disk drive, TD=tape drive, Pr=printer, PD=processor dewce, WO=WORM. CD&D-ROM, Sc=Scanner, O&optical
storage. MC=medla changer, Cmommunicatlon device
X=requested, O=optional, M=manufacturer-specific

H.2.2 (i-byte Commands

Test Unit Ready (OOh)


With this command you can determine whether the addressed target drive is ready. If so, the
target completes the command with the status everything o.k. A request sense command returns
only a no status. Note that the status key is valid only after an extended request sense command
to determine the cause of a not-ready state of the addressed drive.
1204 Appendix H

LUN: logical unit number 0 to 7


P: flag
l=return messages with flag, if L=l O=messages without flag
I,: link
l&inked commands O=single commands

Rezero Unit (Olh)

This command moves the target back to the zero position, that is, mostly to the beginning of the
drive. On a hard disk this means that the read/write heads are moved to track 0.

Bit 7 6 5 4 3 211 0
we
0 0 0 0 0 0 0 0 1
1 LUN 1 Reserved
2 Reserved
3 I Resewed
4 I Reserved
5 I RPaPNaii 1 F/I

LUN: logical unit number 0 to 7


P: flag
Lreturn messages with flag, if L=l Ozmessages without flag
IA: link
l-linked commands O=single comnds

Request Sense (03h)

This command instructs the target to return status data about the last executed command to the
initiator. The target aborts the transfer of the status data if all available bytes have been trans-
mitted to the initiator, or if the allocation length is exhausted. Note that the status data is only
valid with a message check status for the preceding command as long as the target has not
received any further command.

The target transfers status data to the initiator during the course of a data-in phase. The status
data consist of an &byte header and additional status bytes in accordance with the preceding
command and the error.

Only with a sufficient allocation length can you be sure that all status bytes are transferred by
the target (specify a value of 255 here ). Whether and, if so, how many additional status bytes the
target transfers in an extended form depends upon the entry ndditional stat~ts let@ in byte 7 of
the status data. Table H.2 shows an example for the status, where the physical location of the
error is indicated. The returned status information is very extensive, so it is not detailed here.
Hard Disk Drive Controllers

LW: logical unit number 0 to 7


Allocation Length: number of bytes which the initiator reserves for the target's status data
054 status bytes (SCSI-I) 0~0 status bytes (SCSI-I I )
1...255: number of status bytes to transfer
P: flag
l-return messages with flag, if L=l O=messages without flag
L: link
l.linked commands O-single cormnands

Header

VAL: valid
l=logical block address (byte 3-6) valid &CBA not valid
Class: error class. for extended status class equal to 7
Error Code: for extended status equal to 0
Status Key: error group, see H.2.4
Logical Block Address: identification of the block where the error occurred
AdditIonal Status Length: number of additional status bytes
Additional Status Bytes (Example)
Byte CCdellt
8 Command Dependent
9 Command Dependent
10 Command Dependent
11 Command Dependent
12 Additional Status Code
13 Extended Status Code
14 FRU
15 val 1 Status Code Dependent
16 Status Code Dependent
17 Ftetnes
16 Physical Cylmder (MSB)
19 Physical Cylinder (LSB)
20 Physical Head
L2’ Physical Sector

Tnble H.2: St&us


1206 Appendix H

Format Unit (04h)

This command formats the whole drive by writing all ID and sector data fields. You must
specify the block size and the geometric drive parameters, such as sectors per track, etc., in
advance by a mode select cornman<. If you do not, the target uses the same parameters as for a
preformatted drive and the predetermined standard parameters for a non-formatted drive. Most
SCSI hard disks contain a so-called manufacturer defect list, stored in one or more reserved
tracks, which is managed by the controller. The target uses this list to correct the known defects
by reassigning blocks. If you reformat a hard disk which has been in use for a long time, it may
be possible that the function of the intelligent bad sector remapping has detected further defects
and has repaired them by reassigning blocks in the background. Such defect entries are called
a grown defect list, and are also stored in reserved tracks by the controller. In a format operation
the initiator may further transfer additional defect parameters in a data-out phase. The data
transferred by the initiator consists of a 4-byte header and zero or more 4-byte defect descriptors,
whose structure is shown in Table H.4. The format command can be executed in one of three
modes, which is determined by the bits FMT and CMP (Table H.3).

Bit 7 6 5 4 3 2 1 0
We
0 1 0 0 0 0 0 1 ~
1 1 L U N jFMT)X&+ef&FomMt

In??: logical unit number 0 to 7


FMT: format data
CMP: complete format mode, see Table H.3
Defect Porn: defect list format
Interleave: interleave value
O.atandard value (normally equal I)
valid values: 1 to (sectors per track - 1)
P: flag
l=return messages with flag, if I,.1 O=messagea without flag
I,: link
l=linked conrmanda O=single commands
P: flag
l=return messages with flag, if I,=1 O.messagea without flag
I,: link
l=linked commnds O-single commands
Hard Disk Drive Controllers 1207

FMT CMP ;;le;i :o;mat Corn- Description


mand

0 x x x x P&G Formatting with primary and grown defect list:


no data-out ohase wtth defect list from initiator

1’1°1 Oxx I I P&G&i Formatting with primaly. grown and defect list from
nit&or: data-out phase with defect list from initiator. I

I ‘I ‘I Oxx I p I Formatting with primary defect Ins! only; grown defect list is ignored;
no data-out phase with defect list from initiator. I

Table H.3: FMT, CMP and defect list

Header

The entry length of defect list indicates the total number of bytes in the following defect descriptors

Descriptor
Byte Content
0 Defect Block Address (MSB)
1 Defect Block Address
2 Defect Block Address
3 Defect Block Address (LSB)
1

Table H.4: fnitiator defect list

Reassign Blocks (0%)

This command instructs the target to replace defect logical blocks by intact blocks in a certain
area of the drive which is reserved for this pupose. The initiator passes to the target a defect
list which contains the blocks to reassign. The defect blocks are thus mapped to intact blocks so
that all further accesses are diverted to the intact blocks. The data in the defect blocks is lost.
If the capacity of the drive is not sufficient to reassign all specified defect blocks, the command
aborts with a check status and the error key is set to medium error. The target automatically adds
all blocks reassigned by this command to the known defect list. The defect list, which is trans-
ferred in a data-out phase by the initiator, consists of a 4 byte header followed by one or more
defect descriptors with a length of 4 bytes each. The structure of head and descriptor is shown
in Table H.5.
1208 Appendix H

LUN: logical unit number 0 to 7


P: flag
l=return messages with flag, if L=l O=messages without flag
LX: link
l=linked comands O=single commands

Descriptor

w Lenoth of Defect List lLSR\

The entry length of defect list indicates the total number of the bytes in the following defect descriptors.
Descriptor

0 Defect Lo ical Block Address MSB


fi
3 Defect Loaical Block Address fLSBI

Read (08h)

This command instructs the target to read one or more blocks from the drive, and to transfer
the data in a data-in phase to the initiator.

‘4 I Transfer Length
5 j Reserved j F / L
Hard Disk Drwe Controllers 1209

Lmi: logical unit number 0 to I


Logical Block Address: number of block to read first
Tranefer Length: number of logical blocks to read
F: flag
l=retum messages with flag, if L-1 O=messages without flag
L: link
l=linked comnands O=single commands

Write (Oah)

This command instructs the target to receive one or more blocks from the initiator in a data-out
phase, and to write them onto the medium.

3 ) Logical Block Address (LSB)


4 / Transfer Length
5 I Rnserved IFll

LITN: logical unit number 0 to 7


Logical Block Address: number of block to write first
Transfer Length: number of logical blocks to write
P: flag
l=return messages with flag, if L=I. Oenessages without flag
L: link
l=linked commands O=single commands

Seek (Obh)

This command positions the target at the specified logical block. In the case of a hard disk, the
read/write head is moved to the track which contains the corresponding block (sector).

Bit 7 6 5 4 3 2 1 0
Byte I

LUN: logical unit number 0 to 7


Logical Block Address: number of the block where the target is to be positioned
P: flag
l=return messages with flag, if L-1 O=message8 without flag
L: link
l-linked commands O=single commands
1210 Appendix H

Inquiry (12hl
This command transfers target parameters to the initiator in a data-in phase. The inquiry para-
meters comprise a 5 byte header and additional information. The format is shown in Table H.6.
The target aborts the data-in phase as soon as all target parameters have been transferred or the
reserved bytes are exhausted. The additional information depends upon the type and manu-
facturer of the target, and typically indicates the manufacturer’s name, the product name, the
version number, and the serial number. Therefore the length of the additional information is
manufacturer-dependent; SCSI host adapters use the inquiry command for initialization, and in
many cases display the additional information on-screen during the course of the boot procedure.

r,u?r: logical unit number 0 to 7


Allocation Length: number of bytes which are reserved by the initiator to receive the target
parameters; a value of 0 means that no target parameters are transferred
P: flag
l=return messages with flag, if L=l O=meesages without flag
L: link
l=linked commands O=single commands

Unit Type Code: OOh=LUN 0 7fh=else


RMB: removable medium bit
l-medium removable (e.g. tape drive, optical drive)
O=Medium not removable (e.g. hard disk)
ISO, ECMA, ANSI: revision level of the implemented standard according to ISO, ECMA or
ANSI (OOh=SCSI-I, Olh=SCSI-I with CCS, OZh=SCSI-II); most SCSI
drives use the ANSI standard

Table H.6: Target parameters


Hard Disk Drive Controllers 1211

AEN: l=Unit supports asynchronous message transfer (processor devices only)


TIO: l=target supports message abort /IO process
Data Format: OOh=SCSI-I, Olh=SCSI-I with CCS. OZh=SCSI-II
Additronal Length: number of following additional information bytes
ret unit supports relative addressrng
W32fWl6: unit supports 32-bit and 16-bit wide SCSI. respectively
Sync: unit supports synchronous transfer mode
Link. unit supports linked commands
Quel unit supports SCSI command queueing
SftR: unit supports a soft reset
Manufacturer/Model/Revision: ASCII string with thus information

Table H.6: cont.

Mode Select (15h)

This command enables the initiator to set or alter the target parameters. The initiator transfers
a list of mode parameters to the target in a data-out phase. The list comprises a 4 byte header
which may be followed by a block descriptor and zero or more page descriptors. In Table H.7
you can see their formats. Each page descriptor holds information for the target concerning a
certain function class, the descriptions of which are shown in Table H.8. The descriptors can be
transferred in any order, and the target uses class-specific standard settings if no descriptor is
passed for a class. Many parameters depend upon the drive type and the manufacturer, so that
no generally valid statements are possible.

LUN: logical unit number 0 tcl 7


PP: page famat (ignored in most cases as the mode select Darameters are always Drocessed in
page format)
l=Dage fO=t
SP: save mode parameters (ignored in most cases as the mode select parameters are always
stored by the target)
l=Ba"e DF02J‘,~te,?S O.do not save
Length of Parameter List: number of mode select data bytes
P: fl.xfP l=return mesaages with flag, if L=l O=messages without flag
L: link
l.linked commands O=single commands
1212 Appendix H

Header

Data Length: length of the complete parameter list


Medium Type: OOh=hard disk
Block Descriptor Length: length of the following block descriptors in bytes

Block Descriptor

Density Code: medium density (OOh=hard disk)

Page Descriptor Head

.I seebelow
Page Code.
OOh=operatlon parameters (dependent upon drwe type and manufacturer)
01 h=error recovery parameters
OZh=disconnect parameters
03h=formattirg parameters
04h=geometrlc parameters
OSh=floppy disk parameters
06h=parameters for optical storage
07hwerify error parameters
08h=cache parameters
09h=parameters for peripheral unit
Oah=control parameters
Obh=medlum type
Och=parameters for zones of equal sector/track number (notch)
Odh=CD-ROM data parameters
Oeh=CD-ROM audio parameters
lOh=conf~guration parameters
11 h=partltlon parameters 1
12h=parUt1on parameters 2
13h=partltlon parameters 3
14h=partltlon parameters 4
leh=drive geometry
lfh=funct~on parameters
otherweserved
Page Length- length of the page (entries 0 to n) m bytes

Tnhlr H.7: Mode select pammeters


Hard Disk Drive Controllers 1213

Among the huge number of parameter pages, I will present some of them in the following by
way of an example.

Disconnect Parameters (Page Code=02h, Page Length=Oeh)

Buffer Fill Ratio: fill ratio for the buffer tn units of l/256, at
which the target attempts for read
processes to reconnect to the initiator
Buffer Empty Ratio: fill ratio for the buffer In units of l/256,
below which the target attempts for
write processes to reconnect to the
initiator
Max. Bus tdle Time: max. occupation time (In untts of 100 ps)
of the bus by the target without the need
for executing a REQ/ACK sequence
Min. Bus Idle Time: min. time period (in units of 100 ps) which
the target must wait after a bus
occupation, before it issues a new bus
arbitration
Max Connect Time: max. occupation time (in units of 100 1s) of the bus by the target
Max. Burst Length: max. number of 512.byte blocks which the target can transfer in one instance
DTDC’ data transfer disconnect control
OOb=disconnection always possible, 01 b=after data transfer initiation, do not free the
bus until data transfer is complete, lOb=reserved, 11 b=after data transfer initiation, do
not free the bus until the command is complete
Formatting Parameters (Page Code=OBh, Page Length=lGh)

’ 6 Spare Tracks per LUN (t&B)


9 Spare Tracks per LUN (LSB)
10 Sectors per Track (MSB)
11 Sectors per Track (LSB)
12 Bytes per Sector (MSB)
13 Bytes per Sector (LSB)
14 Sector Interleave (MSB)
15 _Sector
_ Interleave
_ (LSB)
16 Track Interleave (MSB)
17 Track Interleave (LSB)
I6 Cyltnder Interleave (MSB)
19 Cylinder Interleave (LSB)
20 S-SC [HSC IF&W3 ISRF r Reserved
21 Reserved
22 Reserved
-23 Reserved
1214 Appendix H

SSC: soft sector (l=drive with soft sector format)


HSC: hard sector (l=drive with hard sector format)
RMB: drive with removable medium
SRF: enumerate blocks surface by surface
Geometry Parameters (Page Code=O4h, Page Length=1 6h)

123 1 Reserved

Table H.8: cont.

Reserve (16h)

This command reserves the corresponding logical unit for a SCSI device. This command,
together with release, is the base for preventing access conflicts in systems with several initiators
(host adapters). The command has two modifications: with a cleared MY bit the logical unit is
reserved for the initiator of the command; on the other hand, if PTY is set the unit is reserved
for a third initiator, which is characterized by the SCSI ID. The complete logical unit and not
just one block is affected by the reservation, which can only be cancelled by a release command
of the corresponding initiator, by a reset message, or by a hardware reset.
Hard Disk Drive Controllers 1215

logical unit number 0 to 7


l=reservation for a third initiator
Ozreeervation for the current initiator
ID: SCSI ID of the third unit for which the LW is reserved if PTY is set
flag
l=return messages with flag, if L=l O=messages without flag
liti
l=linked commands Ozsingle commands

Release (17h)

This command cancels the reservation of a logical unit for the initiator. If the unit has been
reserved by a command from a third device the reservation can be cancelled only by a release
command from.the same initiator. For this the unit ID has to match the ID of the initiator that
issued the reserve command before.

LW: logical unit number 0 to 7


PTY: l=reservation for a third initiator
O=reservation for the current initiator
Unit ID: SCSI ID of the third unit for which the LUN was reserved if PTY is set
P: flag
l=return messages with flag, if L=l O=messages without flag
L: link
lzlinked commands O.single commands

Mode Sense (lab)

This command returns the medium and drive parameters of the target. By means of certain page
parameter values, you can determine all changeable parameters and standard values for the
parameters. The status data is transferred from the target to the initiator in a data-in phase. The
status data comprises a 4 byte header followed by zero or more block descriptors, and eventu-
ally additional drive parameters. Their formats are shown in Table H.7. The structure of the
pages is indicated in Table H.8.
1216 Appendix H

Bit 7 6 5 4 3 2 1 0
we

4 I Allocation Length
5 / Reselved 1 F/L

LUN: logical unit number 0 to 7


DBD: disable block descriptors
l-transfer pages only
PGP: returned page parameter values
OOb.cu+rent values Ol=changeable values
lOb=standard values llb=saved values
Allocation Length: number of bytes which are reserved by the initiator for the mode data
F: flag
l=return messages with flag, if L=l O=messages without flag
L: link
l=linked commands Ozsingle commands

Start/Stop (lbh)

This command instructs the target to move the heads into transport position, or to move the
heads out of this position. On many drives, additionally the spindle motor is switched off or on.

LIJN: logical unit number 0 to 7


IMM: inmediate
l=status is transferred immediately after the beginning of the command execution
O=status is transferred after command completion
STR: start
lzposition head on track 0 or equivalent track
O=move head into transport poeition
P: flag
l=return messages with flag, if L=l O=messages without flag
L: link
l-linked commands O=single commands

Send Diagnostic (ldh)

This command instructs the target to execute a self-test. With the DvO and UnO bits you can
avoid other units, or the addressed LUN itself, being affected by this test. Then, the self-test is
only executed if the state of this (or these) unit(s) is not changed. The function returns a diag-
nostic page.
Hard Disk Drive Controllers 1217

Bit 7 6 5 4 3 2 1 0
W
0 0 0 0 1 1 1 0 1
1 LUN IPF jres IST ~DuojU1-10
2 Resewed
3 Allocation Length
4 Allocation Length
I

IJJN: logical unit number 0 to 7


PP page format
l=SCSI-II O.SCSI-I
ST: self-test
1=issue self-test
DvO: device off-line
l.the target may execute the self-test, even if other LUNs are affected by this
oncl: unit off-line
l=the target may execute the self-test, even if the addressed LUN is affected by this
P: flag
kreturn meesages with flag, if ~=l O=measages without flag
L: link
l.linked commands O=single commands

Diagnostic Page

H.2.3 IO-byte Commands

Read Capacity (25h)

The target returns information concerning the drive’s capacity to the initiator. There are two
execution forms of the command: if the PM1 bit is cleared, the command transfers the logical
block address (LBA) and the block length of the last logical block on the drive. LBA in the
command code has to be equal to 0 in this case. If the PM1 bit is set, the target transfers the LBA
and the block length of the last logical block after the LBA in the command, after which a
significant delay in data transfer occurs. This can be a cylinder boundary which requires a
repositioning of the head. The capacity information is transferred during the course of a data-
in phase. Table H.9 gives the structure of the capacity information.
1218 Appendix H

Bit 7 6 5 4 3 2 1 0
BY-

Lu?J: logical unit number 0 to 7


rel: l=relative block addressing
PMI: partial medium indicator
lzlogical block addrees and block length of last block before a significant datatransfer
delay occurs
O.logical block address and block length of last block
P: flag
l.return messages with flag, if L=l O=measages without flag
L: link
l=linked commands Ozaingle commands

Capacity Information

Toable H.9: Capacity information

Extended Read (28h)

This command instructs the target to read one or more blocks from the drive, and to transfer
the data in a data-in phase to the initiator. Unlike the normal reading of a block, here the logical
block address comprises 32 bits and the transfer length 16 bits. Thus you can access volumes
with a capacity of 4G blocks and read 64k blocks all at once.

e
Hard Disk Drive Controllers 1219

LUN: logical unit number 0 to 7


DPO: disable page output
l-read data are not transferred into target cache
Fm: force unit access
l=target must read data from volume even if the block is available in the target cache
rel: l-relative block addressing
Logical Block Address: number of the first block to read
Transfer Length: number of logical blocks to read
P: flag
l-return messages with flag, if LII O=messages without flag
L: link
l.linked colomands O=single commands

Extended Write (Zah)

This command instructs the target to receive one or more blocks in a data-out phase from the
initiator, and to write them onto the medium. Unlike the normal writing of a block, here the
logical block address comprises 32 bits and the transfer length 16 bits. Thus you can access
volumes with a capacity of 4G blocks and write 64k blocks all at once.

Bit 7 6 5 4 3 2 1 0
Bvte

4 I LcqmlBlock Address
5 / LogicalBlockAddress(LSB)

LW: logical unit mmber 0 to 7


DPO: dieable page o"tD"t
l=write data is not transferred into the target cache
FUA: force unit acc.3se
l.target must write data onto medium even if the block is available in the cache
Tel: lzrelative block addressing
Lcaical Block Address: number of the block to write first
Transfer Length: number of logical blocks to write
P: flag
l.return messages with flag, if ~=l O=meaaeges without flag
L: link
l.linked commands o=singh 03-nas
1220 Appendix H

Extended Seek (Zbh)

This command moves the target to the specified logical block. In the case of a hard disk drive,
the read/write head is positioned on that track which contains the corresponding block (sector).
Unlike the normal seek, here the, logical block address is 32 bits wide. Thus you can access
volumes with a capacity of 4G blocks.

Bll 7 6 5 4 3 2 1 0
Byte
0 0 0 1 0 1 0 1 1
1 LUN 1 Reselved
2 Logical Block Address (MSB)
3 Logml Block Address
4 Loqical Block Address
5 Logical Block Address (LSB)
6 Resewed
7 Reserved
6 Reserved
0 IF II

LuN: logical unit number 0 to 7


Logical Block Address: number of the block where the drive is to be positioned
F: flag
l=return messages with flag, if L=l Oznessages without flag
L: link
l=linked commands O=single commands

Write and Verify (Zeh)

This command instructs the target to write the data received from the initiator in a data-out
phase onto the medium. Afterwards, the target has to verify whether the data has been written
correctly. With the CHK bit you can choose between two different verify modes. With the CHK
bit cleared the target verifies the write operation by comparing the written data with the data
which has been transferred by the initiator before. If CHK is set, the target only performs a
medium verification, that is, the target only checks whether the ECC bytes conform to the
written data. If the verification leads to an error, the status key is set to compare error.

3 Logical Block Address


4 Logical Block Address
5 LogIcal Block Address (LSB)
- 6 Reserved
7 Transfer Length (MSB)
a
Hard Disk Drive Controllers 1221

LVN: logical unit number 0 to 7


CHK: byte check
l=verify by comparison O=medium verification only via ECC
Logical Block Address: block to start write and verification with
Transfer Length: number of logical blocks to write and verify
F: flag
l=return messages with flag, if L=l O=mesaages without flag
L: link
l=linked commands Oaingle commands

Verify (Zfhl
This command instructs the target to verify the data written onto the medium. Using the CHK
bit, you can choose between two different verify modes. With the CHK bit cleared the target
verifies the write operation by comparing the written data with data transferred by the initiator
in a data-out phase. If CHK is set the target only performs a medium verification; the target only
checks whether the ECC bytes conform to the written data. If the verification leads to an error,
the status key is set to compare error. The command is similar to write and vet+), but the data
transferred with a cleared CHK bit is not written onto the medium.

LUN: logical unit number 0 to 7


CHIC: byte check
l.verify by comparison O.medium verification only via ECC
Logical Block Address: block where to start verification
Transfer Length: number of logical blocks to verify
P: flag
l.return messages with flag, if L=l O.messages without flag
L: link
l.linked commands 0=aingle commands

Read Defect Data (37hl


This command instructs the target to transfer the medium defect data stored on the medium to
the initiator in a data-in phase. The defect data comprises a 4 byte header and (depending upon
the P and G bits of the command) a defect list, or additionally a reassign list, which indicates the
reassignment of the defect blocks. The reassign list is passed after the defect list. In this case,
defect and reassign lists are separated by four bytes of value ffh. Table H.10 gives the corres-
ponding formats.
1222 Appendix H

UJN: logical unit number 0 to I


P: l=tranefet manufacturer defect list only
0: grown defect list (bit is valid only if P is also set)
l=tranefer defect list added by host and entries about the reassigned blocks
Allocation'Length: number of bytes which the initiator has reserved for the defect data to be
transmitted
I?: flag
l-return messages with flag, if L=l O=messages without flag
L: link
l=linked commands O=single commands

Header

i 1 reserved 1 P 1 G / Resewed
2 j Length of Defect List (MSB)
I Lenoth of Defect List (LSB)

P. G: type of transferred defect list


lO=defect list only
1 l=defect list and reassignment list
00, Ol=invalid
Length of Defect List: defect list length ir! bytes

Defect Entry
Hard Disk Drwe Controllers 1223

Reallocation Entry

Table H.lO: cont.

Write Buffer (3bh)


This command instructs the target to write the data transferred by the initiator in a data-out
phase into its buffer memory. The transferred write data comprises a 4 byte header and the
write data itself. The header format is shown in Table H.ll.

Resewed
Reserved
Reserved

LON: logical unit number 0 to 7


Allocation Length: number of max. transferred data including header which is stored by the
target
P: flag
lzreturn messages with flag, if L=I O.messages without flag
L: link
l.linked commands O=single commands

Buffer Data Header


1224 Appendix H

Read Buffer (3ch)

This command instructs the target to transfer the indicated number of bytes in a data-in phase
from its buffer memory to the initiator. The transferred read data comprises a 4-byte header and
the read data itself. The header format is shown in Table H.12.

R e s e r v e d _ _
Resewed
Reserved
Reserved
Reserved
Allocation Lenglh (MSB)
Allwabon Lenqth (LSB)
1 - I

LUN: logical unit number 0 to I


Allocation Length: max. number of data transferred by the target including header
l=return messages with flag, if L=l Osnessages without flag
L: link
l=linked commands O=single commands

Buffer Data Header


Byte content
0 Reserved
1 Resewed
2 Available Space (MSB)
3 Available Space (LSB)

Read Long (3eh)

This command reads one or more blocks together with the ECC bytes from the target and
transfers them in a data-in phase to the initiator. No error check and error correction is carried
out by the target by means of the ECC bytes.

Bit 7 6 5 4 3 2 1 0
Byte
0 0 0 1 1 1 1 1 0
1 LUN 1 DFO IFUA] Reservad~ rel
2 Logical Block Address (MSB)
3 LogIcal Block Address
4 Logical Block Address
5 Logical Block Address (LSB)
- 6 Reserved
7 Transfer Length (MSB)
6 Trawler Lenqth (LSB)
q RP~F)NLd /F/I
Hard Disk Drive Controllers 1225

LUN: logical unit n u m b e r 0 to 7


DPO: disable page output
laead data is not transferred into the cache
FDA: force unit access
lztarget must read the data from medium even if the block is available in the cache
rel: l-relative block addressing
Logical Block Address: number of the block to read first
Transfer Length: number of logical blocks to read
P: flag
lrreturn messages with flag, if L-l Ozmessages without flag
L: link
l=linked commands O=single commands

Write Long (3fh)

This command instructs the target to receive one or more blocks together with the ECC bytes
from the initiator in a data-out phase, and to write them onto the medium. The target doesn’t
generate the ECC bytes itself, but writes the data transferred by the initiator without any change
onto the medium.

Bit 7 6 5 4 3 2 1 0
we

LDN: logical unit number 0 to 7


DPO: disable page output
la-rite data is not transferred into the cache
FDA: force unit access
l-target must write data onto the medium even if the block is available in the cache
rel: lzrelative block addressing
Logical Block Address: number of the block to write first
Transfer Length: number of logical blocks to write
F: flag
l=return messages with flag, if L=l O=messages without flag
L: link
lzlinked commands Ozsingle commands
1226 Appendix H

Change Definition (40hl

This function switches a SCSI-II target to a behaviour according to an earlier SCSI specification.

Parameter List Length


0 I ~^^^^...A I E

LuN: logical unit number 0 to I


S: save bit
l=save changes
SCSI version: OOhanchanged, Olh=SCSI-I, OZh=SCSI-I with CCS, 03h=SCSI-II
Length of Parameter List: number of passed bytes (manufacturer-dependent)
F: flag
l=return messages with flag, if L=l O.messages without flag
L: link
lzlinked commands O=single commands

Mode Select (55hI

This command enables the initiator to set or alter the target parameters. The initiator transfers
a list of mode parameters to the target in a data-out phase. The list comprises a 4 byte header
which may be followed by a block descriptor and zero or more page descriptors. In Table H.7
you can see their formats. Each page descriptor holds information for the target concerning a
certain function class, the descriptions of which are shown in Table H.8. The descriptors can be
transferred in any order, and the target uses class-specific standard settings if no descriptor is
passed for a class. Many parameters depend upon the drive type and the manufacturer, so that
no generally valid statements are possible.
Hard Disk Drive Controllers 1227

Lutz: logical u n i t number 0 t o 7


PF: page format (ignored in most cases as the mode select parameters are always processed in
page format)
l=*age format
SP: save mode parameters (ignored in most cases as the mode select parameters are always
stored by the target)
I.=save parameters O-do not save
Length of Parameter List: number of mode select data bytes
F: flWP
l=return messages with flag, if L=l O=messages without flag
I,: link
l=linked commands O=single commands

Mode Sense (lab)


This command returns the medium and drive parameters of the target. By means of certain page
parameter values, you can determine all changeable parameters and standard values for the
parameters. The status data is transferred from the target to the initiator in a data-in phase. The
status data comprises a 4 byte header is by zero or more block descriptors, and eventually
additional drive parameters. Their formats are shown in Table H.7. The structure of the pages
is indicated in Table H.8.

LUN: logical unit number 0 to 7


DBD: disable block descriptors
l=transfer pages only
PGP: returned page parameter values
OOb.current values OLchangeable values
lOb.standard values llb=saved values
Allocation Length: number of bytes which are reserved by the initiator for the mode data
F: flag
lzreturn messages with flag, if L=l Oanessages without flag
I,: link
l.linked commands O=single commands
1228 Appendix H

H.2.4 Status Key

Key Meaning Cause

Oh no status no special status information necessary


I
lh corrected error last command completed successfully after
recovery procedure of target
2h not ready drive cannot be accessed
3h medium error command aborted because of an uncorrectable
error; cause probably bad medium
4h hardware error target detected an uncorrectable hardware-
error of controller, drive, etc.
5h invalid request invalid parameter in command descriptor
block or in the addrtional parameters
6h attention/reset reset occurred since the last selection by the inrtiator
7h data protected the data on the volume is protected
against the current access
8h blank check unexpected access to certain parts of the medium
9h reserved for manufacturer (the manufacturer may use this code for own purposes)
ah copy operatron aborted the copy operation between initiator and
target has been aborted
bh command aborted the current command has been aborted
ch equal search command encountered data pattern
dh volume overflow the volume is full
eh compare error an error occurred during a verify operation
fh reserved

H.2.5 Additional Status Codes

Code Meaning
OOh no status Information
Olh no index or sector srgnal
02h no seek signal
03h write error
04h drive not ready
05h no response of LUN
06h track 0 not found
07h several units selected
08h LUN error
09h error in seek unit
Oah error counter overflow
Och write error
10h CRC or KC error in ID
llh uncorrectable read error of data blocks
12h no address mark found in ID field
13h no address mark found rn data field
14h no data record found
15h seek error
16h rncorrect data synchronizatron
17h recovered data after retries of target without ECC correctron
Hard Disk Drwe Controllers 1229

Code Meaning
18h recovered data after ECC correction by target (without retries)
19h error in the defect list
lah parameter overflow
lbh error during synchronous data transfer
lch primary defect lrst not found
ldh compare error
leh recovered ID after ECC correction by target
2Oh invalid command code
2lh Invalid logical block address LEA; address bigger than read drive capacity
b 22h rnvalrd function call
24h invalid entry in command descriptor block
25h invalid logical unit number LUN
26h invalid entry in parameter list
27h wrote protection
28h medium change
29h power-on or reset or bus-reset occurred
2ah mode select parameters changed
2bh copy process not possible
: 2ch command linking not possible
* 2dh overwrite error
2fh command aborted by other inrtiator
3oh incompatible medium
31h rnvalrd format
32h no spare sector available for defect sector
33h incorrect tape length
36h printer rrbbon defect
t 39h parameter cannot be saved
no volume inserted
medium error
invalid identify message
LUN not configured
changed operatron conditions
RAM error
data path error
power-on dragnostics error
message error
Internal controller error
error rn selectron or reselection phase
unsuccessful software reset
47h parity error of the SCSI Interface
48h rnrtiator has detected an error
49h rnvalrd defect list
4ah command phase error
4bh data phase error
4ch self-configuration of LUN farled
4eh command overlap
5Oh seek error dunng write
51h erase error
52h cassette error
53h medium change error
54h SCSI/host Interface error
1230 Appendix H

Code Meaning

55h system error


57h directory not recoverable
59h updated block read
5ah condition change by user
5bh usage counter error
5ch drive spindle
60h beam source error
61h video error
62h seek error of sense head
63h end of data area
64h Invalid track mode
80h-ffh reserved for manufacturer’s own codes (for example error
codes of the controller diagnostics routines)

H.3 ASPI Programming Interface


Adaptec’s Advanced SCSl Programming Interface (ASPI) provides seven functions for making an
access to the SCSI host adapter. Section H.3.1 summarizes there ASPI functions, together with
the function codes.

H.3.1 ASPI Functions

Code Function
OOh host adapter Inquiry
Olh get device type
02h execute SCSI command
03h abort SCSI command
04h reset SCSI devrce
05h set host adapter parameters
06h get disk drive information

H.3.2 SCSI Request Block

Usually, ASPI is present as a driver loaded when your PC is booted. You may use the seven
ASPI functions listed in Section H.3.1 by placing the segment and offset (in this order) of a
so-called SCSI Request B/o& (SRBJ on the stack. The structure of the first eight SRB bytes is the
same for all ASP1 functions. The remaining bytes (if present) depend upon the ASP1 function.
In the following I will summarize the SRB structure for the each ASP1 function (I = input para-
meter, 0 = output parameter).

Host Adapter Inquiry (OOh)

This function provides information regarding the addressed host adapter.


Hard Disk Drive Controllers 1231

We Input/ Content
output
OOh I OOh (host adapter rnqurry)
Olh 0 status (see H.3.3)
02h I host adapter number*’
03h reserved
04h..07h reserved
08h 0 number of Installed host adapters
09h 0 SCSI ID of host adapter
Oah..l9h 0 ASPI manager name
lah..29h 0 host adapter name
2ah..39h 0 parameter, dependent upon adapter

*I 1st adapter. 0; 2nd adapter. 1, etc.

Get Device Type (Olh)

This function returns information similar to the SCSI inquiry command.

Byte Input/ Content


output

OOh I 01 h (get device type)


Olh 0 status (see H.3.3)
02h I host adapter number*’
03h reserved
04h..07h reserved
08h I SCSI ID of target
09h I LUN
Oah 0 SCSI device class of target/LUN

*I 1st adapter: 0. 2nd adapter: 1 etc.

Execute SCSI Command (02h)

This function instructs the host adapter to execute the corresponding SCSI command

Byte Input/ Content


output

OOh 02h (execute SCSI command)


Olh status (see H 3.3)
02h host adapter number”
03h brt 0 : P O S T , brt 1 Irnk, 2 .3: drrectron”,
brts 4 .7: reserved
04h..07h reserved
08h ID of target
09h LUN
Oah..Odh data buffer size (allocatron length)
Oeh srze I1 of sense data rn bytes
1232 Appendix H

We Input/ Content
output
Ofh..lZh I segment: offset of data buffer
13h..l6h I segment:offset of SRB link
17h I 8 we 12 of SCSI command In bytes
18h 0 host adapter statu?
19h 0 target stat&
lah..ldh I segment:offset of POST
leh..3fh depending upon operating system
40h..40h+l2-1 I SCSI command
40h+12. 40h+l2+11-1 0 sense data

” 1st adapter: 0; 2nd adapter: 1, etc.


21 POST: l=use POST routine. O=SRB for sense request. link. l=SRB llnk points to next SRB of an SRB chain, O=no m o r e
S R B Ilnks; direction: OOb = determlned by SCSI command, 01 b=SCSI target-thost, lOb=host+SCSI target, 11 b=no data
transfer
3’ OOh=no error, 1 lh=no target response (time-out). 12h=data overflow/underflow. 13h=unexpected bus free phase,
14h=bus phase error of target, 1 S..ffh=reserved
” OOh=no target status, OZh=sense data available, 08h=addressed LUN busy. 18h=reservatlon conflict

Abort SCSI Command (03h)

This command attempts to abort the current SCSI command. Note that this command always
returns a status o.k. in the allocated SRB, although the current command returns its status in its
own SRB. Thus, the current command is successfully aborted only if the code 02h appears in the
status field of its SRB (see Section H.3.3). Eventually, the abort attempt must be repeated.

We Input/ Content
output
OOh I 03h (abort SCSI command)
0th 0 status (see H.3.3)
02h I host adapter number*’
03h reserved
04h..07h reserved
08h..09h I offset of SRB for the command to be aborted
oah-obh I segment of SRB for the command to be aborted

*’ 1st adapter: 0; 2nd adapter, 1. etc


Hard Disk Drive Controllers 1233

Reset SCSI Device (04h)


This command resets a certain SCSI device.

We Input/ Content
output
OOh I 04h (reset SCSI device)
Olh 0 status (see H.3.3)
02h I host adapter number”
03h reserved
04h..07h reserved
08h I target ID
09h I LUN
Oah..l7h reserved
18h 0 host adapter status”
19h 0 target status3)

‘) 1st adapter: 0; 2nd adapter: 1. etc


‘I OOh=no error, 11 h=no target response (tme-out), 1 Zh=data overflow/underflow, 13h=unexpected bus free phase,
14h=bus phase error of target. 15h..ffh=reserved
‘) OOh=no target status, OZh=sense data mallable, 08h=addressed LUN busy. 18h=reservatlon conflict

Set Host Adapter Parameters (05h)


This function sets the parameters for a certain host adapter. The parameter values and their
meanings depend upon the adapter.

We Input/ Content
output
OOh I 05h (set host adapter parameters)
Olh 0 status (see H.3.3)
02h I host adapter number”
03h reserved
04h..07h reserved
08h..17h I dependent upon the host adapter

‘I 1st adapter, 0. 2nd adapter 1, etc


1234 Appendix H

Get Disk Drive Information (06h)

This command instructs the addressed drive to transfer its parameters.

We InpuV Content
output

OOh I 06h (get disk drive information)


Olh 0 status (see H.3.3)
02h I host adapter number”
03h reserved
04h .07h reserved
08h I target ID
09h I LUN
Oah 0 dnve flag2’
Obh 0 drive number for INT 13h3’
Och 0 preferred head translatior?
Odh 0 preferred sector translatior?
Oeh-17h reserved

’ 1st adapter. 0. 2nd adapter. 1. etc.


’ bits 7..2: reserved, bits 1 .O. OOb=drwe cannot be accessed via INT 13h (access only via ASPI), Olb=dwe can be accessed
via INT 13h and is managed by DOS, lOb=drlve can be accessed via INT 13h but is not managed by DOS, 1 lb=reserved
3J number (OOh..ffh) which addresses the drive with INT 13h (only valid If drive flag equal to xu.xxxOlb or xxxxxxlob)
” preferred parameters drive heads and sectors per track for the translation of logical to physical geometry.

H.3.3 ASPI Status Codes

Status Meaning

OOh ASPI rn progress


Olh function completed successfully
02h functron aborted by host command
03h SCSI command cannot be aborted
04h general error
80h rnvalrd SRB f o r m a t
81h invaird host adapter specified
82h SCSI target not found

You might also like