📄 tty.h
字号:
/* * 'tty.h' defines some structures used by tty_io.c and some defines. * * NOTE! Don't touch this without checking that nothing in rs_io.s or * con_io.s breaks. Some constants are hardwired into the system (mainly * offsets into 'tty_queue' */#ifndef _TTY_H#define _TTY_H#include <termios.h>#define TTY_BUF_SIZE 1024struct tty_queue { /*由终端所处理的数据所构成的缓冲队列*/ unsigned long data;/*该缓冲区队列中数据的行数(对于串行终端则是指其端口号)*/ unsigned long head;/*缓冲区中数据头指针*/ unsigned long tail;/*缓冲区中数据尾指针*/ struct task_struct * proc_list;/*等待该缓冲区队列的进程列表*/ char buf[TTY_BUF_SIZE];/*该队列的缓冲区*/};#define INC(a) ((a) = ((a)+1) & (TTY_BUF_SIZE-1))#define DEC(a) ((a) = ((a)-1) & (TTY_BUF_SIZE-1))#define EMPTY(a) ((a).head == (a).tail)#define LEFT(a) (((a).tail-(a).head-1)&(TTY_BUF_SIZE-1))#define LAST(a) ((a).buf[(TTY_BUF_SIZE-1)&((a).head-1)])#define FULL(a) (!LEFT(a))#define CHARS(a) (((a).head-(a).tail)&(TTY_BUF_SIZE-1))#define GETCH(queue,c) \(void)({c=(queue).buf[(queue).tail];INC((queue).tail);})#define PUTCH(c,queue) \(void)({(queue).buf[(queue).head]=(c);INC((queue).head);})#define INTR_CHAR(tty) ((tty)->termios.c_cc[VINTR])#define QUIT_CHAR(tty) ((tty)->termios.c_cc[VQUIT])#define ERASE_CHAR(tty) ((tty)->termios.c_cc[VERASE])#define KILL_CHAR(tty) ((tty)->termios.c_cc[VKILL])#define EOF_CHAR(tty) ((tty)->termios.c_cc[VEOF])#define START_CHAR(tty) ((tty)->termios.c_cc[VSTART])#define STOP_CHAR(tty) ((tty)->termios.c_cc[VSTOP])#define SUSPEND_CHAR(tty) ((tty)->termios.c_cc[VSUSP])struct tty_struct { /*终端设备结构(支持3个终端设备:控制台及2个串行终端)*/ struct termios termios; /*io属性(termios.h)*/ int pgrp; /*所属进程组*/ int stopped; /*终端是否停止*/ void (*write)(struct tty_struct * tty); /*终端设备的输出处理函数(控制台:驱动显示硬件,在屏幕上显示信息;串行终端:将字符发送置串行端口)*/ struct tty_queue read_q; /*tty读队列,临时存放从终端输入的字符,在读入用户输入的字符时,中断处理汇编程序仅仅是将字符放入该队列中,而由中断程序所调用的copy_to_cooked来处理字符的变换工作*/ struct tty_queue write_q;/*tty写队列,临时存放写入终端的字符*/ struct tty_queue secondary; /*tty辅助队列,临时存放从read_q中读入并经过规则程序处理过的字符*/ };extern struct tty_struct tty_table[];/* intr=^C quit=^| erase=del kill=^U eof=^D vtime=\0 vmin=\1 sxtc=\0 start=^Q stop=^S susp=^Z eol=\0 reprint=^R discard=^U werase=^W lnext=^V eol2=\0*/#define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"void rs_init(void);void con_init(void);void tty_init(void);int tty_read(unsigned c, char * buf, int n);int tty_write(unsigned c, char * buf, int n);void rs_write(struct tty_struct * tty);void con_write(struct tty_struct * tty);void copy_to_cooked(struct tty_struct * tty);#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -