TTY驱动读写流程随笔

如:

write

write —> fd

tty_write()
	do_tty_write()
	1
		struct tty_struct *tty
			struct tty_ldisc *ldisc;
				struct tty_ldisc_ops *ops;
					// n_tty_write()
					write)(struct tty_struct *tty, struct file *file, const unsigned char *buf, size_t nr) -----------------------------------------ldisc层  
																|
                                                                |
		                                                        |
		                                                        |
		struct tty_struct *tty                                  |
			const struct tty_operations *ops;                   |
				//uart_write()									|
				int  (*write)(struct tty_struct * tty,const unsigned char *buf, int count); -------------------------------------core层
					//将数据存储到								|
					struct uart_state                           |
						struct circ_buf	xmit;                   |
                                                                |
                                                                |
		                                                        |
		                                                        |
		struct tty_struct                                       |
			struct uart_state                                   |
				struct uart_port  *uart_port                    |
					const struct uart_ops	*ops;               |
						(*start_tx)(struct uart_port *); -------+   -------------------------------- uart层

写流程:

TTY驱动读写流程随笔_第1张图片

读流程

TTY驱动读写流程随笔_第2张图片

你可能感兴趣的:(TTY驱动,TTY驱动)