Writing Device Drivers
Previous Next

Installing, Updating, and Removing Drivers

Before a driver can be used, the system must be informed that the driver exists. The add_drv(1M) utility must be used to correctly install the device driver. After a driver is installed, that driver can be loaded and unloaded from memory without using the add_drv command.

Copying the Driver to a Module Directory

Three conditions determine a device driver module's path:

  • The platform that the driver runs on

  • The architecture for which the driver is compiled

  • Whether the path is needed at boot time

Device drivers reside in the following locations:

/platform/`uname -i`/kernel/drv

Contains 32-bit drivers that run only on a specific platform.

/platform/`uname -i`/kernel/drv/sparcv9

Contains 64-bit drivers that run only on a specific SPARC-based platform.

/platform/`uname -i`/kernel/drv/amd64

Contains 64-bit drivers that run only on a specific x86-based platform.

/platform/`uname -m`/kernel/drv

Contains 32-bit drivers that run only on a specific family of platforms.

/platform/`uname -m`/kernel/drv/sparcv9

Contains 64-bit drivers that run only on a specific family of SPARC-based platforms.

/platform/`uname -m`/kernel/drv/amd64

Contains 64-bit drivers that run only on a specific family of x86-based platforms.

/usr/kernel/drv

Contains 32-bit drivers that are independent of platforms.

/usr/kernel/drv/sparcv9

Contains 64-bit drivers on SPARC-based systems that are independent of platforms.

/usr/kernel/drv/amd64

Contains 64-bit drivers on x86-based systems that are independent of platforms.

To install a 32-bit driver, the driver and its configuration file must be copied to a drv directory in the module path. For example, to copy a driver to /usr/kernel/drv, type:

$ su
# cp xx /usr/kernel/drv
# cp xx.conf /usr/kernel/drv

To install a SPARC driver, copy the driver to a drv/sparcv9 directory in the module path. Copy the driver configuration file to the drv directory in the module path. For example, to copy a driver to /usr/kernel/drv, you would type:

$ su
# cp xx /usr/kernel/drv/sparcv9
# cp xx.conf /usr/kernel/drv

To install a 64-bit x86 driver, copy the driver to a drv/amd64 directory in the module path. Copy the driver configuration file to the drv directory in the module path. For example, to copy a driver to /usr/kernel/drv, you would type:

$ su
# cp xx /usr/kernel/drv/amd64
# cp xx.conf /usr/kernel/drv

Note - All driver configuration files (.conf files) must go in the drv directory in the module path. The .conf files cannot go into any subdirectory of the drv directory.


Installing Drivers with add_drv

Use the add_drv(1M) command to install the driver in the system. If the driver installs successfully,add_drv runs devfsadm(1M) to create the logical names in the /dev directory.

# add_drv xx

In this case, the device identifies itself as xx. The device special files have default ownership and permissions (0600 root sys). The add_drv command also allows additional names for the device (aliases) to be specified. See the add_drv(1M) man page for information on adding aliases and setting file permissions explicitly.


Note - Do not use the add_drv command to install a STREAMS module. See the STREAMS Programming Guide for details.


If the driver creates minor nodes that do not represent terminal devices such as disks, tapes, or ports, you can modify /etc/devlink.tab to cause devfsadm to create logical device names in /dev. Alternatively, logical names can be created by a program that is run at driver installation time.

Updating Driver Information

Use the update_drv(1M) command to notify the system of any changes to an installed device driver. By default, the system re-reads the driver configuration file and reloads the driver binary module.

Removing the Driver

To remove a driver from the system, use the rem_drv(1M) command, and then delete the driver module and configuration file from the module path. A driver cannot be used again until that driver is reinstalled with add_drv(1M). The removal of a SCSI HBA driver requires a reboot to take effect.

Previous Next