## Physical Device Driver Reference

[prev][next][parent][TOC]

### Physical Device Driver Programming Model

The physical device driver programming model is a 16:16 based protect-mode model. The physical device driver can have multiple code and data segments . The first segment in the device driver must be a data segment and the second segment must be a code segment. These two segments are fixed in memory and (by default) will be the only two segments kept in the system after device driver initialization. OS/2 assumes that every other segment is needed for initialization only, unless it is marked as permanent in the header of the device driver EXE file.

A permanent segment remains after initialization and is assumed to be movable and swappable, but not discardable. A physical device driver can lock a permanent segment using the appropriate device helper service, if it is necessary to prevent it from being swapped out or moved. I/O Protect Level (IOPL) is available at privilege level 3 during device driver installation. The physical device driver programmer uses the SEGMENTS directive and its IOPL option in the linker DEF file to mark those segments that are to be kept after initialization. Because the first two segments are always kept, they do not have to be marked in this fashion.

Note: Unlike the OS/2 Version 1.x operating systems, the OS/2 2.1 (or later) device drivers always execute in protect mode.

The physical device driver executable image does not contain a stack segment. An 8KB stack is provided by the system. However, at initialization, a device driver may indicate to the system its actual stack usage by calling the RegisterStackUsage device helper routine for each IRQ it services. See Limiting the Number of Nested Interrupts for more information.