After the driver is assembled, linked, and converted to a .BIN or .SYS file, copy it to the root directory of a bootable disk. If it is a character-device driver, do not use the same name for the file as you used for the logical device listed in the driver's header, or you will not be able to delete, copy, or rename the file after the driver is loaded.
Use your favorite text editor to add the line
DEVICE=[D:][PATH]FILENAME.EXT
to the CONFIG.SYS file on the bootable disk. (In this line, D: is an optional drive designator and FILENAME.EXT is the name of the file containing your new device driver. You can include a path specification in the entry if you prefer not to put the driver file in your root directory.) Now restart your computer system to load the modified CONFIG.SYS file.
During the MS-DOS boot sequence, the SYSINIT module (which is part of IO.SYS) reads and processes the CONFIG.SYS file. It loads the driver into memory and inspects the device header. If the driver is a character-device driver, SYSINIT links it into the device chain ahead of the other character devices; if it is a block-device driver, SYSINIT places it behind all previously linked block devices and the resident block devices (Figures 14-10, 14-11, and 14-12). It accomplishes the linkage by updating the link field in the device header to point to the segment and offset of the next driver in the chain. The link field of the last driver in the chain contains -1,-1.
Next, SYSINIT calls the strat routine with a request header that contains a command code of zero, and then it calls the intr routine. The driver executes its initialization routine and returns the break address, telling MS-DOS how much memory to reserve for this driver. Now MS-DOS can proceed to the next entry in the CONFIG.SYS file.
You cannot supersede a built-in block-device driver——you can only add supplemental block devices. However, you can override the default system driver for a character device (such as CON) with an installed driver by giving it the same logical-device name in the device header. When processing a character I/O request, MS-DOS always scans the list of installed drivers before it scans the list of default devices and takes the first match.
Figure 14-10. MS-DOS device-driver chain before any installable device drivers have been loaded.
Please refer to the printed book for this figure.
Figure 14-11. MS-DOS device-driver chain after installable device drivers have been loaded.
Please refer to the printed book for this figure.
Address Attribute Strategy Interrupt Type Units Name routine routine 00E3:0111 8004 0FD5 0FE0 C NUL 0070:0148 8013 008E 0099 C CON 0070:01DD 8000 008E 009F C AUX 0070:028E 8000 008E 00AE C PRN 0070:0300 8008 008E 00C3 C CLOCK 0070:03CC 0000 008E 00C9 B 02 0070:01EF 8000 008E 009F C COM1 007002A0 8000 008E 00AE C LPT1 0070:06F0 8000 008E 00B4 C LPT2 0070:0702 8000 008E 00BA C LPT3 0070:0714 8000 008E 00A5 C COM2 End of device chain
Figure 14-12. Example listing of device chain under MS-DOS version 2.1, "plain vanilla" IBM PC with no fixed disks or user device drivers. (C=character device, B=block device)