论文部分内容阅读
摘要:嵌入式操作系统I/O驱动系统的设计与实现是实现嵌入式操作系统应用的关键问题。 文章,首先给出I/O驱动的硬件设计;其次,针对硬件给出I/O驱动程序的模块初始化、模块的卸载、设备文件操作接口定义与实现的详细设计过程;最后,给出驱动模块的加载过程与测试方法。
关键词:嵌入式操作系统;驱动程序;内核;系统调用
中图分类号:TP316文献标识码:A文章编号:1009-3044(2008)09-11742-03
Research of I/O Driver of Embedded Operating System
XIAO Yao-nan, XIAO Liao-liang
(Hunan Railway Professional-Technology College, Zhuzhou 412001, China)
Abstract: The design and implementation of driver system of EOS is the key point for the application of EOS. In this paper, Firstly, the hardware design of the I/O driver is proposed; Secondly, the design of module initialization, module exit, interface definition and implementation of the equipment file operation is presented; Finally, the process of mounding the driver and the test method is presented.
Key words: EOS; Driver; Kernel; System Call
1 引言
随着微处理器技术的发展,嵌入式操作系统越来越微型化和专业化,嵌入式系统已经成为计算机应用领域的一个重要组成部分。根据应用场景设计硬件电路,裁剪系统内核,并量身定制应用场景驱动程序是目前嵌入式操作系统到实际应用的关键技术。为此,文章对嵌入式操作系统I/O驱动的硬件设计、I/O驱动程序设计、驱动模块的编译与测试三个方面进行了一些研究。
2 嵌入式操作系统I/O驱动的设计
2.1 I/O驱动的硬件设计
本文以S3C44B0X作为控制CPU,本系统利用74HC574对S3C44B0X的数据端口进行扩展,地址线BA20~BA22通LC138扩展,形成集成块的片选信号。当地址信号为0x10000000时,I/O_CS0低电平有效,即选中IC12,当地址信号 0x10200000时,I/O_CS2低电平有效,将选中其它集成块,精简I/O驱动扩展电路如图1所示。
以下将针对图1驱动模块硬件结构详细分析I/O驱动程序的编写方法并给出设计过程。
2.2.1 模块初始化
模块初始化module_init(Xiao_I/O_Opr_init)函数通过参数Xiao_I/O_Opr_init调用I/O端口驱动模块初始化函数static int_init Xiao_I/O_Opr_init(void),该函数利用系统函数void * ioremap(unsigned long offset, unsigned long size)为片选信号BA22~BA20分配内存I/O虚拟地址,从而设备驱动程序能访问I/O内存地址。同时,在模块初始化函数中,register_chrdev()函数完成字符设备在内核系统中的注册,并建立与文件系统(Xiao_fops)的关联。模块初始化函数如下所示:
#define DEVICE_NAME "Xiao_I/O_Opr"
#define SEG_CS00x10000000 //A22,A21,A20=000 ->I/O_CS0
#define SEG_CS10x10200000 //A22,A21,A20=010 ->I/O_CS1
#define SEG_CS20x10300000 //A22,A21,A20=011 ->I/O_CS2
static int_init Xiao_I/O_Opr_init(void)
{ int ret;
cs1_address=ioremap(I/O_CS0, 4);
cs2_address=ioremap(I/O_CS1, 4);
cs3_address=ioremap(I/O_CS2, 4);
ret = register_chrdev(61, DEVICE_NAME,
关键词:嵌入式操作系统;驱动程序;内核;系统调用
中图分类号:TP316文献标识码:A文章编号:1009-3044(2008)09-11742-03
Research of I/O Driver of Embedded Operating System
XIAO Yao-nan, XIAO Liao-liang
(Hunan Railway Professional-Technology College, Zhuzhou 412001, China)
Abstract: The design and implementation of driver system of EOS is the key point for the application of EOS. In this paper, Firstly, the hardware design of the I/O driver is proposed; Secondly, the design of module initialization, module exit, interface definition and implementation of the equipment file operation is presented; Finally, the process of mounding the driver and the test method is presented.
Key words: EOS; Driver; Kernel; System Call
1 引言
随着微处理器技术的发展,嵌入式操作系统越来越微型化和专业化,嵌入式系统已经成为计算机应用领域的一个重要组成部分。根据应用场景设计硬件电路,裁剪系统内核,并量身定制应用场景驱动程序是目前嵌入式操作系统到实际应用的关键技术。为此,文章对嵌入式操作系统I/O驱动的硬件设计、I/O驱动程序设计、驱动模块的编译与测试三个方面进行了一些研究。
2 嵌入式操作系统I/O驱动的设计
2.1 I/O驱动的硬件设计
本文以S3C44B0X作为控制CPU,本系统利用74HC574对S3C44B0X的数据端口进行扩展,地址线BA20~BA22通LC138扩展,形成集成块的片选信号。当地址信号为0x10000000时,I/O_CS0低电平有效,即选中IC12,当地址信号 0x10200000时,I/O_CS2低电平有效,将选中其它集成块,精简I/O驱动扩展电路如图1所示。

以下将针对图1驱动模块硬件结构详细分析I/O驱动程序的编写方法并给出设计过程。
2.2.1 模块初始化
模块初始化module_init(Xiao_I/O_Opr_init)函数通过参数Xiao_I/O_Opr_init调用I/O端口驱动模块初始化函数static int_init Xiao_I/O_Opr_init(void),该函数利用系统函数void * ioremap(unsigned long offset, unsigned long size)为片选信号BA22~BA20分配内存I/O虚拟地址,从而设备驱动程序能访问I/O内存地址。同时,在模块初始化函数中,register_chrdev()函数完成字符设备在内核系统中的注册,并建立与文件系统(Xiao_fops)的关联。模块初始化函数如下所示:
#define DEVICE_NAME "Xiao_I/O_Opr"
#define SEG_CS00x10000000 //A22,A21,A20=000 ->I/O_CS0
#define SEG_CS10x10200000 //A22,A21,A20=010 ->I/O_CS1
#define SEG_CS20x10300000 //A22,A21,A20=011 ->I/O_CS2
static int_init Xiao_I/O_Opr_init(void)
{ int ret;
cs1_address=ioremap(I/O_CS0, 4);
cs2_address=ioremap(I/O_CS1, 4);
cs3_address=ioremap(I/O_CS2, 4);
ret = register_chrdev(61, DEVICE_NAME,