📄 tty.h
字号:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/kernel/tty.h
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
11600 /* tty.h - Terminals */
11601
11602 #define TTY_IN_BYTES 256 /* tty input queue size */
11603 #define TAB_SIZE 8 /* distance between tab stops */
11604 #define TAB_MASK 7 /* mask to compute a tab stop position */
11605
11606 #define ESC '\33' /* escape */
11607
11608 #define O_NOCTTY 00400 /* from <fcntl.h>, or cc will choke */
11609 #define O_NONBLOCK 04000
11610
11611 typedef _PROTOTYPE( void (*devfun_t), (struct tty *tp) );
11612 typedef _PROTOTYPE( void (*devfunarg_t), (struct tty *tp, int c) );
11613
11614 typedef struct tty {
11615 int tty_events; /* set when TTY should inspect this line */
11616
11617 /* Input queue. Typed characters are stored here until read by a program. */
11618 u16_t *tty_inhead; /* pointer to place where next char goes */
11619 u16_t *tty_intail; /* pointer to next char to be given to prog */
11620 int tty_incount; /* # chars in the input queue */
11621 int tty_eotct; /* number of "line breaks" in input queue */
11622 devfun_t tty_devread; /* routine to read from low level buffers */
11623 devfun_t tty_icancel; /* cancel any device input */
11624 int tty_min; /* minimum requested #chars in input queue */
11625 clock_t tty_time; /* time when the input is available */
11626 struct tty *tty_timenext; /* for a list of ttys with active timers */
11627
11628 /* Output section. */
11629 devfun_t tty_devwrite; /* routine to start actual device output */
11630 devfunarg_t tty_echo; /* routine to echo characters input */
11631 devfun_t tty_ocancel; /* cancel any ongoing device output */
11632 devfun_t tty_break; /* let the device send a break */
11633
11634 /* Terminal parameters and status. */
11635 int tty_position; /* current position on the screen for echoing */
11636 char tty_reprint; /* 1 when echoed input messed up, else 0 */
11637 char tty_escaped; /* 1 when LNEXT (^V) just seen, else 0 */
11638 char tty_inhibited; /* 1 when STOP (^S) just seen (stops output) */
11639 char tty_pgrp; /* slot number of controlling process */
11640 char tty_openct; /* count of number of opens of this tty */
11641
11642 /* Information about incomplete I/O requests is stored here. */
11643 char tty_inrepcode; /* reply code, TASK_REPLY or REVIVE */
11644 char tty_incaller; /* process that made the call (usually FS) */
11645 char tty_inproc; /* process that wants to read from tty */
11646 vir_bytes tty_in_vir; /* virtual address where data is to go */
11647 int tty_inleft; /* how many chars are still needed */
11648 int tty_incum; /* # chars input so far */
11649 char tty_outrepcode; /* reply code, TASK_REPLY or REVIVE */
11650 char tty_outcaller; /* process that made the call (usually FS) */
11651 char tty_outproc; /* process that wants to write to tty */
11652 vir_bytes tty_out_vir; /* virtual address where data comes from */
11653 int tty_outleft; /* # chars yet to be output */
11654 int tty_outcum; /* # chars output so far */
11655 char tty_iocaller; /* process that made the call (usually FS) */
11656 char tty_ioproc; /* process that wants to do an ioctl */
11657 int tty_ioreq; /* ioctl request code */
11658 vir_bytes tty_iovir; /* virtual address of ioctl buffer */
11659
11660 /* Miscellaneous. */
11661 devfun_t tty_ioctl; /* set line speed, etc. at the device level */
11662 devfun_t tty_close; /* tell the device that the tty is closed */
11663 void *tty_priv; /* pointer to per device private data */
11664 struct termios tty_termios; /* terminal attributes */
11665 struct winsize tty_winsize; /* window size (#lines and #columns) */
11666
11667 u16_t tty_inbuf[TTY_IN_BYTES];/* tty input buffer */
11668 } tty_t;
11669
11670 EXTERN tty_t tty_table[NR_CONS+NR_RS_LINES+NR_PTYS];
11671
11672 /* Values for the fields. */
11673 #define NOT_ESCAPED 0 /* previous character is not LNEXT (^V) */
11674 #define ESCAPED 1 /* previous character was LNEXT (^V) */
11675 #define RUNNING 0 /* no STOP (^S) has been typed to stop output */
11676 #define STOPPED 1 /* STOP (^S) has been typed to stop output */
11677
11678 /* Fields and flags on characters in the input queue. */
11679 #define IN_CHAR 0x00FF /* low 8 bits are the character itself */
11680 #define IN_LEN 0x0F00 /* length of char if it has been echoed */
11681 #define IN_LSHIFT 8 /* length = (c & IN_LEN) >> IN_LSHIFT */
11682 #define IN_EOT 0x1000 /* char is a line break (^D, LF) */
11683 #define IN_EOF 0x2000 /* char is EOF (^D), do not return to user */
11684 #define IN_ESC 0x4000 /* escaped by LNEXT (^V), no interpretation */
11685
11686 /* Times and timeouts. */
11687 #define TIME_NEVER ((clock_t) -1 < 0 ? (clock_t) LONG_MAX : (clock_t) -1)
11688 #define force_timeout() ((void) (tty_timeout = 0))
11689
11690 EXTERN tty_t *tty_timelist; /* list of ttys with active timers */
11691
11692 /* Number of elements and limit of a buffer. */
11693 #define buflen(buf) (sizeof(buf) / sizeof((buf)[0]))
11694 #define bufend(buf) ((buf) + buflen(buf))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -