|
|
#include <sys/types.h> #include <sys/ddi.h>
Beginning with DDI version 8, entry-point routines are located through the driver's drvops(D4) structure rather than by naming convention, but retaining the naming conventions makes the driver easier to maintain. Some interface-specific entry-point routines are identified through other structures, such as streamtab(D4str) for STREAMS drivers and the hba_info(D4sdi) structure for SDI HBA drivers.
Any number of instances of the same driver (or module) entry point routine can be running concurrently. It is the responsibility of the driver or module to synchronize access to its private data structures.
For a hardware device, the idata corresponds to
the actual physical device,
and the channelp corresponds to an operating mode.
The idata value is returned by the
CFG_ADD subfunction to the
config(D2)
entry point routine.
See
``Device instance'' in HDK Technical Reference
and
``Channel number'' in HDK Technical Reference.
Comparison of DDI 7 and DDI 8 entry point routines (non-STREAMS drivers)
| ||DDI 7 | ||DDI 8 | Routine | Context ||Block | Character ||All | Notes biostart | blockable || | || | chpoll | blockable || | o || | close | blockable ||rn | rn ||r* | changed syntax config | blockable || | ||rh | devinfo | blockable ||on | on || | changed syntax halt | non-blockable ||on | on || | see config(D2) init | initialization ||on | on || | see load(D2) intr | interrupt ||oh | oh ||oh | changed syntax ioctl | user || | on ||o* | changed syntax drvctl | blockable || | ||o | _load | blockable ||o | o ||r | mmap | user || | on ||o | changed syntax open | blockable ||rn | rn ||r* | changed syntax read | user || | on || | see biostart(D2) size | blockable ||rn | || | see devinfo(D2) start | non-blockable ||on | on || | see _load(D2) strategy | blockable ||on | || | see biostart(D2) _unload | blockable ||o | o ||r | _verify | blockable ||oh | oh || | see config(D2) write | user || | on || |
KEY:
SDI drivers use these routines for their pass-through interface, but those are a different interface that are attached through the hba_info(D4sdi) structure and the sdi_register(D3sdi) routine. See ``SDI pass-through interface'' in HDK Technical Reference.
DDI 8 introduces entry point versioning so that the operating system knows how to invoke the appropriate set of entry point routines for the specified DDI version. All communication of driver entry points for DDI 8 drivers takes place at run time, using the drv_attach(D3) function. drv_attach( ) is called from a driver's _load(D2) routine during driver initialization. The driver passes in a pointer to a drvinfo(D4) structure that includes a pointer to another structure that lists the driver entry point routines. The set of entry point routines in a driver must conform to those documented for the declared DDI version.
The beginning of every DDI 8 driver source file must include the following lines before any header files are #included:
#define _KERNEL #define _DDI 8The _DDI line gives the ``major'' version number, such as 7 or 8; it does not use full version numbers such as 8.1 or 8mp. These definitions can instead be given as arguments to the -D option of the cc line to compile the driver:
cc -D_KERNEL -D_DDI=8
The _DDI=version definition is optional for DDI versions prior to version 8.
``Entry-point routines'' in HDK Technical Reference
``Context of a driver'' in HDK Technical Reference
``DDI interface versioning'' in HDK Technical Reference
``Device instance'' in HDK Technical Reference
``Channel number'' in HDK Technical Reference
``Driver structure'' in Developing device drivers