Skip Navigation Links | |
Exit Print View | |
Device Driver Tutorial Oracle Solaris 11.1 Information Library |
1. Introduction to Device Drivers
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
Building and Installing the Template Driver
Reading and Writing the Device
Complete Template Driver Source
3. Reading and Writing Data in Kernel Memory
This example guides you through the following steps:
Create a directory where you can develop your driver and open a new text file named dummy.c.
Write the entry points for loadable module configuration: _init(9E), _info(9E), and _fini(9E).
Write the entry points for autoconfiguration: attach(9E), detach(9E), getinfo(9E), and prop_op(9E).
Write the entry points for user context: open(9E), close(9E), read(9E), and write(9E).
Define the data structures: the character and block operations structure cb_ops(9S), the device operations structure dev_ops(9S), and the module linkage structures modldrv(9S) and modlinkage(9S).
Create the driver configuration file dummy.conf.
Build and install the driver.
Test the driver by loading the driver, reading from and writing to the device node, and unloading the driver.
The entry points that are to be created in this example are shown in the following diagram.
Figure 2-1 Entry Points for the dummy Example