60.html
来自「linux 0.11中文版 有注释」· HTML 代码 · 共 725 行 · 第 1/5 页
HTML
725 行
<html>
<head>
<title>kernel/chr_drv/console.c</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/104.html'>kernel</a>/<a href='../files/106.html'>chr_drv</a>/console.c</h2>
<i><font color='green'>/* [<][>]<a href='#L134'>[^]</a><a href='#L978'>[v]</a>[top]<a href='#BOTTOM'>[bottom]</a><a href='../mains.html'>[index]</a><a href='../help.html'>[help]</a> */</font></i>
<hr>
<h2>DEFINITIONS</h2>
This source file includes following definitions.
<ol>
<li><a href='#L134' title='Defined at 134.'>gotoxy</a>
<li><a href='#L147' title='Defined at 147.'>set_origin</a>
<li><a href='#L163' title='Defined at 163.'>scrup</a>
<li><a href='#L241' title='Defined at 241.'>scrdown</a>
<li><a href='#L271' title='Defined at 271.'>lf</a>
<li><a href='#L287' title='Defined at 287.'>ri</a>
<li><a href='#L303' title='Defined at 303.'>cr</a>
<li><a href='#L312' title='Defined at 312.'>del</a>
<li><a href='#L329' title='Defined at 329.'>csi_J</a>
<li><a href='#L360' title='Defined at 360.'>csi_K</a>
<li><a href='#L393' title='Defined at 393.'>csi_m</a>
<li><a href='#L421' title='Defined at 421.'>set_cursor</a>
<li><a href='#L437' title='Defined at 437.'>respond</a>
<li><a href='#L453' title='Defined at 453.'>insert_char</a>
<li><a href='#L473' title='Defined at 473.'>insert_line</a>
<li><a href='#L488' title='Defined at 488.'>delete_char</a>
<li><a href='#L510' title='Defined at 510.'>delete_line</a>
<li><a href='#L527' title='Defined at 527.'>csi_at</a>
<li><a href='#L542' title='Defined at 542.'>csi_L</a>
<li><a href='#L557' title='Defined at 557.'>csi_P</a>
<li><a href='#L572' title='Defined at 572.'>csi_M</a>
<li><a href='#L589' title='Defined at 589.'>save_cur</a>
<li><a href='#L597' title='Defined at 597.'>restore_cur</a>
<li><a href='#L605' title='Defined at 605.'>con_write</a>
<li><a href='#L872' title='Defined at 872.'>con_init</a>
<li><a href='#L965' title='Defined at 965.'>sysbeepstop</a>
<li><a href='#L978' title='Defined at 978.'>sysbeep</a>
</ol>
<hr>
<pre>
<a name='L1'><i><font color='green'>/*</font></i>
<a name='L2'><i><font color='green'>* linux/kernel/console.c</font></i>
<a name='L3'><i><font color='green'>*</font></i>
<a name='L4'><i><font color='green'>* (C) 1991 Linus Torvalds</font></i>
<a name='L5'><i><font color='green'>*/</font></i>
<a name='L6'>
<a name='L7'><i><font color='green'>/*</font></i>
<a name='L8'><i><font color='green'>* console.c</font></i>
<a name='L9'><i><font color='green'>*</font></i>
<a name='L10'><i><font color='green'>* This module implements the console io functions</font></i>
<a name='L11'><i><font color='green'>* 'void con_init(void)'</font></i>
<a name='L12'><i><font color='green'>* 'void con_write(struct tty_queue * queue)'</font></i>
<a name='L13'><i><font color='green'>* Hopefully this will be a rather complete VT102 implementation.</font></i>
<a name='L14'><i><font color='green'>*</font></i>
<a name='L15'><i><font color='green'>* Beeping thanks to John T Kohl.</font></i>
<a name='L16'><i><font color='green'>*/</font></i>
<a name='L17'><i><font color='green'>/*</font></i>
<a name='L18'><i><font color='green'>* 该模块实现控制台输入输出功能</font></i>
<a name='L19'><i><font color='green'>* 'void con_init(void)'</font></i>
<a name='L20'><i><font color='green'>* 'void con_write(struct tty_queue * queue)'</font></i>
<a name='L21'><i><font color='green'>* 希望这是一个非常完整的VT102 实现。</font></i>
<a name='L22'><i><font color='green'>*</font></i>
<a name='L23'><i><font color='green'>* 感谢John T Kohl 实现了蜂鸣指示。</font></i>
<a name='L24'><i><font color='green'>*/</font></i>
<a name='L25'>
<a name='L26'><i><font color='green'>/*</font></i>
<a name='L27'><i><font color='green'>* NOTE!!! We sometimes disable and enable interrupts for a short while</font></i>
<a name='L28'><i><font color='green'>* (to put a word in video IO), but this will work even for keyboard</font></i>
<a name='L29'><i><font color='green'>* interrupts. We know interrupts aren't enabled when getting a keyboard</font></i>
<a name='L30'><i><font color='green'>* interrupt, as we use trap-gates. Hopefully all is well.</font></i>
<a name='L31'><i><font color='green'>*/</font></i>
<a name='L32'><i><font color='green'>/*</font></i>
<a name='L33'><i><font color='green'>* 注意!!! 我们有时短暂地禁止和允许中断(在将一个字(word)放到视频IO),但即使</font></i>
<a name='L34'><i><font color='green'>* 对于键盘中断这也是可以工作的。因为我们使用陷阱门,所以我们知道在获得一个</font></i>
<a name='L35'><i><font color='green'>* 键盘中断时中断是不允许的。希望一切均正常。</font></i>
<a name='L36'><i><font color='green'>*/</font></i>
<a name='L37'>
<a name='L38'><i><font color='green'>/*</font></i>
<a name='L39'><i><font color='green'>* Code to check for different video-cards mostly by Galen Hunt,</font></i>
<a name='L40'><i><font color='green'>* <g-hunt@ee.utah.edu></font></i>
<a name='L41'><i><font color='green'>*/</font></i>
<a name='L42'><i><font color='green'>/*</font></i>
<a name='L43'><i><font color='green'>* 检测不同显示卡的代码大多数是Galen Hunt 编写的,</font></i>
<a name='L44'><i><font color='green'>* <g-hunt@ee.utah.edu></font></i>
<a name='L45'><i><font color='green'>*/</font></i>
<a name='L46'>
<a name='L47'><font color='darkred'>#include</font> <<a href='36.html'>linux/sched.h</a>> <i><font color='green'>// 调度程序头文件,定义了任务结构task_struct、初始任务0 的数据,</font></i>
<a name='L48'><i><font color='green'>// 还有一些有关描述符参数设置和获取的嵌入式汇编函数宏语句。</font></i>
<a name='L49'><font color='darkred'>#include</font> <<a href='38.html'>linux/tty.h</a>> <i><font color='green'>// tty 头文件,定义了有关tty_io,串行通信方面的参数、常数。</font></i>
<a name='L50'><font color='darkred'>#include</font> <<a href='22.html'>asm/io.h</a>> <i><font color='green'>// io 头文件。定义硬件端口输入/输出宏汇编语句。</font></i>
<a name='L51'><font color='darkred'>#include</font> <<a href='25.html'>asm/system.h</a>> <i><font color='green'>// 系统头文件。定义了设置或修改描述符/中断门等的嵌入式汇编宏。</font></i>
<a name='L52'>
<a name='L53'><i><font color='green'>/*</font></i>
<a name='L54'><i><font color='green'>* These are set up by the setup-routine at boot-time:</font></i>
<a name='L55'><i><font color='green'>*/</font></i>
<a name='L56'><i><font color='green'>/*</font></i>
<a name='L57'><i><font color='green'>* 这些是设置子程序setup 在引导启动系统时设置的参数:</font></i>
<a name='L58'><i><font color='green'>*/</font></i>
<a name='L59'>
<a name='L60'><i><font color='green'>// 参见对boot/setup.s 的注释,和setup 程序读取并保留的参数表。</font></i>
<a name='L61'><font color='darkred'>#define</font> <a href='../S/60.html#L952' title='Refered from 952 in kernel/chr_drv/console.c.'>ORIG_X</a> (*(<b>unsigned</b> <b>char</b> *)0x90000) <i><font color='green'>// 光标列号。</font></i>
<a name='L62'><font color='darkred'>#define</font> <a href='../S/60.html#L952' title='Refered from 952 in kernel/chr_drv/console.c.'>ORIG_Y</a> (*(<b>unsigned</b> <b>char</b> *)0x90001) <i><font color='green'>// 光标行号。</font></i>
<a name='L63'><font color='darkred'>#define</font> <a href='../S/60.html#L881' title='Refered from 881 in kernel/chr_drv/console.c.'>ORIG_VIDEO_PAGE</a> (*(<b>unsigned</b> <b>short</b> *)0x90004) <i><font color='green'>// 显示页面。</font></i>
<a name='L64'><font color='darkred'>#define</font> <a href='../S/60.html#L885' title='Refered from 885 in kernel/chr_drv/console.c.'>ORIG_VIDEO_MODE</a> ((*(<b>unsigned</b> <b>short</b> *)0x90006) & 0xff) <i><font color='green'>// 显示模式。</font></i>
<a name='L65'><font color='darkred'>#define</font> <a href='../S/60.html#L878' title='Refered from 878 in kernel/chr_drv/console.c.'>ORIG_VIDEO_COLS</a> (((*(<b>unsigned</b> <b>short</b> *)0x90006) & 0xff00) >> 8) <i><font color='green'>// 字符列数。</font></i>
<a name='L66'><font color='darkred'>#define</font> <a href='../S/60.html#L880' title='Refered from 880 in kernel/chr_drv/console.c.'>ORIG_VIDEO_LINES</a> (25) <i><font color='green'>// 显示行数。</font></i>
<a name='L67'><font color='darkred'>#define</font> ORIG_VIDEO_EGA_AX (*(<b>unsigned</b> <b>short</b> *)0x90008) <i><font color='green'>// [??]</font></i>
<a name='L68'><font color='darkred'>#define</font> <a href='../R/178.html' title='Multiple refered from 2 places.'>ORIG_VIDEO_EGA_BX</a> (*(<b>unsigned</b> <b>short</b> *)0x9000a) <i><font color='green'>// 显示内存大小和色彩模式。</font></i>
<a name='L69'><font color='darkred'>#define</font> ORIG_VIDEO_EGA_CX (*(<b>unsigned</b> <b>short</b> *)0x9000c) <i><font color='green'>// 显示卡特性参数。</font></i>
<a name='L70'>
<a name='L71'><i><font color='green'>// 定义显示器单色/彩色显示模式类型符号常数。</font></i>
<a name='L72'><font color='darkred'>#define</font> <a href='../S/60.html#L903' title='Refered from 903 in kernel/chr_drv/console.c.'>VIDEO_TYPE_MDA</a> 0x10 <i><font color='green'>/* Monochrome Text Display */</font></i> <i><font color='green'>/* 单色文本 */</font></i>
<a name='L73'><font color='darkred'>#define</font> <a href='../S/60.html#L925' title='Refered from 925 in kernel/chr_drv/console.c.'>VIDEO_TYPE_CGA</a> 0x11 <i><font color='green'>/* CGA Display */</font></i> <i><font color='green'>/* CGA 显示器 */</font></i>
<a name='L74'><font color='darkred'>#define</font> <a href='../R/295.html' title='Multiple refered from 3 places.'>VIDEO_TYPE_EGAM</a> 0x20 <i><font color='green'>/* EGA/VGA in Monochrome Mode */</font></i> <i><font color='green'>/* EGA/VGA 单色 */</font></i>
<a name='L75'><font color='darkred'>#define</font> <a href='../R/294.html' title='Multiple refered from 3 places.'>VIDEO_TYPE_EGAC</a> 0x21 <i><font color='green'>/* EGA/VGA in Color Mode */</font></i> <i><font color='green'>/* EGA/VGA 彩色 */</font></i>
<a name='L76'>
<a name='L77'><font color='darkred'>#define</font> <a href='../R/137.html' title='Multiple refered from 3 places.'>NPAR</a> 16
<a name='L78'>
<a name='L79'><b>extern</b> <b>void</b> keyboard_interrupt (<b>void</b>); <i><font color='green'>// 键盘中断处理程序(keyboard.S)。</font></i>
<a name='L80'>
<a name='L81'><b>static</b> <b>unsigned</b> <b>char</b> video_type; <i><font color='green'>/* Type of display being used */</font></i>
<a name='L82'><i><font color='green'>/* 使用的显示类型 */</font></i>
<a name='L83'><b>static</b> <b>unsigned</b> <b>long</b> video_num_columns; <i><font color='green'>/* Number of text columns */</font></i>
<a name='L84'><i><font color='green'>/* 屏幕文本列数 */</font></i>
<a name='L85'><b>static</b> <b>unsigned</b> <b>long</b> video_size_row; <i><font color='green'>/* Bytes per row */</font></i>
<a name='L86'><i><font color='green'>/* 每行使用的字节数 */</font></i>
<a name='L87'><b>static</b> <b>unsigned</b> <b>long</b> video_num_lines; <i><font color='green'>/* Number of test lines */</font></i>
<a name='L88'><i><font color='green'>/* 屏幕文本行数 */</font></i>
<a name='L89'><b>static</b> <b>unsigned</b> <b>char</b> video_page; <i><font color='green'>/* Initial video page */</font></i>
<a name='L90'><i><font color='green'>/* 初始显示页面 */</font></i>
<a name='L91'><b>static</b> <b>unsigned</b> <b>long</b> video_mem_start; <i><font color='green'>/* Start of video RAM */</font></i>
<a name='L92'><i><font color='green'>/* 显示内存起始地址 */</font></i>
<a name='L93'><b>static</b> <b>unsigned</b> <b>long</b> video_mem_end; <i><font color='green'>/* End of video RAM (sort of) */</font></i>
<a name='L94'><i><font color='green'>/* 显示内存结束(末端)地址 */</font></i>
<a name='L95'><b>static</b> <b>unsigned</b> <b>short</b> video_port_reg; <i><font color='green'>/* Video register select port */</font></i>
<a name='L96'><i><font color='green'>/* 显示控制索引寄存器端口 */</font></i>
<a name='L97'><b>static</b> <b>unsigned</b> <b>short</b> video_port_val; <i><font color='green'>/* Video register value port */</font></i>
<a name='L98'><i><font color='green'>/* 显示控制数据寄存器端口 */</font></i>
<a name='L99'><b>static</b> <b>unsigned</b> <b>short</b> video_erase_char; <i><font color='green'>/* Char+Attrib to erase with */</font></i>
<a name='L100'><i><font color='green'>/* 擦除字符属性与字符(0x0720) */</font></i>
<a name='L101'>
<a name='L102'><i><font color='green'>// 以下这些变量用于屏幕卷屏操作。</font></i>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?