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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? tty_io.c

?? linux0.02源代碼用于研究linux操作系統
?? C
字號:
/* *  linux/kernel/tty_io.c * *  (C) 1991  Linus Torvalds *//* * 'tty_io.c' gives an orthogonal feeling to tty's, be they consoles * or rs-channels. It also implements echoing, cooked mode etc. * * Kill-line thanks to John T Kohl, who also corrected VMIN = VTIME = 0. */#include <ctype.h>#include <errno.h>#include <signal.h>#include <unistd.h>#define ALRMMASK (1<<(SIGALRM-1))#include <linux/sched.h>#include <linux/tty.h>#include <asm/segment.h>#include <asm/system.h>int kill_pg(int pgrp, int sig, int priv);int is_orphaned_pgrp(int pgrp);#define _L_FLAG(tty,f)	((tty)->termios.c_lflag & f)#define _I_FLAG(tty,f)	((tty)->termios.c_iflag & f)#define _O_FLAG(tty,f)	((tty)->termios.c_oflag & f)#define L_CANON(tty)	_L_FLAG((tty),ICANON)#define L_ISIG(tty)	_L_FLAG((tty),ISIG)#define L_ECHO(tty)	_L_FLAG((tty),ECHO)#define L_ECHOE(tty)	_L_FLAG((tty),ECHOE)#define L_ECHOK(tty)	_L_FLAG((tty),ECHOK)#define L_ECHOCTL(tty)	_L_FLAG((tty),ECHOCTL)#define L_ECHOKE(tty)	_L_FLAG((tty),ECHOKE)#define L_TOSTOP(tty)	_L_FLAG((tty),TOSTOP)#define I_UCLC(tty)	_I_FLAG((tty),IUCLC)#define I_NLCR(tty)	_I_FLAG((tty),INLCR)#define I_CRNL(tty)	_I_FLAG((tty),ICRNL)#define I_NOCR(tty)	_I_FLAG((tty),IGNCR)#define I_IXON(tty)	_I_FLAG((tty),IXON)#define O_POST(tty)	_O_FLAG((tty),OPOST)#define O_NLCR(tty)	_O_FLAG((tty),ONLCR)#define O_CRNL(tty)	_O_FLAG((tty),OCRNL)#define O_NLRET(tty)	_O_FLAG((tty),ONLRET)#define O_LCUC(tty)	_O_FLAG((tty),OLCUC)#define C_SPEED(tty)	((tty)->termios.c_cflag & CBAUD)#define C_HUP(tty)	(C_SPEED((tty)) == B0)#ifndef MIN#define MIN(a,b) ((a) < (b) ? (a) : (b))#endif#define QUEUES	(3*(MAX_CONSOLES+NR_SERIALS+2*NR_PTYS))static struct tty_queue tty_queues[QUEUES];struct tty_struct tty_table[256];#define con_queues tty_queues#define rs_queues ((3*MAX_CONSOLES) + tty_queues)#define mpty_queues ((3*(MAX_CONSOLES+NR_SERIALS)) + tty_queues)#define spty_queues ((3*(MAX_CONSOLES+NR_SERIALS+NR_PTYS)) + tty_queues)#define con_table tty_table#define rs_table (64+tty_table)#define mpty_table (128+tty_table)#define spty_table (192+tty_table)int fg_console = 0;/* * these are the tables used by the machine code handlers. * you can implement virtual consoles. */struct tty_queue * table_list[]={	con_queues + 0, con_queues + 1,	rs_queues + 0, rs_queues + 1,	rs_queues + 3, rs_queues + 4	};void change_console(unsigned int new_console){	if (new_console == fg_console || new_console >= NR_CONSOLES)		return;	fg_console = new_console;	table_list[0] = con_queues + 0 + fg_console*3;	table_list[1] = con_queues + 1 + fg_console*3;	update_screen();}static void sleep_if_empty(struct tty_queue * queue){	cli();	while (!(current->signal & ~current->blocked) && EMPTY(queue))		interruptible_sleep_on(&queue->proc_list);	sti();}static void sleep_if_full(struct tty_queue * queue){	if (!FULL(queue))		return;	cli();	while (!(current->signal & ~current->blocked) && LEFT(queue)<128)		interruptible_sleep_on(&queue->proc_list);	sti();}void wait_for_keypress(void){	sleep_if_empty(tty_table[fg_console].secondary);}void copy_to_cooked(struct tty_struct * tty){	signed char c;	if (!(tty->read_q || tty->write_q || tty->secondary)) {		printk("copy_to_cooked: missing queues\n\r");		return;	}	while (1) {		if (EMPTY(tty->read_q))			break;		if (FULL(tty->secondary))			break;		GETCH(tty->read_q,c);		if (c==13) {			if (I_CRNL(tty))				c=10;			else if (I_NOCR(tty))				continue;		} else if (c==10 && I_NLCR(tty))			c=13;		if (I_UCLC(tty))			c=tolower(c);		if (L_CANON(tty)) {			if ((KILL_CHAR(tty) != _POSIX_VDISABLE) &&			    (c==KILL_CHAR(tty))) {				/* deal with killing the input line */				while(!(EMPTY(tty->secondary) ||				        (c=LAST(tty->secondary))==10 ||				        ((EOF_CHAR(tty) != _POSIX_VDISABLE) &&					 (c==EOF_CHAR(tty))))) {					if (L_ECHO(tty)) {						if (c<32)							PUTCH(127,tty->write_q);						PUTCH(127,tty->write_q);						tty->write(tty);					}					DEC(tty->secondary->head);				}				continue;			}			if ((ERASE_CHAR(tty) != _POSIX_VDISABLE) &&			    (c==ERASE_CHAR(tty))) {				if (EMPTY(tty->secondary) ||				   (c=LAST(tty->secondary))==10 ||				   ((EOF_CHAR(tty) != _POSIX_VDISABLE) &&				    (c==EOF_CHAR(tty))))					continue;				if (L_ECHO(tty)) {					if (c<32)						PUTCH(127,tty->write_q);					PUTCH(127,tty->write_q);					tty->write(tty);				}				DEC(tty->secondary->head);				continue;			}		}		if (I_IXON(tty)) {			if ((STOP_CHAR(tty) != _POSIX_VDISABLE) &&			    (c==STOP_CHAR(tty))) {				tty->stopped=1;				tty->write(tty);				continue;			}			if ((START_CHAR(tty) != _POSIX_VDISABLE) &&			    (c==START_CHAR(tty))) {				tty->stopped=0;				tty->write(tty);				continue;			}		}		if (L_ISIG(tty)) {			if ((INTR_CHAR(tty) != _POSIX_VDISABLE) &&			    (c==INTR_CHAR(tty))) {				kill_pg(tty->pgrp, SIGINT, 1);				continue;			}			if ((QUIT_CHAR(tty) != _POSIX_VDISABLE) &&			    (c==QUIT_CHAR(tty))) {				kill_pg(tty->pgrp, SIGQUIT, 1);				continue;			}			if ((SUSPEND_CHAR(tty) != _POSIX_VDISABLE) &&			    (c==SUSPEND_CHAR(tty))) {				if (!is_orphaned_pgrp(tty->pgrp))					kill_pg(tty->pgrp, SIGTSTP, 1);				continue;			}		}		if (c==10 || (EOF_CHAR(tty) != _POSIX_VDISABLE &&			      c==EOF_CHAR(tty)))			tty->secondary->data++;		if (L_ECHO(tty)) {			if (c==10) {				PUTCH(10,tty->write_q);				PUTCH(13,tty->write_q);			} else if (c<32) {				if (L_ECHOCTL(tty)) {					PUTCH('^',tty->write_q);					PUTCH(c+64,tty->write_q);				}			} else				PUTCH(c,tty->write_q);			tty->write(tty);		}		PUTCH(c,tty->secondary);	}	wake_up(&tty->secondary->proc_list);}/* * Called when we need to send a SIGTTIN or SIGTTOU to our process * group *  * We only request that a system call be restarted if there was if the  * default signal handler is being used.  The reason for this is that if * a job is catching SIGTTIN or SIGTTOU, the signal handler may not want  * the system call to be restarted blindly.  If there is no way to reset the * terminal pgrp back to the current pgrp (perhaps because the controlling * tty has been released on logout), we don't want to be in an infinite loop * while restarting the system call, and have it always generate a SIGTTIN * or SIGTTOU.  The default signal handler will cause the process to stop * thus avoiding the infinite loop problem.  Presumably the job-control * cognizant parent will fix things up before continuging its child process. */int tty_signal(int sig, struct tty_struct *tty){	if (is_orphaned_pgrp(current->pgrp))		return -EIO;		/* don't stop an orphaned pgrp */	(void) kill_pg(current->pgrp,sig,1);	if ((current->blocked & (1<<(sig-1))) ||	    ((int) current->sigaction[sig-1].sa_handler == 1)) 		return -EIO;		/* Our signal will be ignored */	else if (current->sigaction[sig-1].sa_handler)		return -EINTR;		/* We _will_ be interrupted :-) */	else		return -ERESTARTSYS;	/* We _will_ be interrupted :-) */					/* (but restart after we continue) */}int tty_read(unsigned channel, char * buf, int nr){	struct tty_struct * tty;	struct tty_struct * other_tty = NULL;	char c, * b=buf;	int minimum,time;	if (channel > 255)		return -EIO;	tty = TTY_TABLE(channel);	if (!(tty->write_q || tty->read_q || tty->secondary))		return -EIO;	if ((current->tty == channel) && (tty->pgrp != current->pgrp)) 		return(tty_signal(SIGTTIN, tty));	if (channel & 0x80)		other_tty = tty_table + (channel ^ 0x40);	time = 10L*tty->termios.c_cc[VTIME];	minimum = tty->termios.c_cc[VMIN];	if (L_CANON(tty)) {		minimum = nr;		current->timeout = 0xffffffff;		time = 0;	} else if (minimum)		current->timeout = 0xffffffff;	else {		minimum = nr;		if (time)			current->timeout = time + jiffies;		time = 0;	}	if (minimum>nr)		minimum = nr;	while (nr>0) {		if (other_tty)			other_tty->write(other_tty);		cli();		if (EMPTY(tty->secondary) || (L_CANON(tty) &&		    !FULL(tty->read_q) && !tty->secondary->data)) {			if (!current->timeout ||			  (current->signal & ~current->blocked)) {			  	sti();				break;			}			if (IS_A_PTY_SLAVE(channel) && C_HUP(other_tty))				break;			interruptible_sleep_on(&tty->secondary->proc_list);			sti();			continue;		}		sti();		do {			GETCH(tty->secondary,c);			if ((EOF_CHAR(tty) != _POSIX_VDISABLE &&			     c==EOF_CHAR(tty)) || c==10)				tty->secondary->data--;			if ((EOF_CHAR(tty) != _POSIX_VDISABLE &&			     c==EOF_CHAR(tty)) && L_CANON(tty))				break;			else {				put_fs_byte(c,b++);				if (!--nr)					break;			}			if (c==10 && L_CANON(tty))				break;		} while (nr>0 && !EMPTY(tty->secondary));		wake_up(&tty->read_q->proc_list);		if (time)			current->timeout = time+jiffies;		if (L_CANON(tty) || b-buf >= minimum)			break;	}	current->timeout = 0;	if ((current->signal & ~current->blocked) && !(b-buf))		return -ERESTARTSYS;	return (b-buf);}int tty_write(unsigned channel, char * buf, int nr){	static cr_flag=0;	struct tty_struct * tty;	char c, *b=buf;	if (channel > 255)		return -EIO;	tty = TTY_TABLE(channel);	if (!(tty->write_q || tty->read_q || tty->secondary))		return -EIO;	if (L_TOSTOP(tty) && 	    (current->tty == channel) && (tty->pgrp != current->pgrp)) 		return(tty_signal(SIGTTOU, tty));	while (nr>0) {		sleep_if_full(tty->write_q);		if (current->signal & ~current->blocked)			break;		while (nr>0 && !FULL(tty->write_q)) {			c=get_fs_byte(b);			if (O_POST(tty)) {				if (c=='\r' && O_CRNL(tty))					c='\n';				else if (c=='\n' && O_NLRET(tty))					c='\r';				if (c=='\n' && !cr_flag && O_NLCR(tty)) {					cr_flag = 1;					PUTCH(13,tty->write_q);					continue;				}				if (O_LCUC(tty))					c=toupper(c);			}			b++; nr--;			cr_flag = 0;			PUTCH(c,tty->write_q);		}		tty->write(tty);		if (nr>0)			schedule();	}	return (b-buf);}/* * Jeh, sometimes I really like the 386. * This routine is called from an interrupt, * and there should be absolutely no problem * with sleeping even in an interrupt (I hope). * Of course, if somebody proves me wrong, I'll * hate intel for all time :-). We'll have to * be careful and see to reinstating the interrupt * chips before calling this, though. * * I don't think we sleep here under normal circumstances * anyway, which is good, as the task sleeping might be * totally innocent. */void do_tty_interrupt(int tty){	copy_to_cooked(TTY_TABLE(tty));}void chr_dev_init(void){}void tty_init(void){	int i;	for (i=0 ; i < QUEUES ; i++)		tty_queues[i] = (struct tty_queue) {0,0,0,0,""};	rs_queues[0] = (struct tty_queue) {0x3f8,0,0,0,""};	rs_queues[1] = (struct tty_queue) {0x3f8,0,0,0,""};	rs_queues[3] = (struct tty_queue) {0x2f8,0,0,0,""};	rs_queues[4] = (struct tty_queue) {0x2f8,0,0,0,""};	for (i=0 ; i<256 ; i++) {		tty_table[i] =  (struct tty_struct) {		 	{0, 0, 0, 0, 0, INIT_C_CC},			0, 0, 0, NULL, NULL, NULL, NULL		};	}	con_init();	for (i = 0 ; i<NR_CONSOLES ; i++) {		con_table[i] = (struct tty_struct) {		 	{ICRNL,		/* change incoming CR to NL */			OPOST|ONLCR,	/* change outgoing NL to CRNL */			0,			IXON | ISIG | ICANON | ECHO | ECHOCTL | ECHOKE,			0,		/* console termio */			INIT_C_CC},			0,			/* initial pgrp */			0,			/* initial session */			0,			/* initial stopped */			con_write,			con_queues+0+i*3,con_queues+1+i*3,con_queues+2+i*3		};	}	for (i = 0 ; i<NR_SERIALS ; i++) {		rs_table[i] = (struct tty_struct) {			{0, /* no translation */			0,  /* no translation */			B2400 | CS8,			0,			0,			INIT_C_CC},			0,			0,			0,			rs_write,			rs_queues+0+i*3,rs_queues+1+i*3,rs_queues+2+i*3		};	}	for (i = 0 ; i<NR_PTYS ; i++) {		mpty_table[i] = (struct tty_struct) {			{0, /* no translation */			0,  /* no translation */			B9600 | CS8,			0,			0,			INIT_C_CC},			0,			0,			0,			mpty_write,			mpty_queues+0+i*3,mpty_queues+1+i*3,mpty_queues+2+i*3		};		spty_table[i] = (struct tty_struct) {			{0, /* no translation */			0,  /* no translation */			B9600 | CS8,			IXON | ISIG | ICANON,			0,			INIT_C_CC},			0,			0,			0,			spty_write,			spty_queues+0+i*3,spty_queues+1+i*3,spty_queues+2+i*3		};	}	rs_init();	printk("%d virtual consoles\n\r",NR_CONSOLES);	printk("%d pty's\n\r",NR_PTYS);}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
99久久99久久久精品齐齐| 久久精品一区二区三区四区| 精品久久久久久久人人人人传媒 | 91免费视频网址| 91精品欧美综合在线观看最新 | 久久久久国产精品厨房| 亚洲综合小说图片| 国产成人午夜99999| 在线播放视频一区| 一区二区三区四区精品在线视频| 国产剧情一区二区| 日韩精品中文字幕在线不卡尤物| 亚洲男帅同性gay1069| 成人三级在线视频| 久久亚洲一区二区三区明星换脸| 亚洲色图在线看| 久久亚洲一区二区三区四区| 一区二区三区91| 不卡的看片网站| 久久日一线二线三线suv| 夜夜操天天操亚洲| 91一区一区三区| 国产欧美日韩综合精品一区二区| 裸体在线国模精品偷拍| 91精品国产综合久久精品图片| 亚洲一区在线播放| 日本丰满少妇一区二区三区| 国产精品福利一区| 不卡av在线免费观看| 国产精品剧情在线亚洲| 成人午夜电影小说| 中文字幕欧美三区| 粗大黑人巨茎大战欧美成人| 国产欧美精品区一区二区三区| 五月天久久比比资源色| 99国产欧美久久久精品| 国产精品女主播在线观看| 成人性生交大片免费看中文网站| 精品久久久久av影院| 精品一区二区三区在线播放 | 亚洲一卡二卡三卡四卡 | 亚洲国产综合色| 欧美色视频在线观看| 亚洲va天堂va国产va久| 制服丝袜成人动漫| 青青国产91久久久久久 | 国产精品入口麻豆九色| 不卡的av网站| 亚洲成人免费观看| 欧美一区二区三区四区在线观看 | 久久www免费人成看片高清| a亚洲天堂av| 亚洲黄网站在线观看| 欧美性感一区二区三区| 免费观看日韩电影| 国产日韩亚洲欧美综合| 99热国产精品| 性做久久久久久| 久久综合色鬼综合色| 成人福利在线看| 香港成人在线视频| 久久久久九九视频| 一本一道波多野结衣一区二区| 亚洲国产精品一区二区www | 国产精品正在播放| 国产精品久久久久久久久搜平片 | 91久久国产综合久久| 日韩av电影一区| 国产精品人成在线观看免费| 97精品国产露脸对白| 免费高清不卡av| 亚洲欧美综合网| 日韩欧美在线不卡| 色综合久久中文综合久久97| 蜜臀久久99精品久久久久久9| 国产精品不卡在线| 欧美一级理论性理论a| 99国产精品久久久久久久久久久| 日韩av一级电影| 一区二区在线观看av| 久久久久久久久伊人| 欧美日韩一区二区在线观看| 成人自拍视频在线观看| 日韩av网站免费在线| 亚洲精品久久嫩草网站秘色| 久久精品欧美一区二区三区麻豆| 欧美三日本三级三级在线播放| 国产91在线观看丝袜| 喷水一区二区三区| 亚洲一区在线视频观看| 久久精品人人做| 久久综合精品国产一区二区三区| 欧美日韩一区二区在线观看视频| 91在线无精精品入口| 风流少妇一区二区| 精品一区二区综合| 日韩av一级片| 日本女人一区二区三区| 亚洲一区影音先锋| 亚洲精品乱码久久久久久久久| 国产欧美久久久精品影院| 日韩精品最新网址| 欧美一级搡bbbb搡bbbb| 欧美日韩一本到| 欧美日韩在线观看一区二区| 欧美视频在线一区| 在线观看亚洲一区| 色屁屁一区二区| 色婷婷综合久久| 色天天综合色天天久久| 日本韩国一区二区| 在线一区二区三区四区五区 | 成人激情小说网站| 国产成人在线视频免费播放| 国产精品综合久久| 国产黄色成人av| 成人精品免费视频| av爱爱亚洲一区| 97久久精品人人爽人人爽蜜臀| 91在线播放网址| 日本高清成人免费播放| 欧美性一区二区| 在线成人av影院| 欧美一区二区三区视频在线| 欧美va亚洲va香蕉在线| 久久久久高清精品| 国产精品电影一区二区三区| 亚洲黄色录像片| 亚洲电影第三页| 美日韩一级片在线观看| 国产精品中文有码| 97久久久精品综合88久久| 欧美亚洲一区三区| 欧美一级国产精品| 国产日韩欧美激情| 亚洲欧美日韩国产手机在线 | 日本欧美在线看| 国产精品456露脸| 色综合天天天天做夜夜夜夜做| 欧美视频中文字幕| 欧美精品一区二区久久婷婷| 国产精品久久久久精k8| 亚洲国产成人精品视频| 麻豆中文一区二区| bt欧美亚洲午夜电影天堂| 欧美日韩国产免费一区二区| 精品福利视频一区二区三区| 国产精品女主播在线观看| 午夜视频一区二区| 国产一区二区三区精品欧美日韩一区二区三区| 国产尤物一区二区| 97久久精品人人爽人人爽蜜臀| 欧美日韩国产免费一区二区 | 视频一区中文字幕| 国产高清精品久久久久| 在线观看日产精品| 久久久精品免费观看| 亚洲一区视频在线观看视频| 国产精品911| 91精品国产色综合久久久蜜香臀| 国产日韩精品一区二区三区在线| 亚洲一区二区精品视频| 国产美女娇喘av呻吟久久| 91九色02白丝porn| 欧美激情资源网| 奇米四色…亚洲| 色播五月激情综合网| 久久久亚洲国产美女国产盗摄| 一区二区在线看| 国产成人精品午夜视频免费| 欧美高清www午色夜在线视频| 国产欧美一区二区精品性色超碰| 奇米综合一区二区三区精品视频| 色域天天综合网| 欧美韩国日本不卡| 激情文学综合丁香| 6080国产精品一区二区| 亚洲欧美日韩小说| av电影一区二区| 国产精品无遮挡| 国产一二精品视频| 欧美精品一区二区三区一线天视频 | 91在线高清观看| 欧美高清在线精品一区| 国产一区二区不卡老阿姨| 日韩一区二区三区在线观看 | 国产乱码精品1区2区3区| 91精品国产91热久久久做人人| 一区二区三区资源| 一本到高清视频免费精品| 中文字幕二三区不卡| 国产乱人伦偷精品视频免下载| 欧美一区二区在线播放| 日欧美一区二区| 欧美三级中文字幕在线观看| 亚洲欧美一区二区三区孕妇| k8久久久一区二区三区| 中文字幕亚洲欧美在线不卡| 成人激情动漫在线观看| 国产精品灌醉下药二区|