Professional Documents
Culture Documents
Hard Disk Drives Controllers
Hard Disk Drives Controllers
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.
- 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
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
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
Command Phase
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
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
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
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
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
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
Command Phase
~
Cylinder LSB (114h) C7 Cc C, C4 C, C, C, Co
Result Phase
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
~~
Result Phase
~1
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
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
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.
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
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
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
DRV: drive
l=slWJe o=master
Result Phase
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
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 ,
DR”: drive
l.SlaVe o=master
Result Phase
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
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
LSB characterizes the least significant byte, MSB the most significant byte of a multiple byte
quantity.
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
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
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
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
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
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
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
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
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
Descriptor
The entry length of defect list indicates the total number of the bytes in the following defect descriptors.
Descriptor
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
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.
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
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.
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.
Header
Block Descriptor
.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
Among the huge number of parameter pages, I will present some of them in the following by
way of an example.
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)
123 1 Reserved
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
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.
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
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.
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
Diagnostic Page
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-
Capacity Information
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
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)
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
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.
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.
Header
i 1 reserved 1 P 1 G / Resewed
2 j Length of Defect List (MSB)
I Lenoth of Defect List (LSB)
Defect Entry
Hard Disk Drwe Controllers 1223
Reallocation Entry
Resewed
Reserved
Reserved
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
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
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
This function switches a SCSI-II target to a behaviour according to an earlier SCSI specification.
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
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
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
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).
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
This function instructs the host adapter to execute the corresponding SCSI command
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
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
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)
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
We InpuV Content
output
Status Meaning