[Return to Library] [Contents] [Previous Chapter] [Next Section] [Next Chapter] [Index] [Help]


1    Header Files Related to Device Drivers

This chapter describes:


[Return to Library] [Contents] [Previous Chapter] [Next Section] [Next Chapter] [Index] [Help]


1.1    Conventions for Header Files

The descriptions of the header files associated with device drivers are presented in alphabetical order and in reference (man) page style. The descriptions can include the following sections.


Name

This section lists the name of the header file along with a summary description of its contents.


Location

This section presents the pathname for the header file. The pathname makes it easier for you to locate specific header files.


Description

This section briefly describes the contents of the header file.


When to Include

This section explains when to include a header file for block and character drivers.


Of Special Interest

This section lists specific structures, macros, constant values, and so forth that are of interest to device driver writers.


Related Information

This section lists related kernel interfaces, structures, system calls, and so forth.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


1.2    Header Files

Table 1-1 lists the header files related to device drivers, along with short descriptions of their contents. For convenience, the header files are listed in alphabetical order. Note that device drivers should include header files that use the relative pathname instead of the explicit pathname. For example, although buf.h resides in /usr/sys/include/sys/buf.h, device drivers should include it as:

<sys/buf.h>

Not all of the header files reside in <sys>. The following include files reside in other directories:

<kern/lock.h>
<machine/cpu.h>
<io/common/devdriver.h>

Table 1-1: Summary Descriptions of Header Files

Header File Contents
<sys/buf.h> Defines the buf structure.
<sys/conf.h> Defines the dsent structure.
<machine/cpu.h> Defines structures and constants related to the CPU.
<io/common/devdriver.h> Defines the structures, constants, and external interfaces that device drivers and the autoconfiguration software use.
<io/common/devdriver_loadable.h> Defines constants and declares external functions associated with dynamically configured drivers.
<io/common/devgetinfo.h> Defines various data structures used by the DEVGETINFO ioctl command.
<io/common/devio.h> Defines common structures and definitions for device drivers and ioctl commands.
<sys/disklabel.h> Defines structures and macros that operate on Digital UNIX disk labels.
<sys/errno.h> Defines the error codes that a device driver returns to a user process.
<sys/fcntl.h> Defines I/O mode flags that user programs supply to open and fcntl system calls.
<sys/ioctl.h> Defines commands for ioctl interfaces in different device drivers.
<io/common/iotypes.h> Defines constants that 64-bit conversions use.
<sys/kernel.h> Defines global variables that the kernel uses.
<kern/lock.h> Defines simple and complex lock structures.
<sys/malloc.h> Defines kernel memory allocator-related information.
<sys/map.h> Defines structures associated with resource allocation maps.
<sys/mman.h> Defines constants associated with the mmap kernel interface.
<sys/mode.h> Defines constants that driver interfaces use.
<sys/mtio.h> Defines commands and structures for magnetic tape operations.
<sys/param.h> Defines constants and interfaces that the kernel uses.
<sys/poll.h> Defines polling bit masks.
<sys/proc.h> Defines the proc structure, which defines a user process.
<kern/sched_prim.h> Defines scheduling interfaces.
<sys/security.h> Defines structures, constants, and data types that UNIX security software uses.
<sys/select.h> Defines select-related data structures and interfaces.
<sys/sysconfig.h> Defines cfgmgr framework operation codes and data structures used in the device driver's configure interface.
<sys/systm.h> Defines generic kernel global variables.
<kern/task.h> Defines structures that tasks use.
<kern/thread.h> Defines structures that kernel threads use.
<sys/time.h> Contains structures and symbolic names that time-related interfaces use.
<sys/types.h> Defines system data types and major and minor device interfaces.
<sys/uio.h> Contains the definition of the uio structure.
<sys/user.h> Defines the user structure.
<sys/vm.h> Contains a sequence of include statements that includes all of the virtual memory-related files.
<sys/vmmac.h> Contains definitions for byte conversions.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


buf.h

Defines the buf structure


Location

/usr/sys/include/sys/buf.h


Description

The buf.h file defines the buf structure used to pass I/O requests to the strategy interface of a block device driver. Character device drivers can also use the buf structure, typically in the xxstrategy interface.


When to Include

You include the buf.h file in block device drivers because they use file system block-sized buffers from a buffer cache supplied by the kernel to perform I/O.


Of Special Interest

Items of interest to device driver writers are:


Related Information

buf, BUF_LOCK, BUF_UNLOCK


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


conf.h

Defines the dsent structure


Location

/usr/sys/include/sys/conf.h


Description

The conf.h file defines the dsent structure (for block and character device drivers).


When to Include

You should include the conf.h file in block and character device drivers because these drivers declare an instance of and set the associated members of the dsent structure.


Of Special Interest

Items of interest to device driver writers are:

You use the defines to initialize the d_funnel member of the dsent structure.


Related Information

dsent


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


cpu.h

Defines structures and constants related to the CPU


Location

/usr/sys/include/machine/cpu.h


Description

The cpu.h file defines a variety of structures and constants related to the CPU.


When to Include

You include the cpu.h file in block and character device drivers when calling any of the spl interfaces. The reason for this is that the spl interfaces map to an assembler interface.


Of Special Interest

The items contained in cpu.h are opaque to device driver writers. In other words, device driver writers need not know the details of how the spl interfaces map to the assembler-specific interface.


Related Information

spl


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


devdriver.h

Defines the structures, constants, and external interfaces that device drivers and the autoconfiguration software use


Location

/usr/sys/include/io/common/devdriver.h


Description

The devdriver.h file defines the structures, constants, and external interfaces that device drivers and the autoconfiguration software use.


When to Include

You must include the devdriver.h file in block and character device drivers because you initialize the driver structure and reference the controller, device, and bus structures.


Of Special Interest

Items of interest to device driver writers are:


Related Information

bus, controller, device, driver


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


devdriver_loadable.h

Defines constants and declares external functions associated with dynamically configured drivers


Location

/usr/sys/include/io/common/devdriver_loadable.h


Description

The devdriver_loadable.h file defines constants and declares external functions associated with drivers that are dynamically configured into the kernel. The file also defines constants and declares external functions associated with bus support.


When to Include

You do not need to include this file in your device driver.


Of Special Interest

Items of interest to systems engineers who implement a new bus or make changes to an existing bus are the external declarations for interfaces used in bus adapter driver development. Examples of these external declarations are ldbl_find_bus, ldbl_search_bus_local, and ldbl_find_ctlr.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


devgetinfo.h

Defines various data structures used by the DEVGETINFO ioctl command


Location

/usr/sys/include/io/common/devgetinfo.h


Description

The devgetinfo.h file defines various data structures that the DEVGETINFO ioctl command uses.


When to Include

You include the devgetinfo.h file in disk device drivers.


Of Special Interest

Items of interest to device driver writers are the following data structures:


Related Information

DEVGETINFO, v1_bustype_info_t, v1_device_info_t, v1_devtype_info_t, v1_disk_dev_info_t, v1_tape_dev_info_t


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


devio.h

Defines common structures and definitions for device drivers and ioctl commands


Location

/usr/sys/include/io/common/devio.h


Description

The devio.h file defines common structures and definitions for device drivers and ioctl commands, such as DEVGETGEOM. This file also contains descriptions of device types, attributes, and names.


When to Include

You include the devio.h file in your device driver if you plan to use any of the ioctl commands such as DEVGETGEOM.


Of Special Interest

Items of interest to device driver writers are:


Related Information

DEVGETGEOM, DEVIOCGET


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


disklabel.h

Defines structures and macros that operate on Digital UNIX disk labels


Location

/usr/sys/include/sys/disklabel.h


Description

The disklabel.h file defines structures and macros that operate on Digital UNIX disk labels. Each disk has a label that includes information about the hardware disk geometry, file system partitions, and drive-specific information.


When to Include

You include the disklabel.h file if your block device driver needs to operate on disk labels.


Of Special Interest

Items of interest to device driver writers are:


Related Information

disklabel

Reference Pages Section 4: disktab


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


errno.h

Defines the error codes that a device driver returns to a user process


Location

/usr/sys/include/sys/errno.h


Description

The errno.h file defines the error codes returned to a user process by a device driver. Some of the error codes that a device driver can use are EIO, ENXIO, EACCES, EBUSY, ENODEV, and EINVAL.


When to Include

You include the errno.h file in both block and character device drivers to use the systemwide error codes.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


fcntl.h

Defines I/O mode flags that user programs supply to open and fcntl system calls


Location

/usr/sys/include/sys/fcntl.h


Description

The fcntl.h file defines I/O mode flags supplied by user programs to the open and fcntl system calls.


When to Include

You include the fcntl.h file in both block and character device drivers because these I/O mode flags get passed to the driver's open, close, and ioctl interfaces.


Related Information

Reference Pages Section 2: fcntl, open


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


ioctl.h

Defines commands for ioctl interfaces in different device drivers


Location

/usr/sys/include/sys/ioctl.h


Description

The ioctl.h file defines commands for ioctl interfaces in different device drivers. The ioctl commands are driver entry points that perform tasks other than the general I/O operations such as read and write. Thus, you can consider ioctl operations as a way to perform any task other than read and write tasks.


When to Include

You include the ioctl.h file in both block and character device drivers only when there is an ioctl entry point; that is, the driver has an ioctl interface that uses I/O control commands.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


iotypes.h

Defines constants that 64-bit conversions use


Location

/usr/sys/include/io/common/iotypes.h


Description

The iotypes.h file defines constants that 64-bit conversions use.


When to Include

You include the iotypes.h file if you use the constants defined for 64-bit conversions in your device driver.


Of Special Interest

The following table lists some of the 64-bit conversion constants:
Constant Meaning
I8 char
U8 unsigned char
I16 short
U16 unsigned short
I32 int
U32 unsigned int
I64 long long
U64 unsigned long long
I_WORD long
U_WORD unsigned long


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


kernel.h

Defines global variables that the kernel uses


Location

/usr/sys/include/sys/kernel.h


Description

The kernel.h file defines global variables that the kernel uses.


When to Include

You include the kernel.h file in both block and character device drivers to make use of the kernel global variables.


Of Special Interest

The kernel global variables that are of particular interest to device driver writers are:


Related Information

hz, lbolt


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


lock.h

Defines simple and complex lock structures


Location

/usr/sys/include/kern/lock.h


Description

The lock.h file defines the simple spin lock and complex lock structures that device drivers use for synchronization on single processor and multiprocessor systems.


When to Include

You include the lock.h file in device drivers if you use simple or complex locks to synchronize access to device driver structures and device registers.


Of Special Interest

Items of interest to the device driver writer are:


Related Information

lock, slock


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


malloc.h

Defines kernel memory allocator-related information


Location

/usr/sys/include/sys/malloc.h


Description

The malloc.h file defines the constants, data structures, and interfaces associated with the kernel memory allocator interfaces MALLOC and FREE.


When to Include

You include the malloc.h file in block and character device drivers when calling the interfaces associated with the kernel memory allocator.


Of Special Interest

Items of interest to device driver writers are the defines for the different memory types that device drivers can pass to the type argument of the MALLOC interface. For example, you can pass the M_DEVBUF constant to indicate that device driver memory is being allocated (or freed).


Related Information

FREE, MALLOC


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


map.h

Defines structures associated with resource allocation maps


Location

/usr/sys/include/sys/map.h


Description

The map.h file defines structures associated with resource allocation maps.


When to Include

You include the map.h file in both block and character device drivers when you need to make reference to the members of the map and mapent structures.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


mman.h

Defines constants associated with the mmap kernel interface


Location

/usr/sys/include/sys/mman.h


Description

The mman.h file defines constants associated with the mmap kernel interface. It also defines protection bits that the mmap system call uses.


When to Include

You include the mman.h file in any character device driver that needs to call the mmap kernel interface.


Of Special Interest

Items of interest to device driver writers are the following protection bits:


Related Information

xxmmap

Reference Pages Section 2: mmap, munmap


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


mode.h

Defines constants that driver interfaces use


Location

/usr/sys/include/sys/mode.h


Description

The mode.h file defines constants that driver interfaces use.


When to Include

You include the mode.h file when you use any of the constants defined in this file in your device driver.


Of Special Interest

Items of interest to device driver writers are:

Driver writers can use these constants to check the format argument for the xxclose and xxopen interfaces to determine whether the request is for a block or character device special file.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


mtio.h

Defines commands and structures for magnetic tape operations


Location

/usr/sys/include/sys/mtio.h


Description

The mtio.h file defines commands and structures for magnetic tape operations.


When to Include

You include the mtio.h file in tape device drivers. Commands defined in this file are used to communicate with the device driver's ioctl interface.


Of Special Interest

Items of interest to device driver writers are:


Related Information

Reference Pages Section 4: mtio


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


param.h

Defines constants and interfaces that the kernel uses


Location

/usr/sys/include/sys/param.h


Description

The param.h file defines constants and interfaces that the kernel uses.


When to Include

You include the param.h file in block and character device drivers when calling the sleep interface. The reason for this is that the sleep interface maps to another kernel interface.


Of Special Interest

One item of interest to device driver writers is the PCATCH constant.


Related Information

sleep


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


poll.h

Defines polling bit masks


Location

/usr/sys/include/sys/poll.h


Description

The poll.h file defines bit polling bit masks that a device driver's xxselect interface uses.


When to Include

You include the poll.h file in character device drivers if you want to use the polling bit masks to determine the state of the specified device.


Of Special Interest

Items of interest to device driver writers are the following polling bit masks:


Related Information

select_dequeue, select_dequeue_all, select_enqueue, select_wakeup, xxselect

Reference Pages Section 2: select


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


proc.h

Defines the proc structure, which defines a user process


Location

/usr/sys/include/sys/proc.h


Description

The proc.h file defines the proc structure, which defines a user process.


When to Include

You include the proc.h file in block and character device drivers if you want to access different members of the user's process structure.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


sched_prim.h

Defines scheduling interfaces


Location

/usr/sys/include/kern/sched_prim.h


Description

The sched_prim.h file defines scheduling interfaces (macros) and kernel threads-related constants.


When to Include

You include the sched_prim.h file when your driver references any kernel threads-related constants or scheduling interfaces.


Of Special Interest

Items of interest to driver writers are the following interfaces:


Related Information

assert_wait_mesg, thread_block, thread_wakeup, thread_wakeup_one


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


security.h

Defines structures, constants, and data types that UNIX security software uses


Location

/usr/sys/include/sys/security.h


Description

The security.h file defines structures, constants, and data types that UNIX security software uses.


When to Include

You include the security.h file in block and character device drivers if you call the privileged kernel interface.


Of Special Interest

Items of interest to device driver writers are the privilege constants. Examples of these constants include:


Related Information

privileged


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


select.h

Defines select-related data structures and interfaces


Location

/usr/sys/include/sys/select.h


Description

The select.h file defines the data structure and interfaces that device drivers use with the select_enqueue and select_dequeue interfaces.


When to Include

You include the select.h file when your device driver uses the sel_queue data structure and calls the select_enqueue and select_dequeue interfaces.


Of Special Interest

Items of interest to device driver writers are:


Related Information

select_dequeue, select_enqueue, sel_queue


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


sysconfig.h

Defines cfgmgr framework operation codes and data structures used in the device driver's configure interface


Location

/usr/sys/include/sys/sysconfig.h


Description

The sysconfig.h file defines operation codes and data structures used in the device driver's configure interface. The operation codes define the action to be performed by the configure interface. Examples of the operation types include configure, unconfigure, and query. This file also defines many of the constants that are shared between the cfgmgr framework and device drivers. The definition of the cfg_attr_t data structure that the device driver method of cfgmgr passes to the driver's configure interface appears in this file. The definition of the cfg_subsys_attr_t data structure that a driver's configure interface initializes also appears in this file.


When to Include

You include the sysconfig.h file in block and character device drivers.


Of Special Interest

Items of interest to device driver writers are the following constants:

You use these constants as follows:

The following constants are used with the point argument of the register_callback interface:

The following constants are used with the order argument of the register_callback interface:

You may also find the following interfaces (macros) useful for setting and checking dispatch points (through the register_callback interface): SET_CFGPOINT, BEFORE_CFGPOINT, and PAST_CFGPOINT.


Related Information

cfg_attr_t, cfg_subsys_attr_t, register_callback, unregister_callback, xxcallback, xxconfigure


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


systm.h

Defines generic kernel global variables


Location

/usr/sys/include/sys/systm.h


Description

The systm.h file defines generic kernel global variables that some kernel interfaces use.


When to Include

You include the systm.h file in character and block device drivers only if you need to reference one of the generic kernel global variables. Most device drivers will not need this file.


Of Special Interest

Items of interest to device driver writers are:


Related Information

insque


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


task.h

Defines structures that tasks use


Location

/usr/sys/include/kern/task.h


Description

The task.h file defines structures that tasks use.


When to Include

You include the task.h file when your driver references any of the data structures related to tasks.


Of Special Interest

One item of interest to the device driver writer is the typedef task_t, which is an alternate name for struct task *.


Related Information

task


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


thread.h

Defines structures that kernel threads use


Location

/usr/sys/include/kern/thread.h


Description

The thread.h file defines structures that kernel threads use.


When to Include

You include the thread.h file when your driver references any of the data structures related to kernel threads.


Of Special Interest

One item of interest to the device driver writer is the typedef thread_t, which is an alternate name for struct thread *.


Related Information

thread


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


time.h

Contains structures and symbolic names that time-related interfaces use


Location

/usr/sys/include/sys/time.h


Description

The time.h file contains structures and symbolic names that time-related interfaces use.


When to Include

You include the time.h file in block and character device drivers if the driver needs to look at:


Of Special Interest

Items of interest to device driver writers are:


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


types.h

Defines system data types and major and minor device interfaces


Location

/usr/sys/include/sys/types.h


Description

The types.h file defines system data types and major and minor device interfaces.


When to Include

You include the types.h file in most block and character device drivers in order to use the defined data types.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


uio.h

Contains the definition of the uio structure


Location

/usr/sys/include/sys/uio.h


Description

The uio.h file contains the definition of the uio structure.


When to Include

You include the uio.h file in character device drivers that access the uio structure.


Of Special Interest

Items of interest to device driver writers are:


Related Information

uio


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


user.h

Defines the user structure


Location

/usr/sys/include/sys/user.h


Description

The user.h file defines the user structure.


When to Include

You include the user.h file in block and character device drivers only if the driver needs to access different members of the user's user context structure.


Of Special Interest

Items of interest to device driver writers are:


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


vm.h

Contains a sequence of include statements that includes all of the virtual memory-related files


Location

/usr/sys/include/sys/vm.h


Description

The vm.h file contains a sequence of include statements that includes all of the virtual memory-related files.


When to Include

Including the vm.h file is a quick way of including all of the virtual memory-related files.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Chapter] [Index] [Help]


vmmac.h

Contains definitions for byte conversions


Location

/usr/sys/include/sys/vmmac.h


Description

The vmmac.h file contains definitions for converting from bytes to pages and from pages to bytes.


When to Include

You include the vmmac.h file in device drivers if the driver needs to perform virtual memory calculations directly.