INF: Opening a Character Device in Raw Mode

ID Number: Q26865

2.x 3.x 4.00 4.00a 4.01 4.01a 5.00

MS-DOS

Summary:

A character device driver cannot initialize itself in raw (binary)

mode; the logic behind the MS-DOS device driver was not designed for

this option.

The only way a character device driver can initialize is in cooked

mode. Thus, the only way for a device driver to be used in raw mode is

for the application that is using the device to set the device to raw

mode after it has been initialized.

To do this, the application that wants to use the device in raw mode

should use MS-DOS interrupt 21h, function 44h IOCTL interface,

subfunction 1 (Set Device Parameters). Under this call, DX is the

"device information"; bit 5 should be set to indicate that you want

the device to operate in raw mode.

The following is an example of using this MS-DOS service:

; Code fragment that sets the stdout file handle to raw mode

mov dh, 0 ; Set upper byte of DX = 0

or dl, 20h ; Set raw mode bit in DL

mov bx, 1 ; File handle (stdout)

mov ax, 4401h ; IOCTL Set Device Parameters service

int 21h ; MS-DOS interrupt 21h

The utilities you use to send data to your device must have the

functionality to set the device to binary, or raw mode. For example,

the MS-DOS COPY command's /b switch does this. However, the MS-DOS

TYPE command, when redirected to your device, does not do this. Some

people have written small TSR programs that they distribute with their

device drivers that intercept the file handle open service of

interrupt 21h (service 3Dh); if the target is their device, it opens

the file and sets the file to binary mode. The device would remain in

raw mode while the application kept this file handle open.

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