📄 38.html
字号:
<html>
<head>
<title>include/linux/tty.h</title>
<meta name='robots' content='noindex,nofollow'>
<meta name='generator' content='GLOBAL-5.4.1'>
</head>
<body text='#191970' bgcolor='#f5f5dc' vlink='gray'>
<a name='TOP'><h2><a href='../mains.html'>root</a>/<a href='../files/99.html'>include</a>/<a href='../files/101.html'>linux</a>/tty.h</h2>
<i><font color='green'>/* [<][>][^][v][top]<a href='#BOTTOM'>[bottom]</a><a href='../mains.html'>[index]</a><a href='../help.html'>[help]</a> */</font></i>
<hr>
<h2><a href='../J/38.html' title='Multiple included from 8 places.'>INCLUDED FROM</a></h2>
<hr>
<pre>
<a name='L1'><i><font color='green'>/*</font></i>
<a name='L2'><i><font color='green'>* 'tty.h' defines some structures used by tty_io.c and some defines.</font></i>
<a name='L3'><i><font color='green'>*</font></i>
<a name='L4'><i><font color='green'>* NOTE! Don't touch this without checking that nothing in rs_io.s or</font></i>
<a name='L5'><i><font color='green'>* con_io.s breaks. Some constants are hardwired into the system (mainly</font></i>
<a name='L6'><i><font color='green'>* offsets into 'tty_queue'</font></i>
<a name='L7'><i><font color='green'>*/</font></i>
<a name='L8'>
<a name='L9'><i><font color='green'>/*</font></i>
<a name='L10'><i><font color='green'>* 'tty.h'中定义了tty_io.c 程序使用的某些结构和其它一些定义。</font></i>
<a name='L11'><i><font color='green'>*</font></i>
<a name='L12'><i><font color='green'>* 注意!在修改这里的定义时,一定要检查rs_io.s 或con_io.s 程序中不会出现问题。</font></i>
<a name='L13'><i><font color='green'>* 在系统中有些常量是直接写在程序中的(主要是一些tty_queue 中的偏移值)。</font></i>
<a name='L14'><i><font color='green'>*/</font></i>
<a name='L15'><font color='darkred'>#ifndef</font> <a href='../S/38.html#L16' title='Defined at 16 in include/linux/tty.h.'>_TTY_H</a>
<a name='L16'><font color='darkred'>#define</font> <a href='../S/38.html#L15' title='Refered from 15 in include/linux/tty.h.'>_TTY_H</a>
<a name='L17'>
<a name='L18'><font color='darkred'>#include</font> <<a href='48.html'>termios.h</a>> <i><font color='green'>// 终端输入输出函数头文件。主要定义控制异步通信口的终端接口。</font></i>
<a name='L19'>
<a name='L20'><font color='darkred'>#define</font> <a href='../R/288.html' title='Multiple refered from 7 places.'>TTY_BUF_SIZE</a> 1024 <i><font color='green'>// tty 缓冲区大小。</font></i>
<a name='L21'>
<a name='L22'><i><font color='green'>// tty 等待队列数据结构。</font></i>
<a name='L23'><b>struct</b> tty_queue
<a name='L24'><font color='red'>{</font>
<a name='L25'> <b>unsigned</b> <b>long</b> data; <i><font color='green'>// 等待队列缓冲区中当前数据指针字符数[??])。</font></i>
<a name='L26'><i><font color='green'>// 对于串口终端,则存放串行端口地址。</font></i>
<a name='L27'> <b>unsigned</b> <b>long</b> head; <i><font color='green'>// 缓冲区中数据头指针。</font></i>
<a name='L28'> <b>unsigned</b> <b>long</b> tail; <i><font color='green'>// 缓冲区中数据尾指针。</font></i>
<a name='L29'> <b>struct</b> task_struct *proc_list; <i><font color='green'>// 等待进程列表。</font></i>
<a name='L30'> <b>char</b> <a href='../D/716.html' title='Multiple defined in 16 places.'>buf</a>[<a href='../D/487.html' title='Multiple defined in 2 places.'>TTY_BUF_SIZE</a>]; <i><font color='green'>// 队列的缓冲区。</font></i>
<a name='L31'><font color='red'>}</font>;
<a name='L32'>
<a name='L33'><i><font color='green'>// 以下定义了tty 等待队列中缓冲区操作宏函数。(tail 在前,head 在后)。</font></i>
<a name='L34'><i><font color='green'>// a 缓冲区指针前移1 字节,并循环。</font></i>
<a name='L35'><font color='darkred'>#define</font> <a href='../R/91.html' title='Multiple refered from 2 places.'>INC</a>(a) ((a) = ((a)+1) & (<a href='../D/487.html' title='Multiple defined in 2 places.'>TTY_BUF_SIZE</a>-1))
<a name='L36'><i><font color='green'>// a 缓冲区指针后退1 字节,并循环。</font></i>
<a name='L37'><font color='darkred'>#define</font> <a href='../R/23.html' title='Multiple refered from 2 places.'>DEC</a>(a) ((a) = ((a)-1) & (<a href='../D/487.html' title='Multiple defined in 2 places.'>TTY_BUF_SIZE</a>-1))
<a name='L38'><i><font color='green'>// 清空指定队列的缓冲区。</font></i>
<a name='L39'><font color='darkred'>#define</font> <a href='../R/49.html' title='Multiple refered from 7 places.'>EMPTY</a>(a) ((a).head == (a).tail)
<a name='L40'><i><font color='green'>// 缓冲区还可存放字符的长度(空闲区长度)。</font></i>
<a name='L41'><font color='darkred'>#define</font> <a href='../R/114.html' title='Multiple refered from 10 places.'>LEFT</a>(a) (((a).tail-(a).head-1)&(<a href='../D/487.html' title='Multiple defined in 2 places.'>TTY_BUF_SIZE</a>-1))
<a name='L42'><i><font color='green'>// 缓冲区中最后一个位置。</font></i>
<a name='L43'><font color='darkred'>#define</font> <a href='../R/111.html' title='Multiple refered from 2 places.'>LAST</a>(a) ((a).<a href='../D/716.html' title='Multiple defined in 16 places.'>buf</a>[(<a href='../D/487.html' title='Multiple defined in 2 places.'>TTY_BUF_SIZE</a>-1)&((a).head-1)])
<a name='L44'><i><font color='green'>// 缓冲区满(如果为1 的话)。</font></i>
<a name='L45'><font color='darkred'>#define</font> <a href='../R/71.html' title='Multiple refered from 3 places.'>FULL</a>(a) (!<a href='../D/215.html' title='Multiple defined in 2 places.'>LEFT</a>(a))
<a name='L46'><i><font color='green'>// 缓冲区中已存放字符的长度。</font></i>
<a name='L47'><font color='darkred'>#define</font> <a href='../R/12.html' title='Multiple refered from 3 places.'>CHARS</a>(a) (((a).head-(a).tail)&(<a href='../D/487.html' title='Multiple defined in 2 places.'>TTY_BUF_SIZE</a>-1))
<a name='L48'><i><font color='green'>// 从queue 队列项缓冲区中取一字符(从tail 处,并且tail+=1)。</font></i>
<a name='L49'><font color='darkred'>#define</font> <a href='../R/81.html' title='Multiple refered from 3 places.'>GETCH</a>(queue,c) \
<a name='L50'>(<b>void</b>)(<font color='red'>{</font>c=(queue).<a href='../D/716.html' title='Multiple defined in 16 places.'>buf</a>[(queue).tail];<a href='../S/38.html#L35' title='Defined at 35 in include/linux/tty.h.'>INC</a>((queue).tail);<font color='red'>}</font>)
<a name='L51'><i><font color='green'>// 往queue 队列项缓冲区中放置一字符(在head 处,并且head+=1)。</font></i>
<a name='L52'><font color='darkred'>#define</font> <a href='../R/205.html' title='Multiple refered from 13 places.'>PUTCH</a>(c,queue) \
<a name='L53'>(<b>void</b>)(<font color='red'>{</font>(queue).<a href='../D/716.html' title='Multiple defined in 16 places.'>buf</a>[(queue).head]=(c);<a href='../S/38.html#L35' title='Defined at 35 in include/linux/tty.h.'>INC</a>((queue).head);<font color='red'>}</font>)
<a name='L54'>
<a name='L55'><i><font color='green'>// 判断终端键盘字符类型。</font></i>
<a name='L56'><font color='darkred'>#define</font> <a href='../S/65.html#L282' title='Refered from 282 in kernel/chr_drv/tty_io.c.'>INTR_CHAR</a>(<a href='../S/7.html#L44' title='Defined at 44 in fs/char_dev.c.'>tty</a>) ((tty)->termios.c_cc[<a href='../S/48.html#L113' title='Defined at 113 in include/termios.h.'>VINTR</a>]) <i><font color='green'>// 中断符。</font></i>
<a name='L57'><font color='darkred'>#define</font> <a href='../S/65.html#L288' title='Refered from 288 in kernel/chr_drv/tty_io.c.'>QUIT_CHAR</a>(<a href='../S/7.html#L44' title='Defined at 44 in fs/char_dev.c.'>tty</a>) ((tty)->termios.c_cc[<a href='../S/48.html#L114' title='Defined at 114 in include/termios.h.'>VQUIT</a>]) <i><font color='green'>// 退出符。</font></i>
<a name='L58'><font color='darkred'>#define</font> <a href='../R/62.html' title='Multiple refered from 2 places.'>ERASE_CHAR</a>(<a href='../S/7.html#L44' title='Defined at 44 in fs/char_dev.c.'>tty</a>) ((tty)->termios.c_cc[<a href='../S/48.html#L115' title='Defined at 115 in include/termios.h.'>VERASE</a>]) <i><font color='green'>// 削除符。</font></i>
<a name='L59'><font color='darkred'>#define</font> <a href='../S/65.html#L220' title='Refered from 220 in kernel/chr_drv/tty_io.c.'>KILL_CHAR</a>(<a href='../S/7.html#L44' title='Defined at 44 in fs/char_dev.c.'>tty</a>) ((tty)->termios.c_cc[<a href='../S/48.html#L116' title='Defined at 116 in include/termios.h.'>VKILL</a>]) <i><font color='green'>// 终止符。</font></i>
<a name='L60'><font color='darkred'>#define</font> <a href='../R/60.html' title='Multiple refered from 5 places.'>EOF_CHAR</a>(<a href='../S/7.html#L44' title='Defined at 44 in fs/char_dev.c.'>tty</a>) ((tty)->termios.c_cc[<a href='../S/48.html#L117' title='Defined at 117 in include/termios.h.'>VEOF</a>]) <i><font color='green'>// 文件结束符。</font></i>
<a name='L61'><font color='darkred'>#define</font> <a href='../S/65.html#L271' title='Refered from 271 in kernel/chr_drv/tty_io.c.'>START_CHAR</a>(<a href='../S/7.html#L44' title='Defined at 44 in fs/char_dev.c.'>tty</a>) ((tty)->termios.c_cc[<a href='../S/48.html#L121' title='Defined at 121 in include/termios.h.'>VSTART</a>]) <i><font color='green'>// 开始符。</font></i>
<a name='L62'><font color='darkred'>#define</font> <a href='../S/65.html#L265' title='Refered from 265 in kernel/chr_drv/tty_io.c.'>STOP_CHAR</a>(<a href='../S/7.html#L44' title='Defined at 44 in fs/char_dev.c.'>tty</a>) ((tty)->termios.c_cc[<a href='../S/48.html#L122' title='Defined at 122 in include/termios.h.'>VSTOP</a>]) <i><font color='green'>// 结束符。</font></i>
<a name='L63'><font color='darkred'>#define</font> SUSPEND_CHAR(<a href='../S/7.html#L44' title='Defined at 44 in fs/char_dev.c.'>tty</a>) ((tty)->termios.c_cc[<a href='../S/48.html#L123' title='Defined at 123 in include/termios.h.'>VSUSP</a>]) <i><font color='green'>// 挂起符。</font></i>
<a name='L64'>
<a name='L65'><i><font color='green'>// tty 数据结构。</font></i>
<a name='L66'><b>struct</b> tty_struct
<a name='L67'><font color='red'>{</font>
<a name='L68'> <b>struct</b> termios termios; <i><font color='green'>// 终端io 属性和控制字符数据结构。</font></i>
<a name='L69'> <b>int</b> pgrp; <i><font color='green'>// 所属进程组。</font></i>
<a name='L70'> <b>int</b> stopped; <i><font color='green'>// 停止标志。</font></i>
<a name='L71'> <b>void</b> (*write) (<b>struct</b> tty_struct * <a href='../S/7.html#L44' title='Defined at 44 in fs/char_dev.c.'>tty</a>); <i><font color='green'>// tty 写函数指针。</font></i>
<a name='L72'> <b>struct</b> tty_queue read_q; <i><font color='green'>// tty 读队列。</font></i>
<a name='L73'> <b>struct</b> tty_queue write_q; <i><font color='green'>// tty 写队列。</font></i>
<a name='L74'> <b>struct</b> tty_queue secondary; <i><font color='green'>// tty 辅助队列(存放规范模式字符序列),</font></i>
<a name='L75'><font color='red'>}</font>; <i><font color='green'>// 可称为规范(熟)模式队列。</font></i>
<a name='L76'>
<a name='L77'><b>extern</b> <b>struct</b> tty_struct tty_table[]; <i><font color='green'>// tty 结构数组。</font></i>
<a name='L78'>
<a name='L79'><i><font color='green'>/* intr=^C quit=^| erase=del kill=^U</font></i>
<a name='L80'><i><font color='green'>eof=^D vtime=\0 vmin=\1 sxtc=\0</font></i>
<a name='L81'><i><font color='green'>start=^Q stop=^S susp=^Z eol=\0</font></i>
<a name='L82'><i><font color='green'>reprint=^R discard=^U werase=^W lnext=^V</font></i>
<a name='L83'><i><font color='green'>eol2=\0</font></i>
<a name='L84'><i><font color='green'>*/</font></i>
<a name='L85'><i><font color='green'>/* 中断intr=^C 退出quit=^| 删除erase=del 终止kill=^U</font></i>
<a name='L86'><i><font color='green'>* 文件结束eof=^D vtime=\0 vmin=\1 sxtc=\0</font></i>
<a name='L87'><i><font color='green'>* 开始start=^Q 停止stop=^S 挂起susp=^Z 行结束eol=\0</font></i>
<a name='L88'><i><font color='green'>* 重显reprint=^R 丢弃discard=^U werase=^W lnext=^V</font></i>
<a name='L89'><i><font color='green'>* 行结束eol2=\0</font></i>
<a name='L90'><i><font color='green'>*/</font></i>
<a name='L91'><i><font color='green'>// 控制字符对应的ASCII 码值。[8 进制]</font></i>
<a name='L92'><font color='darkred'>#define</font> <a href='../R/92.html' title='Multiple refered from 3 places.'>INIT_C_CC</a> "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
<a name='L93'>
<a name='L94'><b>void</b> <a href='../S/64.html#L57' title='Defined at 57 in kernel/chr_drv/serial.c.'>rs_init</a> (<b>void</b>); <i><font color='green'>// 异步串行通信初始化。(kernel/chr_drv/serial.c, 37)</font></i>
<a name='L95'><b>void</b> <a href='../S/60.html#L872' title='Defined at 872 in kernel/chr_drv/console.c.'>con_init</a> (<b>void</b>); <i><font color='green'>// 控制终端初始化。 (kernel/chr_drv/console.c, 617)</font></i>
<a name='L96'><b>void</b> <a href='../S/65.html#L126' title='Defined at 126 in kernel/chr_drv/tty_io.c.'>tty_init</a> (<b>void</b>); <i><font color='green'>// tty 初始化。 (kernel/chr_drv/tty_io.c, 105)</font></i>
<a name='L97'>
<a name='L98'><b>int</b> <a href='../D/1092.html' title='Multiple defined in 2 places.'>tty_read</a> (<b>unsigned</b> c, <b>char</b> *buf, <b>int</b> n); <i><font color='green'>// (kernel/chr_drv/tty_io.c, 230)</font></i>
<a name='L99'><b>int</b> <a href='../D/1093.html' title='Multiple defined in 2 places.'>tty_write</a> (<b>unsigned</b> c, <b>char</b> *buf, <b>int</b> n); <i><font color='green'>// (kernel/chr_drv/tty_io.c, 290)</font></i>
<a name='L100'>
<a name='L101'><b>void</b> <a href='../S/64.html#L80' title='Defined at 80 in kernel/chr_drv/serial.c.'>rs_write</a> (<b>struct</b> tty_struct *tty); <i><font color='green'>// (kernel/chr_drv/serial.c, 53)</font></i>
<a name='L102'><b>void</b> <a href='../S/60.html#L605' title='Defined at 605 in kernel/chr_drv/console.c.'>con_write</a> (<b>struct</b> tty_struct *tty); <i><font color='green'>// (kernel/chr_drv/console.c, 445)</font></i>
<a name='L103'>
<a name='L104'><b>void</b> <a href='../S/65.html#L192' title='Defined at 192 in kernel/chr_drv/tty_io.c.'>copy_to_cooked</a> (<b>struct</b> tty_struct *tty); <i><font color='green'>// (kernel/chr_drv/tty_io.c, 145)</font></i>
<a name='L105'>
<a name='L106'><font color='darkred'>#endif</font>
</pre>
<hr>
<a name='BOTTOM'>
<i><font color='green'>/* [<][>][^][v]<a href='#TOP'>[top]</a>[bottom]<a href='../mains.html'>[index]</a><a href='../help.html'>[help]</a> */</font></i>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -