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

devswadd Kernel Service

Purpose

Adds a device entry to the device switch table.

Syntax

#include <sys/types.h>
#include <sys/errno.h>
#include <sys/device.h>
int devswadd (devno, dswptr)
dev_t devno;
struct devsw *dswptr;

Parameters

devno Specifies the major and minor device numbers to be associated with the specified entry in the device switch table.
dswptr Points to the device switch structure to be added to the device switch table.

Description

The devswadd kernel service is typically called by a device driver's ddconfig routine to add or replace the device driver's entry points in the device switch table. The device switch table is a table of device switch (devsw) structures indexed by the device driver's major device number. This table of structures is used by the device driver interface services in the kernel to facilitate calling device driver routines.

The major device number portion of the devno parameter is used to specify the index in the device switch table where the devswadd service must place the specified device switch entry. Before this service copies the device switch structure into the device switch table, it checks the existing entry to determine if any opened device is using it. If an opened device is currently occupying the entry to be replaced, the devswadd service does not perform the update. Instead, it returns an EEXIST error value. If the update is successful, it returns a value of 0.

Entry points in the device switch structure that are not supported by the device driver must be handled in one of two ways. If a call to an unsupported entry point should result in the return of an error code, then the entry point must be set to the nodev routine in the structure. As a result, any call to this entry point automatically invokes the nodev routine, which returns an ENODEV error code. The kernel provides the nodev routine.

Otherwise, a call to an unsupported entry point should be treated as a no-operation function. Then the corresponding entry point should be set to the nulldev routine. The nulldev routine, which is also provided by the kernel, performs no operation if called and returns a 0 return code.

On multiprocessor systems, all device driver routines run by default on the first processor started when the system was booted. This ensures compatibility with uniprocessor device drivers. If the device driver being added has been designed to be multiprocessor-safe, set the DEV_MPSAFE flag in the d_opts field of the devsw structure passed to the devswadd kernel service. The device driver routines will then run on any available processor.

All other fields within the structure that are not used should be set to 0. Some fields in the structure are for kernel use; the devswadd service does not copy these fields into the device switch table. These fields are documented in the /usr/include/device.h file.

Execution Environment

The devswadd kernel service can be called from the process environment only.

Return Values

0 Indicates a successful operation.
EEXIST Indicates that the specified device switch entry is in use and cannot be replaced.
ENOMEM Indicates that the entry cannot be pinned due to insufficient real memory.
EINVAL Indicates that the major device number portion of the devno parameter exceeds the maximum permitted number of device switch entries.

Implementation Specifics

The devswadd kernel service is part of Base Operating System (BOS) Runtime.

Related Information

The devswchg kernel service, devswdel kernel service, devswqry kernel service.

The ddconfig device driver entry point.

Kernel Extension and Device Driver Management Kernel Services in AIX Version 4.3 Kernel Extensions and Device Support Programming Concepts.


[ Previous | Next | Contents | Home | Search ]