home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Unsorted BBS Collection
/
thegreatunsorted.tar
/
thegreatunsorted
/
programming
/
misc_programming
/
hd.doc
< prev
next >
Wrap
Text File
|
1990-01-04
|
27KB
|
780 lines
Chapter 7
Fixed Disk Service (INT 13H)
----------------------------
1. Introduction
1.1 Disk Controller Basic Function
1.2 Standard Disk Interface
A. ST-506/412 Winchester
B. Enhanced Small Device Interface (ESDI)
C. Storage Module Device (SMD)
D. Enhanced SMD
E. Small Computer Systems Interface (SCSI)
F. Intelligent Peripheral Interface (IPI)
G. AT-Bus
1.3 Coding
A. Frequency Modulation (FM)
B. Modified Frequency Modulation (MFM)
C. Run Length Limited (RLL)
D. Group Code Recording (GCR)
E. Zone Bit Recording (ZBR)*
1.4 Data Format
1.5 Sector Interleaving
1.6 Disk Formatting
A. Physical Format
B. Partitioning
C. Logical Format
1.7 Translative Versus Non-Translative Mode
2. Winchester Disk Controller
2.1 System Configuration for Fixed Disk System
2.2 I/O Port Definition
2.3 Timing Consideration
3. Programming Sequence in Fixed Disk Service Program
4. SPEC
5. Q & A
1.1 Basic Function of a Disk Controller
1. Write data to the disk
2. Read data from the disk
3. Serialize and de-serialize data
4. Control the disk drive (option)
5. Ensure data integrity
6. Provide reasonable system interface (option)
7. Buffer data to/from disk
1.2 Disk Interface Standard
│
High │
│
│
│ . IPI
│
│ . SMD . ESMD
│
│ . SCSI
COST │ . ESDI
│
│
│
│ . ST-412HP
│
│ . ST-506/412 . AT Bus
│
Low │ . 3.5 Floppy
│
└───────────────────────────────────────────────────────>
Low High
PERFORMANCE
Fig 1 : Fixed Disk Interface Versus Market
A. ST-506 412 Winchester Interface
1. Industry standard since 1981
2. Low capacity Winchester (5 - 150 Mbytes)
3. small size
4. Serial data transfer rate of 5 Mbits/second
5. Cost (not performance) oriented
6. Simple disk interface (most of the effort is in the
disk controller)
B. Enhanced Small Device Interface (ESDI)
1. Substantial upgrade to ST-506/412 interface
2. Oriented towards high-capacity, high speed small
winchester
3. Capable of handling magnetic tapes and optical disks
4. Serial transfer rate 10 Mbits/second
5. Simpler controller
C. Storage Module Device (SMD)
D. Enhanced SMD
E. Small Computer Systems Interface(SCSI)
1. ANSI defined intelligent, low-cost peripheral interface
2. Derived from SASI (Shgart Assoc. Systems Interface)
3. 8-bit parallel data transfer, 1.5 to 4 Mbytes/second
4. Provides device independent software
5. Function more as a computer interface than a disk
interface
6. Requires lots of intelligence in the peripheral
F. Intelligent Peripheral Interface (IPI)
G. AT-Bus
1. Cost dowm
2. Data transfer rate
3. One I/O slot for another add-on card
4. The fixed disk controller is no longer required
1.3 Coding
The following are four different ways of improving the storage
capacity of disk drives:
1) Add more platters
2) Add more tracks per platter
3) Increase BPI (bit per inch)
4) Use better encoding methods
For method 1, it will increase manufacture cost for extra
platter and extra read/write head set.
For method 2, it will increase control logic complexity for
write current precompensation and interfere.
For method 3, it will use better read/write to shorten
the length between read/write head and platter.
For method 4, it will increase the encoding/decoding complexity.
A. Frequency Modulation (FM)
1 bit cell
│<----->│
┌───────┐ ┌───────┐ ┌───────┐
│ 1 │ 0 │ 1 │ 0 0 0 │ 1 │ 0
NRZ Data ──┘ └───────┘ └───────────────────────┘ └───
c d c c d c c c c d c
┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
FM Data ──┘ └─┘ └─┘ └─────┘ └─┘ └─┘ └─────┘ └─────┘ └─────┘ └─┘ └─┘ └─
┌───┐ ┌───────┐ ┌───┐ ┌───────┐ ┌───┐ ┌───
Disk Flux │ │ │ │ │ │ │ │ │ │ │
Transitions ──┘ └───┘ └───┘ └───────┘ └───────┘ └───┘
FM Encoding Rules:
1. Insert clock pulse for each bit cell
2. Insert data pulse when NRZ data is "1"
B. Modified Frequency Modulation(MFM)
1 bit cell
│<----->│
┌───────┐ ┌───────┐ ┌───────┐
│ 1 │ 0 │ 1 │ 0 0 0 │ 1 │ 0
NRZ Data ──┘ └───────┘ └───────────────────────┘ └────
┌─┐ ┌─┐
│ │ │ │
Clock ──────────────────────────────────┘ └─────┘ └──────────────
┌─┐ ┌─┐ ┌─┐
│ │ │ │ │ │
Data ──────┘ └─────────────┘ └─────────────────────────────┘ └────
d d c c d
┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐
│ │ │ │ │ │ │ │ │ │
MFM Data ──────┘ └─────────────┘ └─────────┘ └─────┘ └─────────┘ └──
┌───────────────┐ ┌───────┐ ┌────
Disk Flux │ │ │ │ │
Transitions ──────┘ └───────────┘ └───────────┘
MFM Encoding Rules :
1. Insert clock in pulse at the beginning of a bit cell only
if NRZ data = 0 for two consecutive bits.
2. If data bit = 1, insert data pulse in the middle of the
bit cell.
3. If data bit = 0, no insertion of data pulses in the bit
cell.
C. Run Length Limited (RLL)
RLL 2,7 Encoding Rules:
The following table shows encoding/decoding:
┌─────────┬────┬────┬──────┬──────┬────────┬────────┬────────┐
│ NRZ Data│10 │11 │000 │010 │011 │0010 │0011 │
├─────────┼────┼────┼──────┼──────┼────────┼────────┼────────┤
│ RLL 2,7 │1000│0100│100100│001000│000100 │00001000│00100100│
└─────────┴────┴────┴──────┴──────┴────────┴────────┴────────┘
D. Group Code Recording( GCR)
4,5 GCR Encoding Rules :
The following table shows encoding/decoding:
┌─────────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐
│ NRZ Data│0000 │000 1│0010 │0011 │0100 │0101 │0110 │0111 │
├─────────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ 4,5 GCR │11001│11011│10010│10011│11101│10101│10110│10111│
└─────────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘
┌─────────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐
│ NRZ Data│1000 │1001 │1010 │1011 │1100 │1101 │1110 │1111 │
├─────────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
│ 4,5 GCR │11010│01001│01010│01011│11110│01101│01110│01111│
└─────────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘
E. Zone Bit Recording(ZBR)
According to the track number, the fixed disk drive is divided
into several zones. The tracks in the same zone have the same
format, but the track in different zone may have different
format.
1.4 Data Format
┌─┐ ┌─┐
│ │ │ │
Index ─┘ └──────────────────────────────────────────────────────────┘ └──
┌───────────┬──────┬──────┬────────────────┬──────┬──────┬─────┐
│Index delay│Sector│Sector│ . . . . │Sector│Sector│Final│
│ Field │ 0 │ 1 │ . . . . │ N-1 │ N │ Gap │
└───────────┴──────┴──────┴────────────────┴──────┴──────┴─────┘
│ │
┌───────────┘ └─────────────────────────────────────────────┐
┌───────────┬───────┬────────┬───┬───────────┬──────┬────────────┐
│Preamble 1 │Address│ I.D. │EDC│Postamble 1│Sector│Inter sector│
│(Synch 1) │ Mark │(Header)│ECC│ │Data │ Gap │
└───────────┴───────┴────────┴───┴───────────┴──────┴────────────┘
│ │ │ │
┌───────────────────┘ └─────┐ │ │
┌─────┬─────┬─────┬────┬──────┬────┐ │ │
│ID AM│Track│Track│Head│Sector│ ID │ │ │
│ │(MSD)│(LSD)│ # │ # │Flag│ │ │
└─────┴─────┴─────┴────┴──────┴────┘ │ │
│ │
│ │
┌───────────────────────────┘ └────────────┐
┌───────────┬───────┬────┬──────┬───┬───────────┐
│Preamble 2 │Address│Data│ Data │EDC│Postamble 2│
│(Synch 2) │ Mark │Mark│Record│ECC│ │
└───────────┴───────┴────┴──────┴───┴───────────┘
1.5 Sector Interleaving
The initial formatting of a disk determines where sectors are
located within a track. It is not necessary to allocate sectors
sequentially around the track. The technique known as sector
interleaving optimizes access times when, although sectors are
accessed sequentially, a small amount of processing must be
performed between sector read/write.
interleave factor = 3
interleave factor = 2
1.6 Disk Formatting
A. Physical Format (initialization)
Initializes the fixed disk with sectors and addresses to
access data.
B. Partitioning
Assigns a partical amount of disk space to DOS.
C. Logical Format
Verifies that the initialization of the fixed disk drive
was successfully completed.
1.7 Translative Versus Non-Translative Mode
Owing to the use of advanced technique, the new WDD contains
more cylinders, heads, and sectors per track. But due to DOS
limitation, some DOS software can't access the extra disk
space. So some WDD manufacturer support "Translative mode" to
translate the extra disk space into DOS disk space.
Example 1 :
WDD have 1033 cylinders, 2 heads, 33 sectors/track in
non-translative mode, but it can have 1002 cylinders, 4 heads,
and 17 sectors/track in translative mode.
1033 * 2 * 33 = 68178 sectors/drive in non-translative mode
1002 * 4 * 17 = 68136 sectors/drive in translative mode
About 42 sectors in translative mode will be lost.
2.1 System Configuration for Fixed Disk Subsystem
┌────────┐
┌────────────┤ │<───────────┐
│ │ 8259A │ │
│ ┌───>│ │ │
│ │ └────────┘ │ ┌────────┐
│ ┌─────┴──┐ ┌───┴────┐ ┌---->│ WDD 0 │
│ │ CPU ├──────────────────>│ │<─────|──┬─>│ │
│ │ INT 13H│<----┬-------------│ WDC │ | │ └────────┘
│ │ -------│ | │ │<-----| │ ┌────────┐
└>│ INT 0EH│ | └────────┘ | └─>│ WDD 1 │
└────────┘ | ^ └---->│ │
| | └────────┘
| |
┌───┴────┐ |
│ DRAM │<-----------┘
└────────┘
Command/Control ────────
Data/Status --------
Fig : System Configuration for Fixed Disk System
2.2 I/O Port Definition
I/O Port Addr Read Write
1F0H/170H Data register Data register
1F1H/171H Error register Write Precomp
1F2H/172H Sector Count Sector Count
1F3H/173H Sector number Sector number
1F4H/174H Cylinder Low Cylinder Low
1F5H/175H Cylinder High Cylinder High
1F6H/176H Drive/Head(SDH) Drive/Head(SDH)
1F7H/177H Status register Command register
3F6H Alternate Status Fixed Disk Control
3F7H Digital Input
A. Data Register
Transfers through this register are 16 bits wide for all
data transfer except ECC byte transfers during read/write
long command, which are 8 bits wide.
B. Error Register
There are two mode in all WDC operation: operational mode and
diagnostic mode. The controller is set into diagnostic mode
upon power on or receiving a diagnostic command. In diagnostic
mode, the status register contents are invalid and the error
register contents reflects a self test completion code. If bit
7 of completion code is set, the slave drive will fail.
Completion Code Description
01H/81H No error
02H/82H Winchester Controller
03H/83H Sector Buffer Error
04H/84H ECC Device Error
05H/85H Control Processor Error
The controller is set into operational mode by issuing any
command other than the diagnostic command. While in operational
mode, the error register is valid only when the error bit in the
status register is set. The bit definitions for operational mode
are shown:
bit 7 Bad Block
bit 6 Data ECC Error
bit 5 Reserved
bit 4 ID Not Found
bit 3 Reserved
bit 2 Aborted Command
bit 1 Track 0 Error
bit 0 Address Mark Not Found
C. Write Precompensation Register
The Write precompensation register holds the value of the
starting write precompensation cylinder divided by four. The
controller may use this value to determine when to turn on the
write precompensation logic.
D. Sector Count Register
This register holds the number of sector to be transferred
during a read or write command, and the number of sectors per
per track during a format command. This register is decremented
for every sector during a multi-sector operation. Therefore, if
an error occurs during a multi-sector operation, this register
contains the number of sectors left to be transferred.
E. Sector Number Register
This register holds the starting sector number for any disk
operation. This register is updated as each sector is processed
in a multi-sector operation.
F. Cylinder Number Register
The two eight bit cylinder number registers (Low and High)
specify the starting cylinder argument for disk operation.
G. Drive/Head Register(SDH)
This register is used to specify the drive and head number
to be operated on during any following disk operation. During
the set parameters commands it is used to specify the maximun
number of heads on the drive. The bits are defined as follow:
bit 7 Reserved
bit 6 0
bit 5 1
bit 4 Drive select
bit 3 Reserved
bit 2-0 Head select
H. Status Register
This register contains the results of the last command executed
and the status of the drive. Reading the status register also
clears any interrupt request to the host. The bits are defined
as follows:
bit 7 WDC Busy
bit 6 WDC Ready to accept command
bit 5 Write Fault
bit 4 Seek Completed
bit 3 Data request
bit 2 Corrected Data
bit 1 Index
bit 0 Non-coverable error
I. Command Register
This register contains the code for the command to be performed.
All other command information should be written to the task
file before the command register is loaded. The BUSY bit in
the status register will be set when this register is written.
Interrupt request to the host is also cleared when this register
is written.
Valid command formats are as follows:
Recalibrate 0 0 0 1 0 0 0 0
Seek 0 1 1 1 0 0 0 0
Read Sector 0 0 1 0 0 0 L R
Write Sector 0 0 1 1 0 0 L R
Format Track 0 1 0 1 0 0 0 0
Read Verify 0 1 0 0 0 0 0 R
Write Verify 0 0 1 1 1 1 0 0
Diagnostic 1 0 0 1 0 0 0 0
Read Buffer 1 1 1 0 0 1 0 0
Write Buffer 1 1 1 0 1 0 0 0
Set Parameters 1 0 0 1 0 0 0 1
L : ECC R : Retry
J. Alternate Status Register
This register contains the same information of the status
register. However, this register may be read anytime without
clearing a pending interrupt.
K. Fixed Disk Control Register
This register contains the software reset bit and the enable
bit to enable interrupt requests to the host. The bits are
defined as follows:
bit 7-3 0
bit 2 Reset(1 for 5 us minimun)
bit 1 Interrupt enable
bit 0 0
L. Digital Input Register
This register contains information about the state of the
drive. The bits are defined as follows:
bit 7 Reserved
bit 6 Write Gate status(0 - on, 1 - off)
bit 5-2 Head Select
bit 1-0 Drive Select
2.3 Timing Consideration
A. WDD Start Time & Stop Time
The WDD will speed up spindle to desired speed when user
powers on.
The time from power on to spindle settling down is called
start time. Do not attempt to issue any command during WDD
start time, for it will interfere with WDD self test. Generally
, the WDD start time is approximately 15 seconds.
The WDD will speed down spindle until stopped when powered off.
The time from power off to spindle halt is called stop time.
Generally, the stop time will be approximately 15 seconds.
B. WDD Access time & Seek Time
The performance of WDD is relative to the access time and seek
Time. Generally, the access time and seek time does not affect
the WDD programming sequence. In some WDD, it supports
different seek speed that is set using seek command.
C. WDD Restart time
In some WDD, it will turn off spindle automatically when it
detects unstable condition of the power supply, delay some time
, and turn on the spindle automatically. The time between turn
off and on of the spindle is called restart time. The WDD
restart time must be considered in WDD programming sequence
when using CONNER WDD.
3. Programming Sequence in Fixed Disk Service Program
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;Module_Name: read_sector_hd
;Calling Sequence:
;
; Input : AH = 02h
; AH (in stack) = no_error
; DL = drive no.(not value check)
; DH = head no.
; CH = cylinder low
; CL = bit 7-6 -- cylinder high
; bit 5-0 -- sector no.(1 base)
; AL = no. of sectors to be read
; output : AH (in stack) = status of operation
;
;PDL: IF WDC valid THEN
; prepare task file
; IF WDC ready THEN
; write READ command to WDC
; ENDIF
; DO
; IF interrupt occurred THEN
; read one sector from data register
; get result back
; ELSE
; return error code = 80H (timeout)
; ENDIF
; UNTIL no data to be transferred
; ELSE
; return error code = 01H (invalid function call)
; ENDIF
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
page
f02_00: ; check valid_WDC
call valid_wdc ; check valid_wdc
jc f02_60 ; goto f02_40 if error occurred
; send read command block to WDC
call write_data ; Send command
mov ah, 021h ; BX = 021h for read command
call out_com ; out command byte to WDC
jc f02_60 ; goto f02_60 if WDC is not ready
mov di, [bp-4] ; DI = offset of transfer address
call wait_drq ;
jc f02_60 ;
f02_20: ; wait DRQ and test 64K boundary
cmp di, 0fe00h ; in 64K boundary
jb f02_30 ; goto f02_30 if there is no boundary error
mov ax, es ;
add ax, 20h ;
mov es, ax ; adjust ES
sub di, 200h ; adjust DI
f02_30:
call wait_int ; wait_interrupt
jc f02_60 ; goto f02_60 if time out
mov dx, hd_port0 ; data register
mov cx, 100h ; count = 256 words
cld ;
cli ;
rep insw ;
sti ;
; get result back
call get_result ; get result byte into AL
jc f02_60 ;
dec byte ptr [bp-2] ;
jnz f02_20 ;
f02_60:
jmp disk_end
5. Q & A