企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## 18.9. 快速参考 本节提供了对本章介绍的概念的参考. 它还解释了每个 tty 驱动需要包含的头文件的角色. 在 tty_driver 和 tty_device 结构中的成员变量的列表, 但是, 在这里不重复. ~~~ #include <linux/tty_driver.h> ~~~ 头文件, 包含 struct tty_driver 的定义和声明一些在这个结构中的不同的标志. ~~~ #include <linux/tty.h> ~~~ 头文件, 包含 tty_struct 结构的定义和几个不同的宏定义来易于存取 struct termios 的成员的单个值. 它还含有 tty 驱动核心的函数声明. ~~~ #include <linux/tty_flip.h> ~~~ 头文件, 包含几个 tty flip 缓冲内联函数, 使得易于操作 flip 缓冲结构. ~~~ #include <asm/termios.h> ~~~ 头文件, 包含 struct termio 的定义, 用于内核所建立的特定硬件平台. ~~~ struct tty_driver *alloc_tty_driver(int lines); ~~~ 函数, 创建一个 struct tty_driver, 可之后传递给 tty_register_driver 和 tty_unregister_driver 函数. ~~~ void put_tty_driver(struct tty_driver *driver); ~~~ 函数, 清理尚未成功注册到 tty 内核的 struct tty_driver 结构. ~~~ void tty_set_operations(struct tty_driver *driver, struct tty_operations *op); ~~~ 函数, 初始化 struct tty_driver 的函数回调. 有必要在 tty_register_driver 可被调用前调用. ~~~ int tty_register_driver(struct tty_driver *driver);int tty_unregister_driver(struct tty_driver *driver); ~~~ 函数, 从 tty 核心注册和注销一个 tty 驱动. ~~~ void tty_register_device(struct tty_driver *driver, unsigned minor, struct device *device); void tty_unregister_device(struct tty_driver *driver, unsigned minor); ~~~ 对 tty 核心注册和注销一个单个 tty 设备的函数. ~~~ void tty_insert_flip_char(struct tty_struct *tty, unsigned char ch, char flag); ~~~ 插入字符到 tty 设备的要被用户读的 flip 缓冲的函数. ~~~ TTY_NORMAL TTY_BREAK TTY_FRAME TTY_PARITY TTY_OVERRUN ~~~ flag 参数的不同值, 用在 tty_insert_flip_char 函数. ~~~ int tty_get_baud_rate(struct tty_struct *tty); ~~~ 函数, 获取当前为特定 tty 设备设置的波特率. ~~~ void tty_flip_buffer_push(struct tty_struct *tty); ~~~ 函数, 将当前 flip 缓冲中的数据推给用户. ~~~ tty_std_termios ~~~ 变量, 使用一套通用的缺省线路设置来初始化一个 termios 结构.