home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Unsorted BBS Collection
/
thegreatunsorted.tar
/
thegreatunsorted
/
programming
/
misc_programming
/
hd.spc
< prev
next >
Wrap
Text File
|
1989-12-26
|
14KB
|
417 lines
function:
Fixed Disk I/O
------------------
L.H. KUNG 04/10/1989
description:
AH = 00h Reset disk system
AH = 01h Read status of last operation
AH = 02h Read desired sectors into memory
AH = 03h Write desired sectors from memory
AH = 04h Verify desired sectors
AH = 05h Format desired cylinder
AH = 06h Invalid function call
AH = 07h Invalid function call
AH = 08h Read drive parameters
AH = 09h Initialize drive pair characteristics
AH = 0ah Read long
AH = 0bh Write long
AH = 0ch Seek
AH = 0dh Alternate disk reset
AH = 0eh Invalid function call
AH = 0fh Invalid function call
AH = 10h Test drive ready
AH = 11h Recalibrate
AH = 12h Invalid function call
AH = 13h Invalid function call
AH = 14h Invalid function call
AH = 15h Read DASD type
AH = 16h Invalid function call
AH = 17h Invalid function call
AH = 18h Invalid function call
AH = 19h Park heads
Input:
AH = function number (value check)
AL = number of sectors (non-value check)
DH = head number (non-value check)
DL = drive number (80H based, value check)
CH = cylinder number - low 8 bits (non-value check)
CL = sector number - bits 0-5 (non-value check)
bits 6-7 are high 2 cylinder bits
ES:BX = transfer buffer address
Output:
40:74 = last fixed disk operation status
AH = status of operation
CF = 1 - status is non 0
0 - status is 0
Referenced BIOS data area:
40:72 = reset flag
40:74 = last fixed disk operation status
40:75 = number of fixed disk drives attached
40:8c = dixed disk drive controller status
40:8d = dixed disk drive controller error status
40:8e = fixed disk drive interrupt control
Port definition:
port 1F0h -- Data Register R/W
port 1F1h -- Error Register R
port 1F2h -- Sector Count Register R/W
port 1F3h -- Sector Number Register R/W
port 1F4h -- Cylinder Low R/W
port 1F5h -- Cylinder High R/W
port 1F6h -- SDH Register R/W
port 1F7h -- Status Register R
Command Register W
port 3F6h -- Alternate Status Register R
port 3F7h -- Drive Address Register R
Note 1 : Enter this software interrupt service routine, the value of
function number (ah) and drive number (dl) must be checked
before executing relative service request. Error return code 01
-- invalid function request will return when value invalid.
Note 2 : The status of fixed disk can be get from port 3F6H or 1F7H. The
Difference between port 3F6H and 1F7H is taht fixed disk interrupt
pending signal can be clear by using port 1F7H, but port 3F6H can
not.
Note 3 : For power saving consideration in laptop machine, user can set
desired time to make WDC enter idle mode after last read/write/
verify/seek operation.
Note 4 : There are three modes for WDC in laptop machine : READ/WRITE,
SEEKING, and IDLE mode. The READ/WRITE mode occurs when data is
being read from or written to the disk. The SEEKING mode while
the head is in motion. The IDLE mode occurs when the drive is not
reading,writing or seeking. The motor is up to speed and DRIVE
READY condition exists. Head is residing on last accessed track.
Note 5 : For seeking command, some WDC support parameters to change seek
speed. But new WDC will use top seek speed and don't care parameter
in seek command.
Note 6 : The Conner WDD will turn off motor automaticlly when power supply
unstable, and turn on motor after about 1 minute.
Note 7 : For performance consideration, disk service routine does not use
DMA in data transfer.
Note 8 : For performance consideration, please use in/out string instruction
in data transfer.
Note 9 : The fixed disk service routine support 2 WDD drive only.
Note 10: The WDC use IRQ 0EH to acknowlege the fixed disk service that the
command completion or data transfer completion.
Note 11: The fixed disk type information stores in CMOS. Please reference
CMOS definition.
RESET DISK SYSTEM
input : AH = 00h, 0Dh
DL = drive no. (bit 7 = 1 - fixed disk drive
0 - diskette drive )
output: AH = status of operation
CF = 1 - status is non 0 (error occured)
0 - status is 0 (no error)
Note 1 : The diskette system is also reset for all values of dl.
Note 2 : Prior to waiting for the fixed disk reset, call INT 15,
ah = 90h (device bysy) with al = 00h (type = disk)
informing the operating system of the wait.
Note 3 : This function include 3 sub-functions : reset disk, initialize
disk, and recalibrate.
READ STATUS OF LAST OPERATION
input : AH = 01h
DL = drive no. bit 7 = 1 for fixed disk drive (80H - base)
output: AH = status of operation
AL = last fixed disk operation status
CF = 1 - status is non 0 (error occured)
0 - status is 0 (no error)
Note 1 : Disk status(40:74H) is reset to 0
READ DESIRED SECTORS INTO MEMORY
input : AH = 02h
DL = drive no. bit 7 = 1 for fixed disk drive (80H-base)
DH = head no. (0-base)
CH = cylinder low (0-base)
CL = bit 7, 6 - cylinder high
bit 5 - 0 - sector no. (1-base)
AL = number of sector
ES:BX = address of buffer
output: AH = status of operation
CF = 1 - status is non 0 (error occured)
0 - status is 0 (no error)
Note 1 : Wait interrupt before transfer 512 bytes.
WRITE DESIRED SECTORS FROM MEMORY
input : AH = 03h
DL = drive no. bit 7 = 1 for fixed disk drive (80H-base)
DH = head no. (0-base)
CH = cylinder low (0-base)
CL = bit 7, 6 - cylinder high
bit 5 - 0 - sector no. (1-base)
AL = number of sector
ES:BX = address of buffer
output: AH = status of operation
CF = 1 - status is non 0 (error occured)
0 - status is 0 (no error)
Note 1 : Wait interrupt after transfer 512 bytes.
VERIFY DESIRED SECTORS
input : AH = 04h
DL = drive no. bit 7 = 1 for fixed disk drive (80H-base)
DH = head no. (0-base)
CH = cylinder low (0-base)
CL = bit 7, 6 -cylinder high
bit 5 - 0 - sector no. (1-base)
AL = number of sector
output: AH = status of operation
CF = 1 - status is non 0 (error occured)
0 - status is 0 (no error)
FORMAT DESIRED CYLINDER
input : AH = 05h
DL = drive no. bit 7 = 1 for fixed disk drive (80H-base)
DH = head no. (0-base)
CH = cylinder low (0-base)
CL = bit 7, 6 -cylinder high
ES:BX = point to a 512-byte buffer.
The first 2 x (sectors per cylinder) bytes
contain F, N for each sector :
F = 00h - good sector
N - sector no.
output: AH = status of operation
CF = 1 - status is non 0 (error occured)
0 - status is 0 (no error)
Note 1 : For MS-DOS limitation, this function only support WDD that have
cylinders below 1024. So please check cylinder before execution.
READ DRIVE PARAMETERS
input : AH = 08h
DL = drive no. bit 7 = 1 for fixed disk drive (80-base)
output: AH = status of operation
DL = number of consecutive drives attached
DH = maximum head number
CH = cylinder low
CL = cylinder high (high order 2 bits)
CF = 1 - status is non 0 (error occured)
0 - status is 0 (no error)
INITIALIZE DRIVE PAIR CHARACTERISTICS
input : AH = 09h
DL = drive no. bit 7 = 1 for fixed disk drive (80-base)
output: AH = status of operation
CF = 1 - status is non 0 (error occured)
0 - status is 0 (no error)
note 1 : INT 41H point to a parameter table for drive 0.
note 2 : INT 46H point to a parameter table for drive 1.
READ LONG
input : AH = 0ah
DL = drive no. bit 7 = 1 for fixed disk drive (80-base)
DH = head no. (0-base)
CH = cylinder low (0-base)
CL = bit 7, 6 -cylinder high
bit 5 - 0 - sector no. (1-base)
AL = no. of sector to be transfered
ES:BX = address of buffer
output: AH = status of operation
CF = 1 - status is non 0 (error occured)
0 - status is 0 (no error)
note 1 : The read long request read 512-byte data and 4-byte ECC.
note 2 : In this function WDC would not do ECC check.
note 3 : The data bytes and ECC bytes must be read seperately.
WRITE LONG
input : AH = 0bh
DL = drive no. bit 7 = 1 for fixed disk drive (80-base)
DH = head no. (0-base)
CH = cylinder low (0-base)
CL = bit 7, 6 -cylinder high
bit 5 - 0 - sector no. (1-base)
AL = no. of sector to be transfered
ES:BX = address of buffer
output: AH = status of operation
CF = 1 - status is non 0 (error occured)
0 - status is 0 (no error)
note 1 : The write long request write 512-byte data and 4-byte ECC.
note 2 : In this function WDC would not do ECC check.
note 3 : The data bytes and ECC bytes must be write seperately.
SEEK
input : AH = 0ch
DL = drive no. bit 7 = 1 for fixed disk drive (80-base)
DH = head no. (0-base)
CH = cylinder low (0-base)
CL = bit 7, 6 -cylinder high
output: AH = status of operation
CF = 1 - status is non 0 (error occured)
0 - status is 0 (no error)
ALTERNATE DISK RESET
input : AH = 0dh
DL = drive no. bit 7 = 1 for fixed disk drive (0 - base)
output: AH = status of operation
AL = last fixed disk operation status
CF = 1 - status is non 0 (error occured)
0 - status is 0 (no error)
note 1 : The disk status is reset to 0
note 2 : This function same as ah = 00h
TEST DRIVE READY
input : AH = 10h
DL = drive no. bit 7 = 1 for fixed disk drive (80-base)
output: AH = status of operation
CF = 1 - status is non 0 (error occured)
0 - status is 0 (no error)
RECALIBRATE
input : AH = 11h
DL = drive no. bit 7 = 1 for fixed disk drive (80-base)
output: AH = status of operation
CF = 1 - status is non 0 (error occured)
0 - status is 0 (no error)
READ DASD TYPE
input : AH = 15h
DL = drive no. (bit 7 = 1 - fixed disk drive
0 - diskette drive )
output: AH = 00h - drive not present or (dl) invalid
01h - reserved for diskette interface
02h - reserved for diskette interface
03h - fixed disk
CX,DX = number of 512-byte blocks
if AH = 0 then CX = DX = 0
CF = 0 - operation successfully completed
PARK HEADS
input : AH = 19h
DL = drive no. bit 7 = 1 for fixed disk drive (80-base)
output: AH = status of operation
CF = 1 - status is non 0 (error occured)
0 - status is 0 (no error)
INVALID FUNCTION REQUEST
input : AH = 06h, 07h, 12h, 13h, 14H, 0eh, 0fh
16h to 18h,
19h to FFh
DL = greater than number of fixed disk drive attached
output: AH = 1 -- invalid function request
note 1 : The INT 13H check the value of AH and DL, and return 01 if
invalid.
note 2 : The bit 7 of DL must be cleared before checking, and DL is
0-based, it must be increased one before compared to number of
drive attached.