## Physical Device Driver Reference

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

### Writing a Physical Device Driver Using Advanced BIOS

To determine the basic structure of the physical device driver, certain design points must be identified:

The kind of device to be supported (character or block).

The nature of the I/O to the device - synchronous or staged, Program I/O ( PIO), or Direct Memory Access (DMA).

A staged request can be staged on a time delay, staged on an interrupt, or both. Staged on a time delay means the operation waits for a specific length of time before the operation can be continued or is completed. Staged on an interrupt means the operation waits for an interrupt to occur.

PIO or DMA refers to the type of addressing required for data transfers. PIO is done using virtual addresses, which are also referred to as logical addresses, of the form:

         segment/selector:offset.

DMA is performed using physical addresses, which are 32-bit numbers, indicating the data transfer location in memory.

The maximum number of devices.

The maximum number of interrupt levels.

These items determine the nature of the physical device driver (that is, how the task-time and interrupt-time portions of the device driver relate to each other and which of the DevHlp services will be used for blocking, queueing, timers, and so forth). The type and number of devices generally indicate the logical device names (for example, COM1, LPT1) that the physical device driver supports:

A device type is identified by its ABIOS-architected Device ID.

A specific device is identified by a LID and unit number under that LID.

I/O to the device is performed by calling the ABIOS entry point (start, interrupt, or timeout) that corresponds to the particular LID.

Parameters are passed to an ABIOS service through a request block structure.

I/O requests can be synchronous (run to completion) or staged (run until blocked, waiting for an interrupt or time).

Staged requests can have well-defined time delays between certain stages.

Data transfers can use either physical addresses or virtual addresses.

Before using ABIOS services and during initialization, a physical device driver must identify every LID for which it will accept requests. To do this, the physical device driver uses the architected ABIOS Device ID for its device.

The physical device driver uses the DevHlp_GetLIDEntry to search through the ABIOS common data area looking for the LID that corresponds to the given Device ID. In general, by making repeated calls to GetLIDEntry and counting the number of units supported by each LID it obtains, the physical device driver determines how many supported devices are configured in the system. The physical device driver processes interrupts and requests for its maximum number of supported devices only. Any LID of the device driver 's device type that is left over must be unclaimed so another physical device driver can support it.

A physical device driver knows which LID corresponds to a given logical device name (for example, COM1) because of the rule forcing the operating system logical device names to be in the same order as the LID entries for an associated Device ID. For example, assuming one unit per LID, an installable printer device driver supports LPT3 (the third printer) by locating the third LID that corresponds to the Device ID of the printer.

The physical device driver must determine which interrupt level each LID uses by using the ABIOS function Return LID Parameters. The device driver registers interrupt handler entry points for the interrupt levels that it supports with the DevHlp_SetIRQ. It keeps a list of every LID that corresponds to each interrupt handler.

Note: If the physical device driver supports multiple devices and the number of interrupt levels for those devices exceeds the number of supported interrupt levels, the device driver ignores any LID that it cannot support because too many different interrupt levels are required.

At task time, when the device driver strategy entry point for a given device header receives a request packet, the device driver knows which logical device name and LID (and unit number) correspond to that entry point.

The device driver strategy routine sets up an ABIOS request block and uses the DevHlp_ABIOSCall to invoke the Advanced BIOS START routine to begin the requested ABIOS function. ABIOS requires that the return code field, in the ABIOS request block, be initialized to FFFFH. ABIOS sets the return code to its appropriate value.

Note: Either portion of the device driver, the task-time strategy routine or the interrupt handler, can start an ABIOS request. For simplicity, the example uses the strategy routine as the caller of the Advanced BIOS START service.