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

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

?? keyboard.c

?? LINUX1.0源代碼,代碼條理清晰
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
 * linux/kernel/chr_drv/keyboard.c
 *
 * Keyboard driver for Linux v0.99 using Latin-1.
 *
 * Written for linux by Johan Myreen as a translation from
 * the assembly version by Linus (with diacriticals added)
 *
 * Some additional features added by Christoph Niemann (ChN), March 1993
 * Loadable keymaps by Risto Kankkunen, May 1993
 * Diacriticals redone & other small changes, aeb@cwi.nl, June 1993
 */

#define KEYBOARD_IRQ 1

#include <linux/sched.h>
#include <linux/tty.h>
#include <linux/mm.h>
#include <linux/ptrace.h>
#include <linux/interrupt.h>
#include <linux/config.h>
#include <linux/signal.h>
#include <linux/string.h>

#include <asm/bitops.h>

#include "kbd_kern.h"
#include "diacr.h"

#define SIZE(x) (sizeof(x)/sizeof((x)[0]))

#define KBD_REPORT_ERR
#define KBD_REPORT_UNKN

#ifndef KBD_DEFMODE
#define KBD_DEFMODE ((1 << VC_REPEAT) | (1 << VC_META))
#endif

#ifndef KBD_DEFLEDS
/*
 * Some laptops take the 789uiojklm,. keys as number pad when NumLock
 * is on. This seems a good reason to start with NumLock off.
 */
#define KBD_DEFLEDS 0
#endif

#ifndef KBD_DEFLOCK
#define KBD_DEFLOCK 0
#endif

/*
 * The default IO slowdown is doing 'inb()'s from 0x61, which should be
 * safe. But as that is the keyboard controller chip address, we do our
 * slowdowns here by doing short jumps: the keyboard controller should
 * be able to keep up
 */
#define REALLY_SLOW_IO
#define SLOW_IO_BY_JUMPING
#include <asm/io.h>
#include <asm/system.h>

extern void do_keyboard_interrupt(void);
extern void ctrl_alt_del(void);
extern void change_console(unsigned int new_console);
extern void scrollback(int);
extern void scrollfront(int);

#define fake_keyboard_interrupt() \
__asm__ __volatile__("int $0x21")

unsigned char kbd_read_mask = 0x01;	/* modified by psaux.c */

/*
 * global state includes the following, and various static variables
 * in this module: prev_scancode, shift_state, diacr, npadch,
 *   dead_key_next, last_console
 */

/* shift state counters.. */
static unsigned char k_down[NR_SHIFT] = {0, };
/* keyboard key bitmap */
static unsigned long key_down[8] = { 0, };

static int want_console = -1;
static int last_console = 0;		/* last used VC */
static int dead_key_next = 0;
static int shift_state = 0;
static int npadch = -1;		        /* -1 or number assembled on pad */
static unsigned char diacr = 0;
static char rep = 0;			/* flag telling character repeat */
struct kbd_struct kbd_table[NR_CONSOLES];
static struct kbd_struct * kbd = kbd_table;
static struct tty_struct * tty = NULL;

/* used only by send_data - set by keyboard_interrupt */
static volatile unsigned char acknowledge = 0;
static volatile unsigned char resend = 0;

typedef void (*k_hand)(unsigned char value, char up_flag);
typedef void (k_handfn)(unsigned char value, char up_flag);

static k_handfn
        do_self, do_fn, do_spec, do_pad, do_dead, do_cons, do_cur, do_shift,
	do_meta, do_ascii, do_lock, do_lowercase;

static k_hand key_handler[] = {
	do_self, do_fn, do_spec, do_pad, do_dead, do_cons, do_cur, do_shift,
	do_meta, do_ascii, do_lock, do_lowercase
};

/* maximum values each key_handler can handle */
const int max_vals[] = {
	255, NR_FUNC - 1, 14, 17, 4, 255, 3, NR_SHIFT,
	255, 9, 3, 255
};

const int NR_TYPES = SIZE(max_vals);

static void put_queue(int);
static unsigned char handle_diacr(unsigned char);

/* pt_regs - set by keyboard_interrupt(), used by show_ptregs() */
static struct pt_regs * pt_regs;

static int got_break = 0;

static inline void kb_wait(void)
{
	int i;

	for (i=0; i<0x10000; i++)
		if ((inb_p(0x64) & 0x02) == 0)
			break;
}

static inline void send_cmd(unsigned char c)
{
	kb_wait();
	outb(c,0x64);
}

/*
 * Translation of escaped scancodes to keysyms.
 * This should be user-settable.
 */
#define E0_BASE 96

#define E0_KPENTER (E0_BASE+0)
#define E0_RCTRL   (E0_BASE+1)
#define E0_KPSLASH (E0_BASE+2)
#define E0_PRSCR   (E0_BASE+3)
#define E0_RALT    (E0_BASE+4)
#define E0_BREAK   (E0_BASE+5)  /* (control-pause) */
#define E0_HOME    (E0_BASE+6)
#define E0_UP      (E0_BASE+7)
#define E0_PGUP    (E0_BASE+8)
#define E0_LEFT    (E0_BASE+9)
#define E0_RIGHT   (E0_BASE+10)
#define E0_END     (E0_BASE+11)
#define E0_DOWN    (E0_BASE+12)
#define E0_PGDN    (E0_BASE+13)
#define E0_INS     (E0_BASE+14)
#define E0_DEL     (E0_BASE+15)
/* BTC */
#define E0_MACRO   (E0_BASE+16)
/* LK450 */
#define E0_F13     (E0_BASE+17)
#define E0_F14     (E0_BASE+18)
#define E0_HELP    (E0_BASE+19)
#define E0_DO      (E0_BASE+20)
#define E0_F17     (E0_BASE+21)
#define E0_KPMINPLUS (E0_BASE+22)

#define E1_PAUSE   (E0_BASE+23)

static unsigned char e0_keys[128] = {
  0, 0, 0, 0, 0, 0, 0, 0,			      /* 0x00-0x07 */
  0, 0, 0, 0, 0, 0, 0, 0,			      /* 0x08-0x0f */
  0, 0, 0, 0, 0, 0, 0, 0,			      /* 0x10-0x17 */
  0, 0, 0, 0, E0_KPENTER, E0_RCTRL, 0, 0,	      /* 0x18-0x1f */
  0, 0, 0, 0, 0, 0, 0, 0,			      /* 0x20-0x27 */
  0, 0, 0, 0, 0, 0, 0, 0,			      /* 0x28-0x2f */
  0, 0, 0, 0, 0, E0_KPSLASH, 0, E0_PRSCR,	      /* 0x30-0x37 */
  E0_RALT, 0, 0, 0, 0, E0_F13, E0_F14, E0_HELP,	      /* 0x38-0x3f */
  E0_DO, E0_F17, 0, 0, 0, 0, E0_BREAK, E0_HOME,	      /* 0x40-0x47 */
  E0_UP, E0_PGUP, 0, E0_LEFT, 0, E0_RIGHT, E0_KPMINPLUS, E0_END,/* 0x48-0x4f */
  E0_DOWN, E0_PGDN, E0_INS, E0_DEL, 0, 0, 0, 0,	      /* 0x50-0x57 */
  0, 0, 0, 0, 0, 0, 0, 0,			      /* 0x58-0x5f */
  0, 0, 0, 0, 0, 0, 0, 0,			      /* 0x60-0x67 */
  0, 0, 0, 0, 0, 0, 0, E0_MACRO,		      /* 0x68-0x6f */
  0, 0, 0, 0, 0, 0, 0, 0,			      /* 0x70-0x77 */
  0, 0, 0, 0, 0, 0, 0, 0			      /* 0x78-0x7f */
};

static void keyboard_interrupt(int int_pt_regs)
{
	unsigned char scancode;
	static unsigned int prev_scancode = 0;   /* remember E0, E1 */
	char up_flag;		                 /* 0 or 0200 */
	char raw_mode;

	pt_regs = (struct pt_regs *) int_pt_regs;
	send_cmd(0xAD);		/* disable keyboard */
	kb_wait();
	if ((inb_p(0x64) & kbd_read_mask) != 0x01)
		goto end_kbd_intr;
	scancode = inb(0x60);
	mark_bh(KEYBOARD_BH);
	if (scancode == 0xfa) {
		acknowledge = 1;
		goto end_kbd_intr;
	} else if (scancode == 0xfe) {
		resend = 1;
		goto end_kbd_intr;
	} else if (scancode == 0) {
#ifdef KBD_REPORT_ERR
	        printk("keyboard buffer overflow\n");
#endif
		goto end_kbd_intr;
	} else if (scancode == 0xff) {
#ifdef KBD_REPORT_ERR
	        printk("keyboard error\n");
#endif
	        prev_scancode = 0;
	        goto end_kbd_intr;
	}
	tty = TTY_TABLE(0);
 	kbd = kbd_table + fg_console;
	if ((raw_mode = vc_kbd_mode(kbd,VC_RAW))) {
 		put_queue(scancode);
		/* we do not return yet, because we want to maintain
		   the key_down array, so that we have the correct
		   values when finishing RAW mode or when changing VT's */
 	}
	if (scancode == 0xe0 || scancode == 0xe1) {
		prev_scancode = scancode;
		goto end_kbd_intr;
 	}

 	/*
	 *  Convert scancode to keysym, using prev_scancode.
 	 */
	up_flag = (scancode & 0200);
 	scancode &= 0x7f;
  
	if (prev_scancode) {
	  /*
	   * usually it will be 0xe0, but a Pause key generates
	   * e1 1d 45 e1 9d c5 when pressed, and nothing when released
	   */
	  if (prev_scancode != 0xe0) {
	      if (prev_scancode == 0xe1 && scancode == 0x1d) {
		  prev_scancode = 0x100;
		  goto end_kbd_intr;
	      } else if (prev_scancode == 0x100 && scancode == 0x45) {
		  scancode = E1_PAUSE;
		  prev_scancode = 0;
	      } else {
		  printk("keyboard: unknown e1 escape sequence\n");
		  prev_scancode = 0;
		  goto end_kbd_intr;
	      }
	  } else {
	      prev_scancode = 0;
	      /*
	       *  The keyboard maintains its own internal caps lock and
	       *  num lock statuses. In caps lock mode E0 AA precedes make
	       *  code and E0 2A follows break code. In num lock mode,
	       *  E0 2A precedes make code and E0 AA follows break code.
	       *  We do our own book-keeping, so we will just ignore these.
	       */
	      /*
	       *  For my keyboard there is no caps lock mode, but there are
	       *  both Shift-L and Shift-R modes. The former mode generates
	       *  E0 2A / E0 AA pairs, the latter E0 B6 / E0 36 pairs.
	       *  So, we should also ignore the latter. - aeb@cwi.nl
	       */
	      if (scancode == 0x2a || scancode == 0x36)
		goto end_kbd_intr;

	      if (e0_keys[scancode])
		scancode = e0_keys[scancode];
	      else if (!raw_mode) {
#ifdef KBD_REPORT_UNKN
		  printk("keyboard: unknown scancode e0 %02x\n", scancode);
#endif
		  goto end_kbd_intr;
	      }
	  }
	} else if (scancode >= E0_BASE && !raw_mode) {
#ifdef KBD_REPORT_UNKN
	  printk("keyboard: scancode (%02x) not in range 00 - %2x\n",
		 scancode, E0_BASE - 1);
#endif
	  goto end_kbd_intr;
 	}
  
	/*
	 * At this point the variable `scancode' contains the keysym.
	 * We keep track of the up/down status of the key, and
	 * return the keysym if in MEDIUMRAW mode.
	 * (Note: earlier kernels had a bug and did not pass the up/down
	 * bit to applications.)
	 */

	if (up_flag) {
 		clear_bit(scancode, key_down);
		rep = 0;
	} else
 		rep = set_bit(scancode, key_down);
  
	if (raw_mode)
	        goto end_kbd_intr;

 	if (vc_kbd_mode(kbd, VC_MEDIUMRAW)) {
 		put_queue(scancode + up_flag);
		goto end_kbd_intr;
 	}
  
 	/*
	 * Small change in philosophy: earlier we defined repetition by
	 *	 rep = scancode == prev_keysym;
	 *	 prev_keysym = scancode;
	 * but now by the fact that the depressed key was down already.
	 * Does this ever make a difference?
	 */

	/*
 	 *  Repeat a key only if the input buffers are empty or the
 	 *  characters get echoed locally. This makes key repeat usable
 	 *  with slow applications and under heavy loads.
	 */
	if (!rep || 
	    (vc_kbd_mode(kbd,VC_REPEAT) && tty &&
	     (L_ECHO(tty) || (EMPTY(&tty->secondary) && EMPTY(&tty->read_q)))))
	{
		u_short key_code;
		u_char type;

		/* the XOR below used to be an OR */
		int shift_final = shift_state ^ kbd->lockstate;

		key_code = key_map[shift_final][scancode];
		type = KTYP(key_code);

		if (type == KT_LETTER) {
		    type = KT_LATIN;
		    if (vc_kbd_led(kbd,VC_CAPSLOCK))
			key_code = key_map[shift_final ^ (1<<KG_SHIFT)][scancode];
		}
		(*key_handler[type])(key_code & 0xff, up_flag);
	}

end_kbd_intr:
	send_cmd(0xAE);         /* enable keyboard */
}

static void put_queue(int ch)
{
	struct tty_queue *qp;

	wake_up(&keypress_wait);
	if (!tty)
		return;
	qp = &tty->read_q;

	if (LEFT(qp)) {
		qp->buf[qp->head] = ch;
		INC(qp->head);
	}
}

static void puts_queue(char *cp)
{
	struct tty_queue *qp;
	char ch;

	/* why interruptible here, plain wake_up above? */
	wake_up_interruptible(&keypress_wait);
	if (!tty)
		return;
	qp = &tty->read_q;

	while ((ch = *(cp++)) != 0) {
		if (LEFT(qp)) {
			qp->buf[qp->head] = ch;
			INC(qp->head);
		}
	}
}

static void applkey(int key, char mode)
{
	static char buf[] = { 0x1b, 'O', 0x00, 0x00 };

	buf[1] = (mode ? 'O' : '[');
	buf[2] = key;
	puts_queue(buf);
}

static void enter(void)
{
	put_queue(13);
	if (vc_kbd_mode(kbd,VC_CRLF))
		put_queue(10);
}

static void caps_toggle(void)
{
	if (rep)
		return;
	chg_vc_kbd_led(kbd,VC_CAPSLOCK);
}

static void caps_on(void)
{
	if (rep)
		return;
	set_vc_kbd_led(kbd,VC_CAPSLOCK);
}

static void show_ptregs(void)
{
	if (!pt_regs)
		return;
	printk("\n");
	printk("EIP: %04x:%08lx",0xffff & pt_regs->cs,pt_regs->eip);
	if (pt_regs->cs & 3)
		printk(" ESP: %04x:%08lx",0xffff & pt_regs->ss,pt_regs->esp);
	printk(" EFLAGS: %08lx\n",pt_regs->eflags);
	printk("EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
		pt_regs->orig_eax,pt_regs->ebx,pt_regs->ecx,pt_regs->edx);
	printk("ESI: %08lx EDI: %08lx EBP: %08lx",
		pt_regs->esi, pt_regs->edi, pt_regs->ebp);
	printk(" DS: %04x ES: %04x FS: %04x GS: %04x\n",
		0xffff & pt_regs->ds,0xffff & pt_regs->es,
		0xffff & pt_regs->fs,0xffff & pt_regs->gs);
}

static void hold(void)
{
	if (rep || !tty)
		return;

	/*
	 * Note: SCROLLOCK wil be set (cleared) by stop_tty (start_tty);
	 * these routines are also activated by ^S/^Q.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲欧美在线另类| 亚洲一区二区视频在线观看| 精品一区免费av| 欧美美女直播网站| 亚洲va国产天堂va久久en| 在线视频一区二区三| 亚洲欧美国产三级| 色综合视频一区二区三区高清| 中文一区在线播放| 成人爽a毛片一区二区免费| 国产欧美久久久精品影院| 国产suv一区二区三区88区| 2020国产成人综合网| 国产精品 欧美精品| 国产欧美日韩不卡| 成人免费毛片a| 亚洲天堂av一区| 一本久道久久综合中文字幕| 一区二区三区中文字幕电影| 欧美在线免费观看亚洲| 亚洲h动漫在线| 91精品国产综合久久国产大片| 日韩成人精品在线| 日韩精品最新网址| 国产精品一二三四五| 国产精品天干天干在观线| 99视频有精品| 亚洲bt欧美bt精品777| 欧美一区二区视频观看视频| 捆绑紧缚一区二区三区视频| 久久久久亚洲综合| 99精品国产视频| 性做久久久久久免费观看| 欧美一区二区三区视频免费播放| 久久99国产精品久久99| 中文字幕乱码久久午夜不卡| 91蝌蚪porny九色| 视频在线观看一区| 久久久久久毛片| 色香色香欲天天天影视综合网| 视频一区国产视频| 久久久久久久久久久黄色| 91婷婷韩国欧美一区二区| 亚洲成人在线免费| 久久久噜噜噜久久中文字幕色伊伊| 成人福利视频网站| 亚洲国产综合91精品麻豆| 精品国产91洋老外米糕| 99久久综合精品| 日韩高清在线观看| 国产肉丝袜一区二区| 色综合天天综合网国产成人综合天| 日韩福利视频网| 国产婷婷一区二区| 欧美日韩在线免费视频| 极品瑜伽女神91| 一区二区三区在线影院| 精品日产卡一卡二卡麻豆| 91丨九色丨国产丨porny| 热久久国产精品| 日韩一区有码在线| 日韩一区二区三区高清免费看看 | 国产精品乱码久久久久久| 欧美性xxxxxx少妇| 国产精品456| 亚洲一区二区美女| 久久青草欧美一区二区三区| 在线看国产一区| 国产一区二区在线影院| 夜夜爽夜夜爽精品视频| 久久免费视频一区| 欧美吻胸吃奶大尺度电影| 国产成人av资源| 亚洲3atv精品一区二区三区| 国产精品女主播av| 欧美一区二区免费观在线| 99热精品一区二区| 久久99国产精品麻豆| 亚洲一区二区三区中文字幕| 久久久www成人免费毛片麻豆| 欧美日韩免费电影| av在线播放不卡| 国内一区二区在线| 丝袜美腿亚洲色图| 亚洲激情校园春色| 国产精品免费久久久久| 精品日韩在线观看| 欧美精品一二三四| 91福利在线观看| 成人av影院在线| 国产一区二区三区免费在线观看| 亚洲电影在线免费观看| 国产精品嫩草久久久久| 久久综合色8888| 日韩情涩欧美日韩视频| 欧美在线高清视频| 色综合天天综合| 岛国一区二区在线观看| 久久99这里只有精品| 亚洲第一福利视频在线| 亚洲精品亚洲人成人网| 亚洲国产精品传媒在线观看| 精品国产乱码91久久久久久网站| 欧美群妇大交群中文字幕| 色婷婷av一区二区三区大白胸| 国产盗摄视频一区二区三区| 麻豆成人久久精品二区三区红 | 国产一二精品视频| 免费观看成人av| 五月婷婷久久综合| 亚洲国产精品一区二区www在线 | 精品伊人久久久久7777人| 日韩国产在线一| 午夜av一区二区三区| 一区二区三区免费观看| 亚洲视频每日更新| 日韩理论片网站| 综合久久一区二区三区| 国产精品久久久久久久久动漫| 国产日韩欧美a| 国产目拍亚洲精品99久久精品| 久久无码av三级| 久久久久高清精品| 久久久久99精品国产片| 久久久不卡影院| 久久精品欧美日韩精品| 国产拍欧美日韩视频二区| 久久人人爽人人爽| 日本一区二区三区四区在线视频| 久久精品这里都是精品| 欧美国产97人人爽人人喊| 欧美国产成人精品| 亚洲视频在线观看三级| 亚洲人xxxx| 亚洲国产精品久久艾草纯爱| 亚洲成av人**亚洲成av**| 日韩精品一二三四| 麻豆精品国产传媒mv男同| 久久97超碰色| 粉嫩13p一区二区三区| 成人不卡免费av| 色婷婷一区二区| 欧美私人免费视频| 51精品秘密在线观看| 欧美xxxxx牲另类人与| 久久婷婷成人综合色| 国产精品国产三级国产普通话蜜臀| 国产精品成人免费精品自在线观看| ㊣最新国产の精品bt伙计久久| 亚洲靠逼com| 亚洲成人免费看| 久久99热狠狠色一区二区| 国产精品99久久久久久久vr | 欧美精品日日鲁夜夜添| 日韩一区二区三区四区 | 中文无字幕一区二区三区| 国产精品国产三级国产三级人妇| 一区二区三区在线高清| 日韩精品成人一区二区三区| 国产资源在线一区| 成人高清免费观看| 欧美三级电影在线观看| 精品奇米国产一区二区三区| 欧美国产成人在线| 亚洲大片在线观看| 国精产品一区一区三区mba桃花| www.亚洲激情.com| 欧美日韩电影在线| 久久一区二区三区四区| 亚洲色图制服诱惑 | 欧美精品国产精品| 精品欧美一区二区在线观看| 中文av一区二区| 亚洲高清免费视频| 国产麻豆午夜三级精品| 一本色道久久综合亚洲aⅴ蜜桃| 欧美放荡的少妇| 国产欧美va欧美不卡在线| 亚洲国产精品久久久久婷婷884| 久久不见久久见免费视频7| 成人aa视频在线观看| 3d动漫精品啪啪| 国产精品国产三级国产a| 视频一区二区不卡| 国产99精品视频| 欧美剧情片在线观看| 久久精品亚洲国产奇米99| 亚洲综合免费观看高清完整版| 久久99精品国产.久久久久久| 一本色道久久综合狠狠躁的推荐| 日韩欧美激情一区| 亚洲精品久久7777| 国产一区亚洲一区| 欧美日韩一二区| 国产精品午夜春色av| 热久久免费视频| 在线观看一区日韩| 国产色一区二区| 日韩av一区二区三区四区| 不卡电影一区二区三区|