Index Index for
Section 9
Index Alphabetical
listing for D
Bottom of page Bottom of
page

devsw_add(9r)

NAME

devsw_add - General: Registers driver entry points and reserves a major number

SYNOPSIS

#include <sys/conf.h> int devsw_add( char *driver_name, int driver_reg_instance, int major_number, struct dsent *dsent_ptr );

ARGUMENTS

driver_name Specifies a null-terminated string that represents the name of the device driver whose entry points you want to register and for which you want to reserve an associated major number. The driver name must be at least two characters in length not to exceed DEVSW_NAME_LEN characters, including the null terminator. This name is a string that matches the string you specified for the entry_name item in the /etc/sysconfigtab database. Typically, third-party driver writers specify the driver name (followed by a colon) in the sysconfigtab file fragment, which gets appended to the /etc/sysconfigtab database during the driver product installation. driver_reg_instance Specifies an integer that represents a specific reservation instance for this driver. This argument allows a driver to uniquely identify multiple major numbers for the driver. major_number Specifies the major number you want to reserve for the driver in the dsent table. You can pass a specific major number or the value -1, in which case the devsw_add interface chooses the major number. dsent_ptr Specifies a pointer to the device switch structure that contains pointers to the device driver's entry points for the system service's I/O requests and other information.

DESCRIPTION

The devsw_add interface registers a device driver's I/O services interfaces in and reserves a major number from a free slot in the dsent table. Tru64 UNIX reserves this major number across boots. The devsw_add interface performs appropriate checks on the values passed to the driver_name, major_number, and dsent_ptr arguments. You can request that the devsw_add interface reserve a specific major number from a slot in the dsent table by passing a specific number to the major_number argument. If you pass a specific major number, the devsw_add interface determines if a major number has already been assigned to the device driver. If this major number was already assigned to the device driver, the devsw_add interface simply registers the driver's I/O services interfaces in the dsent table and returns the major number as the reserved number. Passing the value -1 to the major_number argument causes the devsw_add interface to reserve a previously reserved major number or the next available major number from a slot in the dsent table. If the major number you request or if the major number that was previously reserved is too large for the current size of the device switch table, devsw_add returns an error value of -1. You can make subsequent calls to devsw_add to modify the device switch entry in the device switch table.

NOTES

The dsent data structure contains entry points for the block and character I/O services interfaces associated with a specific device driver. This data structure also contains other information such as whether the driver is implemented as a symmetric multiprocessing (SMP) driver. The devsw_add interface is provided for registering these block and character I/O services interfaces and reserving an associated major number. A device driver writer registers the driver's I/O services interfaces by declaring an instance of the dsent structure in the driver and setting the appropriate members to the names of the driver's I/O services interfaces. You must specify an interface name for each member of this structure. If the driver does not implement a specific interface, there are typically two interfaces you can specify: · The nodev interface You specify nodev when it is an error for the interface to be called. To indicate the error, nodev returns ENODEV. · The nulldev interface You specify nulldev when it is not an error for the interface to be called, but the driver has no need to implement the interface. The nulldev interface returns the value zero (0) and performs no tasks. This value indicates a success status.

EXAMPLE

See Writing Device Drivers: Tutorial for a code example of the devsw_add interface.

RETURN VALUES

Upon successful completion, the devsw_add interface returns the reserved major number. Otherwise, on an error, the devsw_add interface returns the value -1. The following list describes possible error conditions: · The devsw_add interface is not available to be called at this point in the driver. · The name you passed to the driver_name argument is not a valid name. · The requested or reserved major number is too large for the current table. · The requested major number is not available. · The requested major number is not the same as the reserved major number. · The pointer passed to the dsent_ptr argument is not valid.

SEE ALSO

Kernel Interfaces: devsw_del(9r), devsw_get(9r) Data Structures: dsent(9s)

Index Index for
Section 9
Index Alphabetical
listing for D
Top of page Top of
page