[ Previous | Next | Contents | Home | Search ]
AIX Version 4.3 Kernel and Subsystems Technical Reference, Volume 1

ddstrategy Device Driver Entry Point

Purpose

Performs block-oriented I/O by scheduling a read or write to a block device.

Syntax

void ddstrategy (bp)
struct buf *bp;

Parameter

bp Points to a buf structure describing all information needed to perform the data transfer.

Description

When the kernel needs a block I/O transfer, it calls the ddstrategy strategy routine of the device driver for that device. The strategy routine schedules the I/O to the device. This typically requires the following actions:

Required Processing

The ddstrategy routine can receive a single request with multiple buf structures. However, it is not required to process requests in any specific order.

The strategy routine can be passed a list of operations to perform. The av_forw field in the buf header describes this null-terminated list of buf headers. This list is not doubly linked: the av_back field is undefined.

Block device drivers must be able to perform multiple block transfers. If the device cannot do multiple block transfers, or can only do multiple block transfers under certain conditions, then the device driver must transfer the data with more than one device operation.

Kernel Buffers and Using the buf Structure

An area of memory is set aside within the kernel memory space for buffering data transfers between a program and the peripheral device. Each kernel buffer has a header, the buf structure, which contains all necessary information for performing the data transfer. The ddstrategy routine is responsible for updating fields in this header as part of the transfer.

The caller of the strategy routine should set the b_iodone field to point to the caller's I/O done routine. When an I/O operation is complete, the device driver calls the iodone kernel service, which then calls the I/O done routine specified in the b_iodone field. The iodone kernel service makes this call from the INTIODONE interrupt level.

The value of the b_flags field is constructed by logically ORing zero or more possible b_flags field flag values.

Attention: Do not modify any of the following fields of the buf structure passed to the ddstrategy entry point: the b_forw , b_back , b_dev , b_un , or b_blkno field. Modifying these fields can cause unpredictable and disastrous results.
Attention: Do not modify any of the following fields of a buf structure acquired with the geteblk service: the b_flags , b_forw , b_back , b_dev , b_count , or b_un field. Modifying any of these fields can cause unpredictable and disastrous results.

Execution Environment

The ddstrategy routine must be coded to execute in an interrupt handler execution environment (device driver bottom half). That is, the routine should neither touch user storage, nor page fault, nor sleep.

Return Values

The ddstrategy routine, unlike other device driver routines, does not return a return code. Any error information is returned in the appropriate fields within the buf structure pointed to by the bp parameter.

When applicable, the return values defined in the POSIX 1003.1 standard for the read and write subroutines should be used.

Related Information

The geteblk kernel service, iodone kernel service.

The buf structure.

The read subroutine, write subroutine.

Device Driver Kernel Extension Overview, Understanding Device Driver Structure and Understanding Device Driver Classes, Programming in the Kernel Environment Overview in AIX Kernel Extensions and Device Support Programming Concepts.


[ Previous | Next | Contents | Home | Search ]