Programs that read and write sectors need device-parameter information to avoid corrupting the medium. A program can retrieve a logical drive's device parameters by using Get Device Parameters (Interrupt 21h Function 440Dh Minor Code 60h). These parameters, returned in the form of a DEVICEPARAMS structure, specify such information as the total number of sectors on the medium and the sizes of the file-system data structures. The DEVICEPARAMS structure has the following form:
DEVICEPARAMS STRUC
dpSpecFunc db ? ;special functions
dpDevType db ? ;device type
dpDevAttr dw ? ;device attributes
dpCylinders dw ? ;number of cylinders
dpMediaType db ? ;media type
;Start of BIOS parameter block (BPB)
dpBytesPerSec dw ? ;bytes per sector
dpSecPerClust db ? ;sectors per cluster
dpResSectors dw ? ;number of reserved sectors
dpFATs db ? ;number of file allocation tables
dpRootDirEnts dw ? ;number of root-directory entries
dpSectors dw ? ;total number of sectors
dpMedia db ? ;media descriptor
dpFATsecs dw ? ;number of sectors per FAT
dpSecPerTrack dw ? ;sectors per track
dpHeads dw ? ;number of heads
dpHiddenSecs dd ? ;number of hidden sectors
dpHugeSectors dd ? ;number of sectors if dpSectors = 0
;End of BIOS parameter block (BPB)
DEVICEPARAMS ENDS
For a full description of the DEVICEPARAMS structure, see Section 3.9, “Structures.”
A program can set the device parameters of a logical drive by using Set Device Parameters (Interrupt 21h Function 440Dh Minor Code 40h). If the physical drive permits a variety of media formats, this function enables the program to select the specific format it requires. For example, a program can set the parameters to format a 360-kilobyte floppy disk in a 1.2-megabyte drive. The following statements define device parameters for several common formats:
SS160 DEVICEPARAMS <0,1,2,40,0,512,1,1,2, 64, 320,0feh,1, 8,1,0,0>
SS180 DEVICEPARAMS <0,1,2,40,0,512,1,1,2, 64, 360,0fch,2, 9,1,0,0>
DD320 DEVICEPARAMS <0,1,2,40,0,512,2,1,2,112, 640,0ffh,1, 8,2,0,0>
DD360 DEVICEPARAMS <0,1,2,40,0,512,2,1,2,112, 720,0fdh,1, 9,2,0,0>
SH320 DEVICEPARAMS <0,1,2,80,0,512,2,1,2,112, 640,0fah,1, 8,1,0,0>
DH360 DEVICEPARAMS <0,1,2,80,0,512,2,1,2,112, 720,0fch,2, 9,1,0,0>
DH640 DEVICEPARAMS <0,1,2,80,0,512,2,1,2,112,1280,0fbh,2, 8,2,0,0>
DH720 DEVICEPARAMS <0,1,2,80,0,512,2,1,2,112,1440,0f9h,3, 9,2,0,0>
DH144 DEVICEPARAMS <0,1,2,80,0,512,1,1,2,224,2880,0f0h,9,18,2,0,0>
DH120 DEVICEPARAMS <0,1,2,80,0,512,1,1,2,224,2400,0f0h,7,15,2,0,0>