⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tty.h

📁 一个用于学习的操作系统
💻 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>#include <fairysky/types.h>#define TTY_BUF_SIZE 1024//tty等待队列数据结构struct tty_queue {    u32 data;       //等待队列缓存区中当前字符行数    u32 head;       //缓存区数据头指针    u32 tail;       //缓存区数据尾指针    struct task_struct * proc_list;     //等待进程列表    char buf[TTY_BUF_SIZE];             //队列的缓存区};#define INC(a)      ((a) = ((a) + 1) & (TTY_BUF_SIZE - 1))      //a缓存区指针向前移1字节,并循环#define DEC(a)      ((a) = ((a) - 1) & (TTY_BUF_SIZE - 1))      //a缓存区指针后退移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))        //缓存区中已存放字符的长度//从queue队列缓存区中取一字符#define GETCH(queue, c) do {        \    c = (queue).buf[(queue).tail];  \    INC((queue).tail);              \}while(0)//往queue队列缓存区中存一字符#define PUTCH(c, queue) do {         \    (queue).buf[(queue).head] = (c);\    INC((queue).head);              \}while(0)#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 {    struct termios termios;     //终端io属性和控制字符数据结构    int pgrp;                   //所属进程组    int stopped;                //停止标志    void (*write)(struct tty_struct * tty);     //tty写函数指针    struct tty_queue read_q;    //tty读队列    struct tty_queue write_q;   //tty写队列    struct tty_queue secondary; //tty规范模式队列};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"extern void init_con(void);extern void init_tty(void);extern void con_write(struct tty_struct * tty);extern void copy_to_cooked(struct tty_struct * tty);#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -