您当前的位置:五五电子网电子知识单片机-工控设备嵌入式系统-技术Linux下的串口驱动的设计层次及接口 正文
Linux下的串口驱动的设计层次及接口

Linux下的串口驱动的设计层次及接口

点击数:7246 次   录入时间:03-04 11:49:30   整理:http://www.55dianzi.com   嵌入式系统-技术

    statIC struct console cs_amba_console = {

    .name = "ttyBM",

    .write = w83697UART_console_write,

    .device = w83697uart_console_device,

    .setup = w83697uart_console_setup,

    .flags = CON_PRINTBUFFER,

    .index = -1,

    };

    串口终端的注册通过下面的函数,将cs_amba_console注册成为终端, 这个函数调用路径是:

    start_kernel()→console_init()→ep93xxuart_w83697_console_init()

    void __init ep93xxuart_w83697_console_init(void)

    终端会对应一种具体设备的driver, 相对于串口这个结构是uart_driver, 在驱动中我们已经提供了一个这样的结构. static struct uart_driver amba_reg, uart_register_driver会将它注册成为终端对应的driver, 因此真正串口与终端的关联就在此处建立.

    函数: static int __init w83697uart_init(void)

    描述: 调用uart_register_driver()完成串口与终端的关联,将串口注册成为一种TTY设备,在uart_register_driver()当中调用tty_register_driver()完成TTY设备注册; 其次是完成串口port口的注册,将静态描述的所有串口port(结构为struct uart_port)注册到uart_driver当中.

    特别说明: 注册串口TTY设备时,由于历史的原因会注册两个TTY设备,一个是normal, 另一个是callout, 是两个设备来的, 在我们这里两者没有什么差别,请看源码中的注解:

    .normal_name = "ttyBM",

    .callout_name = "cuaam",

    /*

    * The callout device is just like the normal device except for

    * the major number and the subtype code.

    */

    函数: static void __exit w83697uart_exit(void)

    描述: 卸截设备,卸截port口,因为我编译的驱动是与内核绑定在一起的,因此实际上根本不会调用此函数.



上一页  [1] [2] [3] [4] [5] 


本文关键字:接口  Linux  嵌入式系统-技术单片机-工控设备 - 嵌入式系统-技术