A block-device driver handles input and output for a mass-storage device, such as a disk drive. The driver must implement the following device-driver functions:
Function | Name | Comments |
00h | Init | ||
01h | Media Check | ||
02h | Build BPB | ||
03h | IOCTL Read | “Required only if bit 14 is set in the dhAttributes field of the DEVICEHEADER structure” | |
04h | Read | ||
08h | Write | ||
09h | Write with Verify | ||
0Ch | IOCTL Write | Required only if bit 14 in dhAttributes is set | |
0Dh | Open Device | Required only if bit 11 in dhAttributes is set | |
0Eh | Close Device | Required only if bit 11 in dhAttributes is set | |
0Fh | Removable Media | Required only if bit 11 in dhAttributes is set | |
13h | Generic IOCTL | Required only if bit 6 in dhAttributes is set | |
17h | Get Logical Device | Required only if bit 6 in dhAttributes is set | |
18h | Set Logical Device | Required only if bit 6 in dhAttributes is set | |
19h | IOCTL Query | Required only if bit 7 in dhAttributes is set |
Every block-device driver controls one or more devices. A device can be a physical drive, such as a floppy disk drive, or a logical drive, such as a partition on a hard disk. In either case, MS-DOS assigns a unique drive number that programs use to access the device. The driver is responsible for determining and reporting how many devices it supports when it returns from a call to Init (Device-Driver Function 00h).
MS-DOS allows no more than 26 drives for the entire system. If a device driver reports a number that would push the system total beyond 26, MS-DOS terminates the driver. To ensure that a driver does not exceed this limit, MS-DOS passes the next available drive number to the driver during initialization. As long as the sum of this number and the driver's number of units is less than 26, the driver's initialization will succeed.
It is not possible to replace the resident block-device driver with an installable device driver. Installable block-device drivers can be used only for devices not directly supported by resident drivers. Note that MS-DOS always initializes resident block-device drivers before installable drivers and always assigns drive numbers in the same order as it initialized the drivers.