Skip Navigation Links | |
Exit Print View | |
Writing Device Drivers Oracle Solaris 11.1 Information Library |
Part I Designing Device Drivers for the Oracle Solaris Platform
1. Overview of Oracle Solaris Device Drivers
2. Oracle Solaris Kernel and Device Tree
5. Managing Events and Queueing Tasks
7. Device Access: Programmed I/O
10. Mapping Device and Kernel Memory
13. Hardening Oracle Solaris Drivers
14. Layered Driver Interface (LDI)
Part II Designing Specific Kinds of Device Drivers
15. Drivers for Character Devices
18. SCSI Host Bus Adapter Drivers
19. Drivers for Network Devices
Part III Building a Device Driver
22. Compiling, Loading, Packaging, and Testing Drivers
Preparing for Driver Installation
Compiling and Linking the Driver
Writing a Hardware Configuration File
Installing, Updating, and Removing Drivers
Copying the Driver to a Module Directory
Stress, Performance, and Interoperability Testing
Installation and Packaging Testing
Testing Specific Types of Drivers
Asynchronous Communication Drivers
23. Debugging, Testing, and Tuning Device Drivers
24. Recommended Coding Practices
B. Summary of Oracle Solaris DDI/DKI Services
C. Making a Device Driver 64-Bit Ready
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.
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:
Contains 64-bit drivers that run only on a specific SPARC-based platform.
Contains 64-bit drivers that run only on a specific x86-based platform.
Contains 32-bit drivers that run only on a specific family of platforms.
Contains 64-bit drivers that run only on a specific family of SPARC-based platforms.
Contains 64-bit drivers that run only on a specific family of x86-based platforms.
Contains 32-bit drivers that are independent of platforms.
Contains 64-bit drivers on SPARC-based systems that are independent of platforms.
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.
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.
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.
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.