JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Device Driver Tutorial     Oracle Solaris 11.1 Information Library
search filter icon
search icon

Document Information

Preface

1.  Introduction to Device Drivers

2.  Template Driver Example

Overview of the Template Driver Example

Writing the Template Driver

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

Testing the Template Driver

Adding the Template Driver

Reading and Writing the Device

Removing the Template Driver

Complete Template Driver Source

3.  Reading and Writing Data in Kernel Memory

4.  Tips for Developing Device Drivers

Index

Overview of the Template Driver Example

This example guides you through the following steps:

  1. Create a directory where you can develop your driver and open a new text file named dummy.c.

  2. Write the entry points for loadable module configuration: _init(9E), _info(9E), and _fini(9E).

  3. Write the entry points for autoconfiguration: attach(9E), detach(9E), getinfo(9E), and prop_op(9E).

  4. Write the entry points for user context: open(9E), close(9E), read(9E), and write(9E).

  5. 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).

  6. Create the driver configuration file dummy.conf.

  7. Build and install the driver.

  8. 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

image:Diagram shows the entry points that are to be created in the dummy examples.