## Physical Device Driver Reference

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

### OS/2 Physical Device Driver Operations

Physical device driver operations consist of the activities and interactions between the strategy routine and the hardware interrupt handler in the processing of an I/O request.

The handling of an I/O request begins with OS/2 calling the strategy routine entry point with a pointer to the request packet. The strategy routine checks the validity of the I/O request. If the request is valid, the strategy routine might place the request on a work queue for the device .

If the device is currently idle, the strategy routine starts the request at the device. The strategy routine can then wait for the device interrupt by suspending its thread of execution with the DevHlp_Block.

When the device interrupt occurs, the hardware interrupt handler checks the request to see if it has been completed. If the request has not been completed, the hardware interrupt handler continues the request at the device. If the request has been completed, the hardware interrupt handler sets the return status in the request packet. The hardware interrupt handler can remove the completed request packet from the work queue and start the next request at the device. If the strategy routine is waiting for the device interrupt (which is blocked), the hardware interrupt handler can initiate the strategy routine with the DevHlp_Run.

The strategy routine queues the requests and initiates only the I/O, if the device has been inactive. The hardware interrupt handler starts requests as they reach the head of the work queue. The thread that is running when the physical device driver determines that a particular request is complete might not necessarily be the same thread in which the device driver had received the request. This is particularly true for the interrupt-time components of the physical device driver. For example, the address of a user buffer passed to the physical device driver when the request was issued belongs to a specific Local Descriptor Table (LDT), which might not be the current LDT when the request ends. The device driver can accommodate this by storing the buffer address as a 32-bit physical address .

The physical device driver strategy routine is called by the OS/2 operating system with a pointer to the request packet. Any addresses passed in the request packets for Read/Write requests are passed as 32-bit physical addresses. Therefore, the physical device driver does not need to lock or convert the addresses into physical addresses. The device driver needs to lock only these addresses that it receives from a source other than the OS/ 2 operating system, as in the case of a process passing an address by way of a generic IOCtl.

The multitasking environment dictates that the components of the device driver must be capable of handling requests simultaneously. This means that the components of the physical device driver must relinquish execution whenever possible. The physical device driver relinquishes control at task -time by blocking, yielding, or referencing a segment that had been swapped out. The OS/2 operating system does not preempt a thread in the physical device driver. However, once the physical device driver releases its execution, the operating system calls the physical device driver with a new request. Once the strategy routine blocks, yields, or references a swapped -out segment, its thread of execution is called with a new request under the context of a different thread.

While the strategy routine assumes that it will not be preempted by other task-time instances, it must protect itself against its own interrupt-time components. It must disable interrupts when checking if the device is active and when examining the device queue. The interrupt-time components are preempted only by other higher priority interrupts.