编写适用于 Oracle® Solaris 11.2 的设备驱动程序

退出打印视图

更新时间: 2014 年 9 月
 
 

驱动程序开发摘要

本章以及后面的两章,Chapter 23, Debugging, Testing, and Tuning Device DriversChapter 24, Recommended Coding Practices,提供了有关开发设备驱动程序的详细信息。

    可采用以下步骤来生成设备驱动程序:

  1. 编写、编译和链接新代码。

    有关文件的命名约定,请参见Driver Code Layout。使用 C 编译器编译驱动程序。使用 ld(1) 链接驱动程序。请参见Compiling and Linking the DriverModule Dependencies

  2. 创建必需的硬件配置文件。

    创建一个特定于名为 xx.conf 的设备的硬件配置文件,其中 xx 为设备的前缀。该文件用于更新 driver.conf(4) 文件。请参见Writing a Hardware Configuration File。对于伪设备驱动程序,需要创建一个 pseudo(4) 文件。

  3. 将驱动程序复制到相应的模块目录。

    请参见Copying the Driver to a Module Directory

  4. 使用 add_drv(1M) 安装设备驱动程序。

    请参见Installing Drivers with add_drvupdate_drv(1M) 命令用于对驱动程序进行更改。请参见Updating Driver Information

  5. 装入驱动程序。

    通过访问设备可自动装入驱动程序。请参见Loading and Unloading Drivers。另外,也可以使用 modload(1M) 命令装入驱动程序。modload 命令不会调用模块中的任何例程,因此适用于进行测试。请参见Loading and Unloading Test Modules

  6. 测试驱动程序。

    驱动程序应在以下方面进行严格的测试:

    有关其他特定于驱动程序的测试,请参见Testing Specific Types of Drivers

  7. 删除驱动程序(如有必要)。

    使用 rem_drv(1M) 命令可删除设备驱动程序。请参见Removing the Driver