tty设备驱动程序 基于:linux2.6.28

 

2014年09月05日 ⁄ 综合 ⁄ 共 10482字 ⁄ 字号 ⁄ 评论关闭
 

本文源自:http://blog.chinaunix.net/uid-21273878-id-1828727.html

tty设备的数据流通图:

tty设备驱动程序 基于:linux2.6.28
tty设备有三层:tty核心,tty线路规程,tty驱动。
我们写驱动还是只负责最底层的tty驱动。线路规程的设置也是在底层的tty驱动。
tty核心是封装好的。
来看一下tty设备的操作函数:

struct tty_operations
{
       int (*open)(struct
tty_struct * tty,
struct file
* filp);
       void (*close)(struct
tty_struct * tty,
struct file
* filp);
       int (*write)(struct
tty_struct * tty,
                    const
unsigned char
*buf, int
count);
       void (*put_char)(struct tty_struct
*tty,
unsigned char ch);
       void (*flush_chars)(struct tty_struct
*tty);
       int (*write_room)(struct tty_struct
*tty);
       int (*chars_in_buffer)(struct tty_struct
*tty);
       int (*ioctl)(struct tty_struct
*tty,
struct file
* file,
                  unsigned
int cmd, unsigned
long arg);
       long (*compat_ioctl)(struct tty_struct
*tty,
struct file
* file,
                          unsigned
int cmd, unsigned
long arg);
       void (*set_termios)(struct tty_struct
*tty,
struct ktermios * old);
       void (*throttle)(struct tty_struct
* tty);
       void (*unthrottle)(struct tty_struct
* tty);
       void (*stop)(struct tty_struct
*tty);
       void (*start)(struct tty_struct
*tty);
       void (*hangup)(struct tty_struct
*tty);
       void (*break_ctl)(struct tty_struct
*tty,
int state);
       void (*flush_buffer)(struct tty_struct
*tty);
       void (*set_ldisc)(struct tty_struct
*tty);
       void (*wait_until_sent)(struct tty_struct
*tty,
int timeout);
       void (*send_xchar)(struct tty_struct
*tty,
char ch);
       int (*read_proc)