• Aucun résultat trouvé

Device Driver Header

Dans le document API Function Requests (Page 182-186)

The device driver's data segment must contain a Device Header as the very first item. The Device Header has the following structure.

Fie Id Length

Pointer To Next Header DWORD

Device Attribute WORD

Offset To Strategy Routine WORD

Reserved WORD

Name or Units 8 BYTES

Reserved 8 BYTES

Pointer to Next Device Header Field

The pointer to the next header is set by OS/2 at the time the device driver is loaded. For loadable device drivers, this field should be set to -1. The pointer-to-next-header field is set by Syslnit and should be left blank.

Note: For a character device driver that supports multiple devices, the data segment contains a device driver header for each device.

These headers must be linked together and the first header must be set to -1. The first word is an offset and the second word is the segment.

Device Attribute Field

The Device Attribute field describes the characteristics of the device driver to the system.

The format of the OS/2 device attribute field is:

15 14 13 12 11 10 9 8 7 6 5 4 3 2 0

c

Ill I

s

0 Ill Ill Ill Ill

c

N

s

K

H Ill B H p Ill LEVEL Ill Ill Ill L

u c

B

R Ill M R N Ill Ill Ill Ill K L R D

The attributes are:

Bit# Meaning

15 Set if character device driver 14 Reserved

=

O

13 Set if non-IBM block format, (block device drivers only). Set for output-until-busy support, (character device drivers only).

12 Set if support shared device access checking (character devices)

11 Set if support removable media (block devices) or device open/close (character devices)

10 Reserved

=

O

9-7 Function level where 001

=

OS/2 device driver 6 Reserved

=

0

5 Reserved

=

0 4 Reserved

=

0 3 Set if CLOCK device 2 Set if NULL device

1 Set if standard output device (STDOUT) 0 Set if standard input device (STDIN)

Bit 15 Bit 15 is the device type bit. Use bit 15 to tell th~ system if the device driver is a block or character device. For block device drivers, bit 15 is 0. For character device drivers bit 15 is 1.

Bit 13 For block device drivers, bit 13 indicates the method the driver uses to determine the media type.

If a block device driver uses information in the BPB to deter-mine the media type, bit 13 should be set to 1. If the device driver uses the media descriptor byte to determine the media type, bit 13 should be 0.

Bit 12 Bit 12 is the shared bit. It is set if the device name is NOT to be protected by sharer. (Has no meaning for block device drivers, must be 0.)

If clear (default), file system sharing rules DO NOT apply to the device, and it is the responsibility of the device driver to provide contention control.

If set, file system sharing rules DO apply to the device, just like they apply to any other file system name. In addition, any given physical device may have only one logical name.

(Devices cannot have aliases.)

Bit 11 For block device drivers, bit 11 is the removable media bit. If set, this bit indicates that the device driver handles removable media.

For character device drivers, bit 11 is the open/close bit. If set, this bit indicates that the device driver must receive OPEN AND CLOSE request packets.

Bit 9-7 Bits 9-7 indicate the function level where 001

=

OS/2 device driver.

Bit 3 Bit 3 is the clock device bit. It is used by a character device driver to indicate the system clock device.

Bit 2 Bit 2 is the NULL attribute bit. It is used by character devices only. Use bit 2 to tell OS/2 if your character device driver is a NULL device. Although there is a NULL device attribute bit, you cannot reassign the NULL device. This is an attribute that exists for OS/2 so that OS/2 can tell if the NULL device is being used.

Bits 1 and O For character devices, bits 1 and O are the standard input/standard output bits. Use these bits to tell OS/2 if your character device driver is the new standard input or standard output device.

Offset to Strategy Routine Field

The offset to the strategy routine field contains the offset from the start of the code segment to the strategy entry point. OS/2 uses this offset to call the strategy routine. The pointer is a word value con-tained in the device header.

Name/Units Field

The name/units field contains the name of a character device ported by the character device driver or the number of units sup-ported by the block device driver.

For a character device driver, the name of the device must be ASCII characters and must be left-justified with the remaining space set to blanks. The device name is used by applications to identify the device for 1/0. A character device driver should consider the fol-lowing rule when selecting a device driver name.

• Rule

A device name takes precedence over a filename in a DosOpen function call. This means that files cannot have the same name as a character device. The DosOpen function call will always open the device rather than the file.

Note: To avoid such conflicts with filenames, a character device driver should choose a character string with some unusual char-acter such as a $ sign.

For a block device driver, the number of units can be placed in the first byte. This is optional because OS/2 will fill this field during device driver initialization.

For character device drivers using ABIOS, the device name repres-ents a single device identified by the Logical ID (LID). For block device drivers using ABIOS, the number of units is equivalent to the number of devices (or units) under the LID.

Dans le document API Function Requests (Page 182-186)