摘要: 1. serial8250_init serial8250_init 函数是模块的入口, static int __init serial8250_init(void) { int ret; if (nr_uarts == 0) return -ENODEV; serial8250_isa_init 阅读全文
posted @ 2020-08-07 11:30 glob 阅读(1142) 评论(0) 推荐(0) 编辑
摘要: 1. printk.c 中的重要变量 首先介绍一些 kernel/printk/printk.c 中定义的一些十分重要的变量。 /* console_sem用来保护对console_drivers列表的访问 */ static DEFINE_SEMAPHORE(console_sem); /* co 阅读全文
posted @ 2020-08-07 11:29 glob 阅读(851) 评论(0) 推荐(1) 编辑
摘要: 1. echo sdf > /dev/ttyS0 tty_cdev_add 给 tty driver 分配字符设备,设置字符设备的文件操作函数指针指向 tty_fops ,后者的写函数为 tty_write 。 static int tty_cdev_add(struct tty_driver *d 阅读全文
posted @ 2020-08-07 11:27 glob 阅读(501) 评论(0) 推荐(0) 编辑
摘要: 1. workqueue tty 借助 workqueue 实现串口读写操作之间的同步。 tty_port 结构体中的 struct tty_bufhead buf 成员有一个 struct work_struct work 成员, drivers/tty/tty_buffer.c 中的 tty_b 阅读全文
posted @ 2020-08-07 11:25 glob 阅读(793) 评论(0) 推荐(0) 编辑
摘要: 1. tty_init 作为字符设备的一员, tty 设备的初始化函数 tty_init 在 drivers/char/mem.c 中的 chr_dev_init 调用。后者声明为 fs_initcall(chr_dev_init); 。 tty_init 的详细说明如下: int __init t 阅读全文
posted @ 2020-08-07 11:23 glob 阅读(752) 评论(0) 推荐(0) 编辑
摘要: 1. 设置 tty 参数 设置 tty 参数时会设置 tty_struct 内 disc_data 的一些成员变量: struct n_tty_data { ... /* must hold exclusive termios_rwsem to reset these */ unsigned cha 阅读全文
posted @ 2020-08-07 11:22 glob 阅读(901) 评论(0) 推荐(0) 编辑
摘要: 1. line discipline line discipline 介于 TTY 层和具体的串口驱动 ( 比如 serial8250 ) 之间。 发送数据时,应用程序通过系统调用向 TTY 设备文件写入数据,进而调用 TTY 层驱动程序执行写操作。 TTY 层驱动程序调用 line discipl 阅读全文
posted @ 2020-08-07 11:21 glob 阅读(877) 评论(0) 推荐(0) 编辑
摘要: serial8250_init 使用的数据结构很多,按照自顶向下的顺序介绍,即从更一般的 TTY 层到更具体的 8250 层。 介绍这些数据结构时,以 serial8250_init 执行时设置的各个成员变量的值为例进行说明。 每个设备保存自己的 port 信息,用 struct tty_port 阅读全文
posted @ 2020-08-07 11:17 glob 阅读(220) 评论(0) 推荐(0) 编辑