Chapter
5
I
Device Drivers
If there is more than one device driver in the .COM file, the last
driver in the file must have the pointer to the next Device
Header field set to
-1.
Attribute
Field
The attribute field tells the system whether this device is a block
or
character device (bit
15).
Most other bits are used
to
give se-
lected character devices certain special treatment. (Note that
these bits mean nothing on
a
block device.) For example, suppose
you have a new device driver that you want
to
be the standard
input and output. Besides installing the driver, you must tell
MS-DOS that you want your new driver
to
override the current
standard input and standard output (the CON device).
You
do
this by setting bits
0
and
1
to
1.
You could also install
a
new
CLOCK device by setting
that
attribute bit.
Although there is
a
NUL device attribute, the NUL device can-
not be reassigned. This attribute exists
so
that MS-DOS can de-
termine if the NUL device is being used.
The NON IBM FORMAT bit applies only
to
block devices and af-
fects the operation
of
the BUILD BPB (Bios Parameter Block) de-
vice call. (Refer
to
“MEDIA CHECK and BUILD BPB” later in
this chapter for further information on this call.)
The IOCTL bit has meaning on both character and block devices.
This bit tells MS-DOS whether the device can handle control
strings (via the IOCTL function call, Function 44H).
If a driver cannot process control strings, it should initially set
the IOCTL bit to
0.
This tells MS-DOS to return an error if an
attempt is made (via Function 44H) to send
or
receive control
strings to this device.
A
device which can process control strings
should initialize the IOCTL bit to
1.
For drivers
of
this type,
MS-DOS will make calls
to
the IOCTL input and output device
functions
to
send and receive IOCTL strings.
The IOCTL functions allow data
to
be sent and received by he
device
for
its own use (for example,
to
set baud rate, stop bits,
and form length), instead
of
passing data over the device channel
as does
a
normal read
or
write. It is up to the device
to
interpret
the passed information, but it must not be treated
as
a normal I/
0
request.
175