The Command-Code Routines

A total of 20 command codes are defined for MS-DOS device drivers. The command codes (which are not consecutive), the names of the associated driver-interrupt routines, and the MS-DOS versions in which they are first supported are as follows:

Command Function Character Block MS-DOS

code driver driver version

0 Init (Initialization) X X 2.0

1 Media Check X 2.0

2 Build BPB X 2.0

3 IOCTL Read X X 2.0

4 Read X X 2.0

5 Nondestructive Read X 2.0

6 Input Status X 2.0

7 Flush Input Buffers X 2.0

8 Write X X 2.0

9 Write with Verify X 2.0

10 Output Status X 2.0

11 Flush Output Buffers X 2.0

12 IOCTL Write X X 2.0

13 Device Open X X 3.0

14 Device Close X X 3.0

15 Removable Media X 3.0

16 Output Until Busy X 3.0

19 Generic IOCTL X X 3.2

23 Get Logical Device X 3.2

24 Set Logical Device X 3.2

As you can see from the preceding table, a driver's interrupt section must support functions 0 through 12 under all versions of MS-DOS. Drivers tailored for MS-DOS 3.0 and 3.1 can optionally support an additional four functions, and MS-DOS drivers for versions 3.2 and later can support three more (for a total of 20). MS-DOS inspects the bits in the attribute word of the device-driver header to determine which of the optional functions a driver supports, if any.

Some of the functions are relevant only for character-device drivers and some only for block-device drivers; a few have meaning to both types. In any case, both driver types should have an executable routine present for each function, even if it does nothing except set the done flag in the status word of the request header.

In the command-code descriptions that follow, RH refers to the request header whose address was passed to the strategy routine in ES:BX, BYTE is an 8-bit parameter, WORD is a 16-bit parameter, and DWORD is a far pointer (a 16-bit offset followed by a 16-bit segment).