Skip Navigation Links | |
Exit Print View | |
Device Driver Tutorial Oracle Solaris 11.1 Information Library |
1. Introduction to Device Drivers
Overview of the Template Driver Example
Writing the Loadable Module Configuration Entry Points
Declaring the Loadable Module Configuration Entry Points
Defining the Module Initialization Entry Point
Defining the Module Information Entry Point
Defining the Module Unload Entry Point
Including Loadable Module Configuration Header Files
Writing the Autoconfiguration Entry Points
Declaring the Autoconfiguration Entry Points
Defining the Device Attach Entry Point
Defining the Device Detach Entry Point
Defining the Get Driver Information Entry Point
Defining the Report Driver Property Information Entry Point
Including Autoconfiguration Header Files
Writing the User Context Entry Points
Declaring the User Context Entry Points
Defining the Open Device Entry Point
Defining the Close Device Entry Point
Defining the Read Device Entry Point
Defining the Write Device Entry Point
Including User Context Header Files
Writing the Driver Data Structures
Defining the Character and Block Operations Structure
Defining the Device Operations Structure
Defining the Module Linkage Structures
Including Data Structures Header Files
Writing the Device Configuration File
Reading and Writing the Device
Complete Template Driver Source
3. Reading and Writing Data in Kernel Memory
This section shows you how to build and install the driver for a 32-bit platform. See Building a Driver and Installing a Driver for build and install instructions for SPARC architectures and for 64-bit x86 architectures.
Compile and link the driver. Use the -D_KERNEL option to indicate that this code defines a kernel module. The following example shows compiling and linking for a 32-bit architecture using the Oracle Solaris Studio C compiler:
% cc -D_KERNEL -c dummy.c % ld -r -o dummy dummy.o
Make sure you are user root when you install the driver.
Install drivers in the /tmp directory until you are finished modifying and testing the _info(), _init(), and attach() routines. Copy the driver binary to the /tmp directory. Link to the driver from the kernel driver directory. See Device Driver Testing Tips for more information.
# cp dummy /tmp
Link to the following directory for a 32-bit architecture:
# ln -s /tmp/dummy /usr/kernel/drv/dummy
Copy the configuration file to the kernel driver area of the system.
# cp dummy.conf /usr/kernel/drv