Microsoft KB Archive/29284

PRB: Multiple Device Drivers in a Single File Do Not Load ID Number: Q29284

3.x 4.00 4.00a 4.01 4.01a 5.00 MS-DOS

Summary:

SYMPTOMS In MS-DOS versions 3.3 and later, multiple device drivers cannot be integrated (contained) in a single file.

CAUSE When a device driver is loaded, its INIT routine is called. This INIT routine must return the new pointer to the available free memory (past the end of the driver).

In MS-DOS 3.3, a feature was added so that if the break address returned by the driver is the same as the break address entered before the driver’s INIT was called (that is, the driver is not allocating any memory), the driver is aborted. As a result, it is not added to the device driver chain.

This feature allows drivers to intentionally abort themselves if, for example, some hardware cannot be initialized. However, this can lead to problems if you have more than one device driver in a single file, because when doing this, it is common practice to share a lot of code and data. As a consequence, the INIT functions for the different drivers will often return the same break address.

After the first driver is initialized, the break address it returns is recorded as the new system break address. Then, the subsequent drivers return the same break address when they are initialized. This invokes the special case outlined above: the system thinks the driver wants itself to be aborted. As a result, the driver is removed from the chain.

RESOLUTION For MS-DOS versions 3.3 and later, the code that checks the break address returned by the driver only compares the segment part of the address to the previous segment. It also compares the offset part to zero (0). Thus, if the break address returned by the driver does not have an offset of zero, the driver will not be aborted under any circumstance.

Additional reference words: 3.x 4.00 4.00a 4.01 4.01a 5.00