亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? console.c

?? linux的內(nèi)核源碼
?? C
字號:
/*
 *	console.c
 *
 * This module implements the console io functions
 *	'void con_init(void)'
 *	'void con_write(struct tty_queue * queue)'
 * Hopefully this will be a rather complete VT102 implementation.
 *
 */

/*
 *  NOTE!!! We sometimes disable and enable interrupts for a short while
 * (to put a word in video IO), but this will work even for keyboard
 * interrupts. We know interrupts aren't enabled when getting a keyboard
 * interrupt, as we use trap-gates. Hopefully all is well.
 */

#include <linux/sched.h>
#include <linux/tty.h>
#include <asm/io.h>
#include <asm/system.h>

#define SCREEN_START 0xb8000	//0Xb8000---0XbFFFF是顯存的地址
#define SCREEN_END   0xc0000
#define LINES 25
#define COLUMNS 80
#define NPAR 16

extern void keyboard_interrupt(void);

static unsigned long origin=SCREEN_START;
static unsigned long scr_end=SCREEN_START+LINES*COLUMNS*2;
static unsigned long pos;
static unsigned long x,y;
static unsigned long top=0,bottom=LINES;
static unsigned long lines=LINES,columns=COLUMNS;
static unsigned long state=0;
static unsigned long npar,par[NPAR];
static unsigned long ques=0;
static unsigned char attr=0x07;

/*
 * this is what the terminal answers to a ESC-Z or csi0c
 * query (= vt100 response).
 */
#define RESPONSE "\033[?1;2c"		//\033=0X1B=ESC鍵

static inline void gotoxy(unsigned int new_x,unsigned int new_y)
{
	if (new_x>=columns || new_y>=lines)
		return;
	x=new_x;
	y=new_y;
	pos=origin+((y*columns+x)<<1);	//乘2是因為描述位置是字
}

static inline void set_origin(void)
{
	cli();
//下面二個寄存器處理屏幕滾動,寄存器12是開始地址的高字,13是低字
//0x3d4是6845索引寄存器,它可以選擇18個寄存器,但必須在讀/寫0x3d5之前,18個寄存器中前10個是處理垂直和水平顯示參數(shù)的,不要動
	outb_p(12,0x3d4);
	outb_p(0xff&((origin-SCREEN_START)>>9),0x3d5);
	outb_p(13,0x3d4);
	outb_p(0xff&((origin-SCREEN_START)>>1),0x3d5);
	sti();
}

static void scrup(void)
{
	if (!top && bottom==lines) {
		origin += columns<<1;
		pos += columns<<1;
		scr_end += columns<<1;
		if (scr_end>SCREEN_END) {
//以下的內(nèi)嵌匯編意思是:
//	movl	0X0720		%eax		//其中0X0720中的07表示屬性為灰,20代表空白鍵
//	movl	(line-1)*columns>>1	%ecx
//	movl	SCREEN_START	%edi
//	movl	origin		%esi
//	cld					//地址增量
//	rep	movsl				//ds:si --->es:di
//	movl	_columns	%ecx
//	rep	stosw				//將eax中的內(nèi)容傳入ES:DI中
			__asm__("cld\n\t"
				"rep\n\t"
				"movsl\n\t"
				"movl _columns,%1\n\t"
				"rep\n\t"
				"stosw"
				::"a" (0x0720),
				"c" ((lines-1)*columns>>1),
				"D" (SCREEN_START),
				"S" (origin)
				:"cx","di","si");
			scr_end -= origin-SCREEN_START;
			pos -= origin-SCREEN_START;
			origin = SCREEN_START;
		} else {
//以下的內(nèi)嵌匯編意思是:
//	movl	0X07200720	%eax
//	movl	columns>>1	%ecx		//因為傳送的是雙字,所以要除2
//	movl	scr_end-(columns<<1)	%edi
//	cld
//	rep	stosl				//雙字傳送
			__asm__("cld\n\t"
				"rep\n\t"
				"stosl"
				::"a" (0x07200720),
				"c" (columns>>1),
				"D" (scr_end-(columns<<1))
				:"cx","di");
		}
		set_origin();
	} else {
//以下的內(nèi)嵌匯編意思是:
//	movl	0X0720		%eax
//	movl	(bottom-top-1)*columns>>1	%ecx
//	movl	origin+(columns<<1)*top		%edi
//	movl	origin+(columns<<1)*(top+1)		%esi
//	cld
//	rep	movsl
//	movl	_columns	%ecx
//	rep	stosw
		__asm__("cld\n\t"
			"rep\n\t"
			"movsl\n\t"
			"movl _columns,%%ecx\n\t"
			"rep\n\t"
			"stosw"
			::"a" (0x0720),
			"c" ((bottom-top-1)*columns>>1),
			"D" (origin+(columns<<1)*top),
			"S" (origin+(columns<<1)*(top+1))
			:"cx","di","si");
	}
}

static void scrdown(void)
{
//以下的內(nèi)嵌匯編意思是:
//	movl	0X0720		%eax
//	movl	(bottom-top-1)*columns	%ecx
//	movl	(origin+(columns<<1)*(bottom-1)-4)	%esi
//	std				//地址減量
//	rep	movsl
//	addl	$2	%%edi
//	movl	_columns	%ecx
//	stosw
	__asm__("std\n\t"
		"rep\n\t"
		"movsl\n\t"
		"addl $2,%%edi\n\t"	/* %edi has been decremented by 4 */
		"movl _columns,%%ecx\n\t"
		"rep\n\t"
		"stosw"
		::"a" (0x0720),
		"c" ((bottom-top-1)*columns>>1),
		"D" (origin+(columns<<1)*bottom-4),
		"S" (origin+(columns<<1)*(bottom-1)-4)
		:"ax","cx","di","si");
}

static void lf(void)
{
	if (y+1<bottom) {
		y++;
		pos += columns<<1;
		return;
	}
	scrup();			//如果超過了底部,屏向上走一行
}

static void ri(void)
{
	if (y>top) {
		y--;
		pos -= columns<<1;
		return;
	}
	scrdown();			//如果y<top,就是超過了屏的頂部,就向下走一行
}

static void cr(void)
{
	pos -= x<<1;
	x=0;
}

static void del(void)
{
	if (x) {
		pos -= 2;
		x--;
		*(unsigned short *)pos = 0x0720;	//將刪除的這個字填為空白,屬性為灰
	}
}

static void csi_J(int par)		//這是處理整個顯示區(qū)的擦除函數(shù)
{
	long count __asm__("cx");
	long start __asm__("di");

	switch (par) {
		case 0:	/* erase from cursor to end of display */
			count = (scr_end-pos)>>1;
			start = pos;
			break;
		case 1:	/* erase from start to cursor */
			count = (pos-origin)>>1;
			start = origin;
			break;
		case 2: /* erase whole display */
			count = columns*lines;
			start = origin;
			break;
		default:
			return;
	}
//以下的內(nèi)嵌匯編意思是:
//	movl	count	%ecx
//	movl	start	%edi
//	movl	0X0720	%eax
//	cld
//	rep	stosw
	__asm__("cld\n\t"
		"rep\n\t"
		"stosw\n\t"
		::"c" (count),
		"D" (start),"a" (0x0720)
		:"cx","di");
}

static void csi_K(int par)
{
	long count __asm__("cx");
	long start __asm__("di");

	switch (par) {
		case 0:	/* erase from cursor to end of line */
			if (x>=columns)
				return;
			count = columns-x;
			start = pos;
			break;
		case 1:	/* erase from start of line to cursor */
			start = pos - (x<<1);
			count = (x<columns)?x:columns;
			break;
		case 2: /* erase whole line */
			start = pos - (x<<1);
			count = columns;
			break;
		default:
			return;
	}
	__asm__("cld\n\t"			//同上
		"rep\n\t"
		"stosw\n\t"
		::"c" (count),
		"D" (start),"a" (0x0720)
		:"cx","di");
}

void csi_m(void)				//修改部分區(qū)域的字符屬性
{
	int i;

	for (i=0;i<=npar;i++)
		switch (par[i]) {
			case 0:attr=0x07;break;
			case 1:attr=0x0f;break;
			case 4:attr=0x0f;break;
			case 7:attr=0x70;break;
			case 27:attr=0x07;break;
		}
}

static inline void set_cursor(void)
{
	cli();
//寄存器14控制光標(biāo)位置(高位字),寄存器15控制低位字
	outb_p(14,0x3d4);
	outb_p(0xff&((pos-SCREEN_START)>>9),0x3d5);
	outb_p(15,0x3d4);
	outb_p(0xff&((pos-SCREEN_START)>>1),0x3d5);
	sti();
}

static void respond(struct tty_struct * tty)
{
	char * p = RESPONSE;

	cli();
	while (*p) {
		PUTCH(*p,tty->read_q);
		p++;
	}
	sti();
	copy_to_cooked(tty);			//此函數(shù)在tty_io.c中定義
}

static void insert_char(void)
{
	int i=x;
	unsigned short tmp,old=0x0720;
	unsigned short * p = (unsigned short *) pos;

	while (i++<columns) {		//將光標(biāo)的當(dāng)前位置填空為0X0720,然后循環(huán),把當(dāng)前位置的老的字符向后移,然后將后面的所有字符向后移一位置
		tmp=*p;
		*p=old;
		old=tmp;
		p++;
	}
}

static void insert_line(void)
{
	int oldtop,oldbottom;

	oldtop=top;
	oldbottom=bottom;
	top=y;				//top是當(dāng)前光標(biāo)位置的Y軸,即為當(dāng)前屏幕的第Y行
	bottom=lines;
	scrdown();
	top=oldtop;
	bottom=oldbottom;
}

static void delete_char(void)
{
	int i;
	unsigned short * p = (unsigned short *) pos;

	if (x>=columns)
		return;
	i = x;				//X為當(dāng)前光標(biāo)的X軸,即為當(dāng)前屏幕的X列
	while (++i < columns) {
		*p = *(p+1);
		p++;
	}
	*p=0x0720;			//將最后一個字符填為0X0720
}

static void delete_line(void)
{
	int oldtop,oldbottom;

	oldtop=top;
	oldbottom=bottom;
	top=y;
	bottom=lines;
	scrup();
	top=oldtop;
	bottom=oldbottom;
}

static void csi_at(int nr)
{
	if (nr>columns)
		nr=columns;
	else if (!nr)			//如果nr為0,那么nr=1,這樣是保證插入一個字符
		nr=1;
	while (nr--)
		insert_char();
}

static void csi_L(int nr)
{
	if (nr>lines)
		nr=lines;
	else if (!nr)
		nr=1;
	while (nr--)
		insert_line();
}

static void csi_P(int nr)
{
	if (nr>columns)
		nr=columns;
	else if (!nr)
		nr=1;
	while (nr--)
		delete_char();
}

static void csi_M(int nr)
{
	if (nr>lines)
		nr=lines;
	else if (!nr)
		nr=1;
	while (nr--)
		delete_line();
}

static int saved_x=0;
static int saved_y=0;

static void save_cur(void)
{
	saved_x=x;
	saved_y=y;
}

static void restore_cur(void)
{
	x=saved_x;
	y=saved_y;
	pos=origin+((y*columns+x)<<1);		//還原光標(biāo)位置
}

void con_write(struct tty_struct * tty)
{
	int nr;
	char c;

	nr = CHARS(tty->write_q);			//tty->write_q中有多少沒有被處理的字符
	while (nr--) {
		GETCH(tty->write_q,c);
		switch(state) {			//state默認為0
			case 0:
				if (c>31 && c<127) {		//是有效可寫字符?
					if (x>=columns) {	//需要換行嗎?
						x -= columns;	//將光標(biāo)X軸指向本行的行首
						pos -= columns<<1;
						lf();		//將光標(biāo)指向下一行
					}
//下面內(nèi)嵌匯編的意思是:
//	movl	c	%eax
//	movb	0X70	%ah
//	movw	%ax	*pos
					__asm__("movb _attr,%%ah\n\t"
						"movw %%ax,%1\n\t"
						::"a" (c),"m" (*(short *)pos)	//其中m表示操作數(shù)是內(nèi)存變量
						:"ax");
					pos += 2;		//指向下一個位置
					x++;
				} else if (c==27)		//27=0X1B,是否為ESC鍵
					state=1;
				else if (c==10 || c==11 || c==12)
					lf();
				else if (c==13)		//13=0X0D,是否為ENTER鍵
					cr();
				else if (c==ERASE_CHAR(tty))
					del();
				else if (c==8) {		//8是空白鍵(BACKSPACE)
					if (x) {
						x--;
						pos -= 2;
					}
				} else if (c==9) {		//TAB鍵
					c=8-(x&7);		//只能跳過最大8個字符
					x += c;
					pos += c<<1;
					if (x>columns) {
						x -= columns;
						pos -= columns<<1;
						lf();
					}
					c=9;
				}
				break;
			case 1:
				state=0;
				if (c=='[')
					state=2;
				else if (c=='E')
					gotoxy(0,y+1);	//到下行的開頭位置
				else if (c=='M')
					ri();			//光標(biāo)到上行的當(dāng)前位置
				else if (c=='D')
					lf();			//光標(biāo)到下行的當(dāng)前位置
				else if (c=='Z')
					respond(tty);
				else if (x=='7')
					save_cur();
				else if (x=='8')
					restore_cur();
				break;
			case 2:
				for(npar=0;npar<NPAR;npar++)
					par[npar]=0;
				npar=0;
				state=3;
				if (ques=(c=='?'))
					break;
			case 3:
				if (c==';' && npar<NPAR-1) {
					npar++;
					break;
				} else if (c>='0' && c<='9') {
					par[npar]=10*par[npar]+c-'0';
					break;
				} else state=4;
			case 4:				//光標(biāo)控制
				state=0;
				switch(c) {
					case 'G': case '`':
						if (par[0]) par[0]--;
						gotoxy(par[0],y);
						break;
					case 'A':
						if (!par[0]) par[0]++;
						gotoxy(x,y-par[0]);
						break;
					case 'B': case 'e':
						if (!par[0]) par[0]++;
						gotoxy(x,y+par[0]);
						break;
					case 'C': case 'a':
						if (!par[0]) par[0]++;
						gotoxy(x+par[0],y);
						break;
					case 'D':
						if (!par[0]) par[0]++;
						gotoxy(x-par[0],y);
						break;
					case 'E':
						if (!par[0]) par[0]++;
						gotoxy(0,y+par[0]);
						break;
					case 'F':
						if (!par[0]) par[0]++;
						gotoxy(0,y-par[0]);
						break;
					case 'd':
						if (par[0]) par[0]--;
						gotoxy(x,par[0]);
						break;
					case 'H': case 'f':
						if (par[0]) par[0]--;
						if (par[1]) par[1]--;
						gotoxy(par[1],par[0]);
						break;
					case 'J':
						csi_J(par[0]);
						break;
					case 'K':
						csi_K(par[0]);
						break;
					case 'L':
						csi_L(par[0]);
						break;
					case 'M':
						csi_M(par[0]);
						break;
					case 'P':
						csi_P(par[0]);
						break;
					case '@':
						csi_at(par[0]);
						break;
					case 'm':
						csi_m();
						break;
					case 'r':
						if (par[0]) par[0]--;
						if (!par[1]) par[1]=lines;
						if (par[0] < par[1] &&
						    par[1] <= lines) {
							top=par[0];
							bottom=par[1];
						}
						break;
					case 's':
						save_cur();
						break;
					case 'u':
						restore_cur();
						break;
				}
		}
	}
	set_cursor();						//實際硬件處理光標(biāo)
}

/*
 *  void con_init(void);
 *
 * This routine initalizes console interrupts, and does nothing
 * else. If you want the screen to clear, call tty_write with
 * the appropriate escape-sequece.
 */
void con_init(void)
{
	register unsigned char a;

	gotoxy(*(unsigned char *)(0x90000+510),*(unsigned char *)(0x90000+511));	//其中0X90000+510是在boot.s中已將光標(biāo)X、Y保存在0X90000+510處
	set_trap_gate(0x21,&keyboard_interrupt);		//定義IDT[21]中斷號是鍵盤中斷處理程序,鍵盤中斷處理程序在keyboard.s中
	outb_p(inb_p(0x21)&0xfd,0x21);			//屏蔽IRQ1
	a=inb_p(0x61);
	outb_p(a|0x80,0x61);					//禁止端口60H開關(guān),開放鍵盤數(shù)據(jù),允許鍵盤IRQ
	outb(a,0x61);						//恢復(fù)
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色狠狠一区二区三区香蕉| 奇米一区二区三区av| 成人教育av在线| 中文字幕一区二区三区不卡在线| 99久久国产综合精品女不卡| 一区在线中文字幕| 欧美视频精品在线| 欧美aⅴ一区二区三区视频| 精品一区二区三区免费视频| 欧美性猛交xxxxxx富婆| 婷婷开心激情综合| 欧美电影免费观看高清完整版| 免费成人av资源网| 国产精品丝袜91| 欧美日韩在线一区二区| 麻豆精品视频在线观看免费| 91精品国产综合久久婷婷香蕉 | 亚洲欧美日韩电影| 在线观看av一区二区| 免费成人在线观看| 国产精品视频一区二区三区不卡| 欧美自拍偷拍午夜视频| 午夜精品久久久久久不卡8050| 久久这里只有精品首页| 91在线国产福利| 欧美aⅴ一区二区三区视频| 久久精子c满五个校花| 国产一区二区按摩在线观看| 一区二区在线观看不卡| 制服丝袜av成人在线看| 白白色 亚洲乱淫| 三级影片在线观看欧美日韩一区二区| 欧美精品一区二区三区蜜臀| 91久久精品一区二区三区| 精品影院一区二区久久久| 亚洲乱码日产精品bd| 欧美成人bangbros| 91国产免费观看| 色综合婷婷久久| 久久97超碰国产精品超碰| 亚洲另类在线视频| 久久久五月婷婷| 欧美美女喷水视频| 99久久99久久综合| 久久不见久久见中文字幕免费| 国产精品污www在线观看| 欧美精品一二三四| 色哟哟国产精品| 国产精品影音先锋| 男人的天堂亚洲一区| 亚洲激情图片qvod| 日本一区二区成人在线| 精品久久一区二区| 日韩一卡二卡三卡四卡| 在线观看亚洲成人| 99精品久久久久久| 国产v综合v亚洲欧| 国产一区二区三区四区五区美女 | 日本道在线观看一区二区| 国产精品18久久久久久久久久久久| 天堂av在线一区| 一卡二卡三卡日韩欧美| 国产精品免费视频观看| 久久久久久久久久久黄色| 日韩精品资源二区在线| 日韩精品一区二区三区在线观看 | 精品久久国产老人久久综合| 欧美剧情片在线观看| 欧美性猛交xxxx黑人交| 欧美亚洲国产怡红院影院| 一本色道久久综合精品竹菊| 97精品久久久午夜一区二区三区| 国产精品1区2区| 国产成人免费xxxxxxxx| 国产91丝袜在线18| 成人高清视频在线| 岛国av在线一区| 丰满岳乱妇一区二区三区| 国产精品一区二区免费不卡| 国产一区二区0| 国产成a人无v码亚洲福利| 国产成人精品亚洲777人妖| 国产98色在线|日韩| gogogo免费视频观看亚洲一| 色综合天天综合网天天狠天天 | 日韩一区二区在线看| 欧美日韩1区2区| 日韩一区二区三区视频| 久久色在线观看| 最新不卡av在线| 亚洲第一福利视频在线| 蜜桃av噜噜一区二区三区小说| 精品一区二区免费看| 国产精品亚洲一区二区三区在线 | 成人国产精品视频| 色婷婷激情一区二区三区| 欧美亚洲国产一区二区三区va| 中文字幕精品综合| 亚洲一区二区三区国产| 日韩黄色一级片| 国产一区999| a美女胸又www黄视频久久| 日本韩国欧美三级| 日韩精品一区二| 中文字幕一区二区三区在线播放| 亚洲大尺度视频在线观看| 久草这里只有精品视频| 99国产麻豆精品| 欧美一区二区三区在| 国产精品色婷婷| 亚洲成a人片综合在线| 国产一区日韩二区欧美三区| 97久久超碰精品国产| 日韩亚洲欧美在线| 一区在线中文字幕| 久久国产欧美日韩精品| www.日韩大片| 日韩欧美你懂的| 日韩伦理电影网| 久草中文综合在线| 欧美综合视频在线观看| 久久婷婷国产综合国色天香| 亚洲制服丝袜av| 国产黄色91视频| 欧美视频三区在线播放| 91色在线porny| 菠萝蜜视频在线观看一区| 在线观看亚洲专区| 久久久美女毛片| 亚洲成人1区2区| 国产成人精品免费一区二区| 欧美人与禽zozo性伦| 中国色在线观看另类| 蜜臀av一区二区三区| 91影视在线播放| 久久精品视频一区二区三区| 亚洲成av人综合在线观看| 成人av免费网站| 精品av综合导航| 午夜婷婷国产麻豆精品| 9久草视频在线视频精品| 日韩女优av电影| 午夜久久久久久久久| 99久久精品情趣| 国产亚洲精品资源在线26u| 日韩在线一二三区| 欧美性受xxxx| 一区二区三区欧美| 成人app下载| 国产婷婷精品av在线| 久久国产综合精品| 欧美在线免费视屏| 国产精品白丝在线| 国内精品国产成人| 欧美一区二区三区在线电影| 偷拍自拍另类欧美| 欧洲亚洲国产日韩| 亚洲精品日韩综合观看成人91| 成熟亚洲日本毛茸茸凸凹| 久久综合久久综合九色| 精品在线观看视频| 成人欧美一区二区三区白人| 成人永久aaa| 亚洲国产精品成人久久综合一区| 国产一区二区三区免费观看| 日韩欧美国产综合| 久久精品国产久精国产爱| 日韩欧美资源站| 激情综合网av| 国产喂奶挤奶一区二区三区| 国产ts人妖一区二区| 中文字幕日本不卡| 91麻豆福利精品推荐| 亚洲欧美另类小说视频| 91免费观看视频| 亚洲一区二区三区四区在线| 91九色最新地址| 亚洲成人免费影院| 日韩一区二区三区四区| 狠狠狠色丁香婷婷综合久久五月| 久久伊人中文字幕| 国产91高潮流白浆在线麻豆| 中文字幕一区在线观看视频| 欧美中文字幕不卡| 日韩av网站免费在线| 久久网站最新地址| 99久久99久久久精品齐齐| 亚洲一区二区三区四区在线观看| 欧美久久一二三四区| 精一区二区三区| 国产精品色一区二区三区| 在线观看日韩国产| 日本aⅴ免费视频一区二区三区| 精品国产91久久久久久久妲己| 成人性生交大合| 亚洲风情在线资源站| 欧美精品一区二区三区高清aⅴ | 伊人开心综合网| 欧美精品99久久久**| 国产美女精品一区二区三区|