zoukankan      html  css  js  c++  java
  • 《精通linux设备驱动程序开发》 第6章串行设备驱动程序 学习笔记

    主要内容:

    • 层次结构
    • UART驱动程序
    • TTY驱动程序

    1. 层次结构

    UARTUniversal Asynchronous Receiver Transmitter,通用异步收发器)常用来实现串行通信。

    内核开发者使用如下的构建模块去构造层次的串行架构。

    (1)关注UART或其他底层串行硬件特征的底层驱动程序;

    (2)和底层驱动程序接口的tty驱动程序层;

    (3)加工用于和tty驱动程序交换数据的线路规程;

    2. UART驱动程序

    UART驱动程序围绕3个关键的数据结构展开,都定义在include/linux/serial_core.h中。

    (1)特定UART相关的驱动程序结构

    struct uart_driver {
        struct module *owner;
        const char *driver_name;
        const char *dev_name;
        /* ... */
        int major;
        int minor;
        /* ... */
        struct tty_driver *tty_driver;
    };

    (2)Struct uart_port UART驱动程序端口存在uart_port结构的实例;

    struct uart_port {
        spinlock_t lock;
        unsigned int iobase;
        unsigned char __iomem *membase;
        unsigned int irq;
        unsigned int uartclk;
        unsigned int fifosize;
        unsigned char x_char;
        /* ... */
    };

    (3)Struct uart_ops 是每个UART驱动程序必须支持的物理硬件上可完成的操作入口函数的超集;

    3. tty驱动程序

    Tty驱动程序和核心结构和注册函数,有三个重要结构:
    1)定义于include/linux/tty.h中的struct tty_struct,包含了和打开tty相关的所有状态信息;

    (2)tty_struct中内嵌的struct tty_flip_buffer flip缓冲区。是数据收集和处理机制的中枢;

    (3)定义于include/linux/tty_driver.h文件中的struct tty_driver,规定了tty驱动程序和高层之间的编程接口;

    stay hungry, stay foolish
  • 相关阅读:
    【C++注意事项】1 数据类型及类型转换
    【万里征程——Windows App开发】动态磁贴
    背包问题
    Fence Repair
    Saruman's Army
    字典序最小问题——Best Cow Line
    区间调度问题
    硬币问题
    数据库查询优化的一些总结
    关于减少BUG的思考
  • 原文地址:https://www.cnblogs.com/zygote/p/13557125.html
Copyright © 2011-2022 走看看