http://docs.oracle.com/cd/E18752_01/html/817-5789/frymm.html
Development environment and tools
更多信息:http://docs.oracle.com/cd/E18752_01/html/816-4854/fcaqh.html#DRIVERfcaqh
写一个 device driver 的一般步骤:
1. 使用9E,9F,9S 中定义的接口和结构写一个C源程序,大部分需要的include files 在/usr/include/sys.中。function 和结构 man pages显示了你需要哪些文件。
2. 写一个.conf 硬件配置文件来定义你的 driver 的属性值。
3. 编译链接你的driver,当为Solaris OS编译一个driver时经常使用-D_KERNEL 选项。默认的编译结果是32位的。为了在64位平台上得到一个64位的结果,参考
http://docs.oracle.com/cd/E18752_01/html/817-5789/frymm.html#fgouv
4. 复制你的driver 的二进制文件和配置文件到合适的[platform]/kernel 目录。http://docs.oracle.com/cd/E18752_01/html/817-5789/emjjp.html#fgomm对driver目录的描述。
5. 用add_drv 命令导入你的driver。你的driver导入后,可以在/dev 和/devices 中看到。还可以在/etc/name_to_major文件中看到你的driver 到entry。
Writing a driver (由C源程序和硬件配置文件组成)
Writing a driver module
driver的c程序就是数据和函数到总和,driver中是没有main()的。对于一个driver许多subroutines 有特定到功能,我们叫他们entry point . Function man page 提供driver中需要到function的声明和需要include进去的头文件。确定你找到了正确的man page。例如,下面到这条命令显示ioct1 man page.但是ioct1 系统调用不能应用到device driver中。
% man ioct1
用下面两个命令中的一个来显示ioct1的man page。ioct1的subroutine 是一个device driver 的entry point。
% man ioct1.9e
% man -s 9e ioct1
64位系统可以跑32位或64位的用户程序(kernel 不行),只是在运行32位用户程序时需要在两种数据模型中进行数据转换。http://docs.oracle.com/cd/E18752_01/html/817-5789/ffdqq.html#fgham
Sun studio IDE 包括以下三种源代码编辑器:GVM、XEmacs和NetBeans 提供的Source Editor。IDE 提供这些工具的在线帮助,也可以在命令行运行GVIM 和XEmacs。
Writing a Configuration file
一个不能self-identifying 的driver 一定要有配置文件 node_name.conf ,node_name是为device预先设定好的。self_identifying driver指的是driver可以从DDI属性接口(ddi_prop_get_int(9F) and ddi_prop_lookup(9F))中得到所有他需要到属性信息。一个配置文件至少要包含device的名字,和device‘s parent 的名字或类型。
For more information about device driver configuration files, see the driver.conf(4) manpage. For an example configuration file, see Writing the Device Configuration File
tips
9E :http://docs.oracle.com/cd/E23824_01/html/821-1476/gentextid-845.html#scrolltoc
9F :http://docs.oracle.com/cd/E23824_01/html/821-1477/gentextid-4704.html#scrolltoc
9S :http://docs.oracle.com/cd/E23824_01/html/821-1476/gentextid-845.html#scrolltoc