home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Unsorted BBS Collection
/
thegreatunsorted.tar
/
thegreatunsorted
/
programming
/
misc_programming
/
fd.doc
< prev
next >
Wrap
Text File
|
1990-01-05
|
16KB
|
379 lines
Chapter 8
Diskette Service (INT 13h)
--------------------------
1. Introduction
1.1 System Configuration for diskette System
1.2 Diskette Interface Standard
1.3 Coding
A. Frequency Modulation(FM)
B. Modified Frequency MOdulation(MFM)
1.4 Data Format
2. Floppy Disk Controller(FDC) - 8272A
2.1 8272A Internal Block Diagram
2.2 Diskette/Drive Specification
2.3 I/O Port Definition
2.4 Timing Consideration
A. Motor Start Time
B. Motor Stop Time
C. Head Settling Time
D. Step Rate Time and Data Transfer Rate
3. Programming Sequence in Diskette Service Program
4. Protection
5. Q & A
1.1 System Configuration for Diskette System
┌────────┐
│ 8253 │
┌────────┐ ┌───┤ Timer │ ┌────────┐
┌──────────────┤ │<───┘ └────────┘ ┌─>│ FDD 0 │
│ ┌────────────┤ 8259A │<───────────┐ ┌--│->│ │
│ │ ┌───>│ │ │ | │ └────────┘
│ │ │ └────────┘ │ | │ ┌────────┐
│ │ ┌─────┴──┐ ┌───┴────┐ |--│->│ FDD 1 │
│ │ │ CPU ├─────────────┬────>│ 8272A │<─────|──┼─>│ │
│ │ │ INT 13H│<------------│-----│ │ | │ └────────┘
│ │ │ -------│ ┌──────────────>│ FDC │<-----| │ ┌────────┐
│ └>│ INT 0EH│ │ │ └────────┘ | ├─>│ FDD 2 │
│ │ -------│ │ ┌───┴────┐ ^ |--│->│ │
└─ >│ INT 08H├───┘ │ 8237 │ | | │ └────────┘
└────────┘ └───┬────┘ | | │ ┌────────┐
┌───┴────┐ | | └─>│ FDD 3 │
│ DRAM │<---┘ └---->│ │
└────────┘ └────────┘
Command/Control ────────
Data/Status --------
Fig : System Configuration for Diskette System
1.2 Diskette Interface Standard
- ST-506/412
- Please reference Fixed Disk Trainning Course
1.3 Coding
Please reference Fixed Disk Trainning Course
1.4 Data Format
┌─┐ ┌─┐
│ │ │ │
Index ─┘ └────────────────────────────────────────────────────────────┘ └─
┌──────────┬───────┬──────────┬──────────────┬──────┬──────────┐
│Pre-Index │Index │Post-index│Sector│ . . . │ Last │ Final │
│ │Address│ │ │ . . . │ │ │
│Gap(Gap 5)│ Mark │Gap(Gap 1)│ 1 │ │Sector│Gap(Gap 4)│
└──────────┴───────┴──────────┴──────┴───────┴──────┴──────────┘
│ │ │ │ │ │
┌────┘ │ ┌────┘ │┌─────────────┘ └─────────────┐
┌───────┬───────┐ ┌───────┬───────┐┌──────┬──────────┬──────┬─────────┐
│Hex FF │HEX 00 │ │Hex FF │HEX 00 ││Sector│ Post ID │Sector│Post Data│
│ │(Sync) │ │ │(Sync) ││ ID │Gap(Gap 2)│ Data │Gap(Gap 3│
└───────┴───────┘ └───────┴───────┘└──────┴──────────┴──────┴─────────┘
│ │ │ │
┌───────────────────────────────────┘ └─────────┐│ │
┌───────┬───────┬───────┬───────┬──────┬──────┬──────┐│ │
│ ID │ Track │ Head │Sector │Sector│ CRC │ CRC ││ │
│Address│ │ │ │ │ │ ││ │
│ Mark │Address│Address│Address│Length│Byte 1│Byte 2││ │
└───────┴───────┴───────┴───────┴──────┴──────┴──────┘│ │
│ │
┌────────────────────┘ └────────┐
┌───────┬───────────────┬──────┬──────┐
│ Data │ 128 * (2 ** N)│CRC │ CRC │
│Address│ │ │ │
│ Mark │User Data Bytes│Byte 1│Byte 2│
└───────┴───────────────┴──────┴──────┘
2.1 Folppy Disk Controller(FDC) - 8272A
┌────────┐ │ │ ┌───────────┐
│Data Bus│ │ │<─>│ Registers │
DB0-7 <───>│ Buffer │<─>│ │ └───────────┘
│ │ │ │ ┌───────────┐
└────────┘ │ │ │ ├< WR CLOCK
│ │ │ ├> WR DATA
│ │ │ Serial ├> WR ENABLE
Termal Count >──┐ │ │<─>│ Interface ├> PRE SHIFT 0
│ │ │ │Controller ├> PRE SHIFT 1
┌───┴────┐ │ │ │ ├< READ DATA
DRQ <────┤ │ │ │ │ ├< DATA WINDOW
-DACK >────┤ Read │ │ │ │ ├> VCO SYNC
INT <────┤ Write │ │ │ └───────────┘
-RD >────┤ DMA │<─>│ │ ┌──────────┐ ┌──────┐
-WR >────┤Controll│ │ │ │ │ │ ├< READY
A0 >────┤ Logic │ │ │ │ │<─>│Input ├< WRITE PROTECT
RESET >────┤ │ │ │ │ │ │ Port ├< INDEX
└───┬────┘ │ │ │ │ │ ├< FAULT/TRACK 0
-CS >────────┘ │ │ │ │ └──────┘
│ │ │ Drive │ ┌──────┐
│ │<─>│ Interface│ │ ├> DRIVE SELECT 0
│ │ │Controller│ │ ├> DRIVE SELECT 1
CLK ─> │ │ │ │ │Output├> MFM MODE
VCC ─> │ │ │ │<─>│ ├> -RW/SEEK
GND ─> │ │ │ │ │ Port ├> HEAD LOAD
│ │ │ │ │ ├> LOW CURRENT
│ │ │ │ │ │ /DIRECTION
│ │ │ │ │ ├> FAULT RESET/STEP
│ └──────────┘ │ ├> HEAD SELECT
8272A Internal Bus └──────┘
Fig : 8272A Internal Block Diagram
2.2 Diskette/Drive Specification
Diskette Drive Sector/Track Data rate
360K 360K(5 1/4") 8 or 9 250 KBS
360K 1.2M(5 1/4") 9 300 KBS
1.2M 1.2M(5 1/4") 15 500 KBS
720K 720K(3 1/2") 9 250 KBS
720K 1.44M(3 1/2") 9 250 KBS
1.44M 1.44M(3 1/2") 18 500 KBS
Diskette capacity = sector length * sectors/track *
tracks/side * no. of side
For example :
1.44M = 512 bytes * 18 sectors/track * 80 tracks * 2
1.2M = 512 bytes * 15 sectors/track * 80 tracks * 2
360K = 512 bytes * 9 sectors/track * 40 tracks * 2
2.3 I/O Port Definition
I/O Port Addr Read Write
3F2H Digital Output Register
3F4H Main Status Register
3F5H Data Register Data Register
3F7H Digital Input Register Data Rate Register
A. Digital Output Register
This register contains the software control bit to select
drive, turn motor on, enable interrupt request, and software
reset. The bits are defined as follows:
bit 7-6 Reserved
bit 5 Drive B motor enable
bit 4 Drive A motor enable
bit 3 Enable interrupt request and DMA
bit 2 Reset()
bit 1 Reserved
bit 0 Drive select(0 - drive A, 1 - drive B)
B. Main Status Register
This register contains the status information of the FDC,
and may be accessed at any time. The bits are defined as
follows:
bit 7 Request to master
bit 6 data transfer direction(1-from FDC to CPU)
bit 5 non-DMA mode select
bit 4 FDC Busy
bit 3 FDD 3 Busy
bit 2 FDD 2 Busy
bit 1 FDD 1 Busy
bit 0 FDD 0 Busy
C. Data Register
This register contains the data to be read from or written
to FDC. Transfers through this register are 8 bits wide.
D. Digital Input Register
This register comtains the status information of the FDD.
The bits are defined as follows:
bit 7 Diskette change(1 - active)
bit 6-0 Reserved for WDD control
E. Data Rate Register
This register contains the data rate select bit to select
data transfer rate during read or write operation.
bit 7-2 Reserved
bit 1-0 Data Rate Select
(00 - 500 KBS, 01 - 300 KBS, 10 - 250KBS)
2.4 Timing Consiteration
A. Motor Start Time
The FDD will speed up spindle to 360 rpm when turn
motor on. The time from motor on to 360 rpm is called motor
start time. Generally, the motor start time is 550 ms. Issue
read command befor motor stable, it may get correct data if
data distortion within receivable range. Issue read command
before motor stable, it should write distorted data into
diskette and make next read operation failed.
B. Motor Stop Time
The FDD will spped down spindle until stop when turn
motor off. The Time form motor off to stop is called motor
stop time. Because it must be delay 550 ms after turn motor
on each time, so turn motor off immediately after each disk
operation will degrade system performance. In AT machine, it
will turn motor off if no any other disk operation during
37(25H) timer ticks.
C. Head Settling Time
The time between seek completed and read/write head
settle down is called head settling time. Generally, the head
settling time is 15 ms.
D. Step Rate Time(SRT) and Data Transfer Rate
The FDC may issue serval step pulse to FDD after the
FDC have received seek or recalibrate command. The time
interval between adjacent step pulse is called step rate
time. You can use SPECIFY command to program SRT from 1 to
16 ms. The SRT should be programmed 1 ms longer than the
minimun time required by the FDD. Generally, we set 6 ms for
SRT in AT machine.
All diskette timing is depentent on external clock.
So it will change its timing when external clock changed.
In AT machine, the external clock changed depend on data
transfer rate :
data transfer rate external clock SRT
500 KBS 8 MHZ SRT * 1
300 KBS 4 MHZ SRT * 2
250 KBS 4 MHZ SRT * 2
So depend on different media/drive configuration, the
diskette service routine must program different SRT (3 or
6 ms) before issue and read/write/verify/format command. But
FDD will receive a fixed SRT, 6 ms.
3. Programming Sequence in Diskette Service Program
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;Module_Name: read_sector
;Calling Sequence:
; Input : AH = 2
; AL = no. of sector(non-value check)
; DH = head no.(non_value check)
; DL = drive no.(value check)
; CH = cylinder no. - low 8 bit(non-value check)
; CL = sector no. - bit 0-5(non-value check)
; bit 6-7 high 2 bits for cylinder No
; ES:BX = transfer address(boundary check)
;
; Output: AH(in stack) = status of operation
; AL(in stack) = no. of transfer (unit : sector)
;Functional Description: read sector
;
;PDL : call diskette_valid
; IF CY = 1(drive invalid) THEN
; jump to disket_end
; ELSE
; call setup
; IF CY = 0 THEN
; AH = 0E6H(read data command byte)
; call rwvf
; ENDIF
; ENDIF
; set motor byte = motor off time(in diskette parameter table)
; jump to disket_end
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
read_sector:
call disket_valid ; check diskette drive number
jnc c60 ; goto c60 if drive valid
jmp disket_end
c60:
call setup ; setup motor,DMA,head location
jc c80 ; goto c80 if setup failed
c70:
mov byte ptr [bp-1], 2 ;
call dsket_dma_ctrl ; programming DMA
jc c80 ; goto c80 if DMA boundary error
mov ah, 0e6h ; AH=read data command byte=66h
call rwvf ; read sector
jnc c80 ; goto c80 if no error
call try_next ; check if need to read again
jc c70 ; to read sector if carry
c80:
jmp off_motor ; goto off_motor
4. Protection
1. change sector length
2. change Track address
3. build extra track
5. Q & A