3、核心结构体

#include

struct tty_driver {

int magic;  /*幻数,通常被设置为TTY_DRIVER_MAGIC。在alloc_tty_driver函数中被初始化*/

struct kref kref; /* Reference management */

struct cdev cdev;

struct module *owner;/*驱动模块的所有者*/

const char *driver_name;/*驱动程序的名称,在/proc/tty和sysfs中使用*/

const char *name;/*驱动节点的名字*/

int name_base; /*为穿件设备名字而使用的开始编号*/

int major;  /*驱动程序的主设备号*/

int minor_start; /*驱动程序使用的最小次设备号*/

int minor_num; /* number of *possible* devices */

int num;  /*可以分配给驱动程序次设备号的个数*/

short type;  /* type of tty driver */

short subtype; /* subtype of tty driver */

struct ktermios init_termios; /*当被创建时,含有初始值的termios结构*/

int flags;  /*驱动程序标志位*/

struct proc_dir_entry *proc_entry; /*驱动程序的/proc入口结构体*/

struct tty_driver *other; /*指向tty从属设备驱动程序的指针*/

/*

* Pointer to the tty data structures

*/

struct tty_struct **ttys;

struct ktermios **termios;

struct ktermios **termios_locked;

void *driver_state;

/*

* Driver methods

*/

const struct tty_operations *ops;

struct list_head tty_drivers;

};

#include

struct tty_operations {

struct tty_struct * (*lookup)(struct tty_driver *driver,

struct inode *inode, int idx);

int  (*install)(struct tty_driver *driver, struct tty_struct *tty);

void (*remove)(struct tty_driver *driver, struct tty_struct *tty);

int  (*open)(struct tty_struct * tty, struct file * filp);/*open函数*/

void (*close)(struct tty_struct * tty, struct file * filp);/*close函数*/

void (*shutdown)(struct tty_struct *tty);

void (*cleanup)(struct tty_struct *tty);

int  (*write)(struct tty_struct * tty,

const unsigned char *buf, int count);/*write函数*/

int  (*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,

unsigned int cmd, unsigned long arg);/*当设备节点的调用ioctl(2)时,该函数被tty核心调用*/

long (*compat_ioctl)(struct tty_struct *tty,

unsigned int cmd, unsigned long arg);

void (*set_termios)(struct tty_struct *tty, struct ktermios * old);/*改变设备的termios设置*/

void (*throttle)(struct tty_struct * tty);/*当tty核心的输入缓冲区满的时候,调用该函数。

tty驱动程序将试图通知设备,不要再发送更多的字符。*/

void (*unthrottle)(struct tty_struct * tty);/*当tty核心的输入缓冲区被清空是,调用该函数,使能其接受更多的数据*/

void (*stop)(struct tty_struct *tty);/*tty驱动程序将停止向设备发送数据*/

void (*start)(struct tty_struct *tty);/*恢复数据的传送*/

void (*hangup)(struct tty_struct *tty);/*当tty驱动程序挂起tty设备时,调用该函数。此时对任何特定硬件的操作应当被挂起*/

int (*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);/*发送X类型的字符函数。要发送的字符放在ch变量中*/

int (*tiocmget)(struct tty_struct *tty);/*获得特定tty设备当前的线路设置*/

int (*tiocmset)(struct tty_struct *tty,

unsigned int set, unsigned int clear);/*为特定的tty设备设置当前线路*/

int (*resize)(struct tty_struct *tty, struct winsize *ws);

int (*set_termiox)(struct tty_struct *tty, struct termiox *tnew);

int (*get_icount)(struct tty_struct *tty,

struct serial_icounter_struct *icount);

#ifdef CONFIG_CONSOLE_POLL

int (*poll_init)(struct tty_driver *driver, int line, char *options);

int (*poll_get_char)(struct tty_driver *driver, int line);

void (*poll_put_char)(struct tty_driver *driver, int line, char ch);

#endif

const struct file_operations *proc_fops;

};

linux下进程的tty,Linux下TTY驱动程序分析相关推荐

  1. linux下进程监控6,Linux进程监控技术—精通软件性能测试与LoadRunner最佳实战(6)...

    8.2.5  Linux操作系统进程监控技术 Linux在进程监控方面同样出色,不仅可以通过图形用户界面的管理工具,还可以用命令方式显示进程相关信息.像"Windows的任务管理器" ...

  2. linux下进程调度算法实验,Linux下进程调度算法的模拟实现.doc

    Linux下进程调度算法的模拟实现 枣 庄 学 院 信息科学与工程学院课程设计任务书 题目: Linux下进程调度算法的模拟实现 学 生1: 学 生2: 学 生3: 专 业: 计算机应用技术 课 程: ...

  3. linux通过进程看端口,linux下通过进程名查看其占用端口

    linux下通过进程名查看其占用端口: 1.先查看进程pid ps -ef | grep 进程名 2.通过pid查看占用端口 netstat -nap | grep 进程pid 例:通过nginx进程 ...

  4. linux php进程端口占用,linux如何查看端口占用情况

    在linux中可以使用lsof和netstat命令来查看端口占用情况,其中lsof语法为"lsof -i:端口号",netstat语法为"netstat -tunlp | ...

  5. linux结束进程_生人勿近之Linux里养僵尸

    Linux里养僵尸是怎么回事呢?Linux相信大家都很熟悉,但是Linux里养僵尸是怎么回事呢,下面就让小编带大家一起了解吧. - 1 - 上一篇挖了个 SIGHUP 的坑,这篇试着填一下. 之前在& ...

  6. linux端口进程号pid,Linux根据端口号查看进程PID

    1.命令lsof,以查找占用端口80为例,用法如下: [root@localhost nginx]# lsof -i:80 以上为没有进程占用80端口, [root@localhost sbin]# ...

  7. linux runable进程查询,关于Linux下进程的详解【进程查看与管理】

    一.关于进程 进程: 已经启动的可执行程序的运行实力 进程的组成:一个进程包含内核中的一部分地址空间和一系列数据结构.其中地址空间是内核标记的一部分内存以供进程使用,而数据结构则用来纪录每个进程的具体 ...

  8. linux按进程分配物理内存,linux下内存管理学习心得(一)

    最近在学习内存管理的时候,发现对linux下的所谓内存如何管理如何分配都不熟悉,通过最近的查阅资料可总结如下,如有不妥之处欢迎大家批评与指正. 总的的来说linux的内存管理其实主要难理解的是以下几个 ...

  9. linux java进程消失_Linux系统下的Java进程无故消失怎么办?

    Linux系统步骤的一些Java项目总是无故的消失,原来是Java进程被关闭掉了.为什么会出现这种情况呢?有可能是被系统自动清除多余进程,或是其他程序关掉了Java项目,这个时候该怎么办呢? 解决方法 ...

  10. linux查看进程grep工作组,Linux下查看一个进程打开了哪...-linux 如何找到进程的工作目录...-使用 grep 恢复误删的文本文件_169IT.COM...

    Linux下查看一个进程打开了哪些文件的命令示例,供大家学习参考. 查看进程14755(httpd)打开了哪些文件: 代码如下: localhost:~# lsof -p 14755 COMMAND ...

最新文章

  1. java中map使用非系统类作为key
  2. C#Redis集合set
  3. 《sed的流艺术之四》-linux命令五分钟系列之二十四
  4. C++11新特性- for语句
  5. How to Set up SSH Tunneling (Port Forwarding)?
  6. 微软更懂“怎样尊重程序员”,正在改进程序员招聘流程
  7. java try catch_Java捕获异常
  8. scrapy爬虫系列之五--CrawlSpider的使用
  9. C#学习笔记之-----倒序输出字符串
  10. 使用MFC开发ActiveX控件
  11. [读书笔记] - 《深度探索C++对象模型》第2章 构造函数语意学
  12. Tokenizers: How machines read
  13. 重装ubuntu系统后VS Code远程连接失败
  14. 群晖服务器怎么做文件转移,群晖(黑) 篇五:群晖系统迁移:旧群晖数据和系统转移到新机器...
  15. C++语言特性的性能分析
  16. 如何打出日语中的叠字符号「々」
  17. 神经网络之输出层设计
  18. 推荐系统(四)——因果效应uplift model系列模型S-Learner,T-Learner,X-Learner
  19. 【Web技术】1431- 总结前端主题切换的思考和现代前端样式的解决方案落地
  20. 【Unity连载】斗兽棋-棋类游戏开发演示(2)

热门文章

  1. c语言u64数据类型打印,小谈C语言中常见数据类型在32及64位机上的使用
  2. 超级计算机排名表格,全球超级计算机500强_科技时代首页_新浪网
  3. Java的浅拷贝与深拷贝总结
  4. c语言常用绘图软件,大佬们,小菜鸟想问一问用vc编译器做简易画图软件
  5. mysql联合查询数量不一致_Mybatis关联查询,查询出的记录数量与数据库直接查询不一致,如何解决?...
  6. html中和over怎么显示div,js 解决隐藏与显示div的相关问题
  7. TestNG测试框架之失败测试重跑
  8. Jmeter自定义函数和引入外部文件的几种方法
  9. python语言的格式框架_django框架模板语言使用方法详解
  10. linux vga 分辨率低,vga输出 1440x900 分辨率问题