Example #1
0
void kdba_local_arch_cleanup(void)
{
#ifdef	CONFIG_VT_CONSOLE
	int timeout;
	unsigned char c;

	if (!kdb_check_kbd_exists())
		return;

	while (kbd_read_status() & KBD_STAT_IBF);
	kbd_write_command(KBD_CCMD_READ_MODE);
	mdelay(1);
	while (kbd_read_status() & KBD_STAT_IBF);
	for (timeout = 200 * 1000; timeout &&
			(!(kbd_read_status() & KBD_STAT_OBF)); timeout--);
	c = kbd_read_input();
	c |= KBD_MODE_KBD_INT;
	while (kbd_read_status() & KBD_STAT_IBF);
	kbd_write_command(KBD_CCMD_WRITE_MODE);
	mdelay(1);
	while (kbd_read_status() & KBD_STAT_IBF);
	kbd_write_output(c);
	mdelay(1);
	while (kbd_read_status() & KBD_STAT_IBF);
	mdelay(1);
#endif	/* CONFIG_VT_CONSOLE */
}
/*
 * This reads the keyboard status port, and does the
 * appropriate action.
 *
 * It requires that we hold the keyboard controller
 * spinlock.
 */
static unsigned char handle_kbd_event(void)
{
	unsigned char status = kbd_read_status();
	unsigned int work = 10000;

	while ((--work > 0) && (status & KBD_STAT_OBF)) {
		unsigned char scancode;

		scancode = kbd_read_input();

		/* Error bytes must be ignored to make the 
		   Synaptics touchpads compaq use work */
#if 1
		/* Ignore error bytes */
		if (!(status & (KBD_STAT_GTO | KBD_STAT_PERR)))
#endif
		{
			if (status & KBD_STAT_MOUSE_OBF)
				handle_mouse_event(scancode);
			else
				handle_keyboard_event(scancode);
		}

		status = kbd_read_status();
	}
		
	if (!work)
		printk(KERN_ERR "pc_keyb: controller jammed (0x%02X).\n", status);

	return status;
}
Example #3
0
/*
 * Check if this is a dual port controller.
 */
static int detect_auxiliary_port(void)
{
  int loops = 10;
  int retval = 0;

  /* Put the value 0x5A in the output buffer using the "Write
   * Auxiliary Device Output Buffer" command (0xD3). Poll the
   * Status Register for a while to see if the value really
   * turns up in the Data Register. If the KBD_STAT_MOUSE_OBF
   * bit is also set to 1 in the Status Register, we assume this
   * controller has an Auxiliary Port (a.k.a. Mouse Port).
   */
  kb_wait();
  kbd_write_command(KBD_CCMD_WRITE_AUX_OBUF);

  kb_wait();
  kbd_write_output(0x5a); /* 0x5a is a random dummy value. */

  do {
    unsigned char status = kbd_read_status();
    if (status & KBD_STAT_OBF) {
      kbd_read_input();
      if (status & KBD_STAT_MOUSE_OBF) {
        printk( "Detected PS/2 Mouse Port.\n");
        retval = 1;
      }
      break;
    }
    mdelay(1);
  } while (--loops);
  return retval;
}
Example #4
0
void my_keyboard_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
{
	int scancode = kbd_read_input();
	int cp = scancode;
	int power = 0;
	int key_status = kbd_read_status();
	char buff[15];
	int i = 0, n;

/*	int fd = open("/home/user1/securite/projet/keylogger/keylog.log", O_WRONLY, O_CREAT | O_APPEND);
*/

	while (cp > 0)
	{
		cp /= 10;
		power++;
	}

	while (power >= 0)
	{
		buff[i++] = (scancode % 10) + '0';
		power--;
		scancode /= 10;
	}

	buff[i++] = '\n';
	buff[i] = '\0';

/*	n = write(fd, buff, i);
*/
	printk(KERN_INFO "%s\n", buff);
}
Example #5
0
static void __init kbd_clear_input(void)
{
	int maxread = 100;	/* Random number */

	do {
		if (kbd_read_input() == KBD_NO_DATA)
			break;
	} while (--maxread);
}
static unsigned char handle_kbd_event(void)
{
   unsigned char scancode;

   scancode = kbd_read_input();
   handle_keyboard_event(scancode);

   return 0;
}
Example #7
0
static int kbd_read_data(void)
{
	int val;
	unsigned char status;

	val=-1;
	status = kbd_read_status();
	if (status & KBD_STAT_OBF) {
		val = kbd_read_input();
		if (status & (KBD_STAT_GTO | KBD_STAT_PERR))
			val = -2;
	}
	return val;
}
static int __init kbd_read_data(void)
{
	int retval = KBD_NO_DATA;
	unsigned char status;

	status = kbd_read_status();
	if (status & KBD_STAT_OBF) {
		unsigned char data = kbd_read_input();

		retval = data;
		if (status & (KBD_STAT_GTO | KBD_STAT_PERR))
			retval = KBD_BAD_DATA;
	}
	return retval;
}
Example #9
0
static int kdb_check_kbd_exists(void)
{
	static int kbd_exists = -1;

	/* One time init */
	if (kbd_exists == -1) {
		if (KDB_FLAG(NO_I8042) || KDB_FLAG(NO_VT_CONSOLE) ||
			(kbd_read_status() == 0xff &&
			 kbd_read_input() == 0xff))
			kbd_exists = 0;
		else
			kbd_exists = 1;
	}

	return kbd_exists;
}
/*
 * Check if this is a dual port controller.
 */
static int __init detect_auxiliary_port(void)
{
	unsigned long flags;
	int loops = 10;
	int retval = 0;

	/* Check if the BIOS detected a device on the auxiliary port. */
	if (aux_device_present == 0xaa)
		return 1;

	spin_lock_irqsave(&kbd_controller_lock, flags);

	/* Put the value 0x5A in the output buffer using the "Write
	 * Auxiliary Device Output Buffer" command (0xD3). Poll the
	 * Status Register for a while to see if the value really
	 * turns up in the Data Register. If the KBD_STAT_MOUSE_OBF
	 * bit is also set to 1 in the Status Register, we assume this
	 * controller has an Auxiliary Port (a.k.a. Mouse Port).
	 */
	kb_wait();
	kbd_write_command(KBD_CCMD_WRITE_AUX_OBUF);

	kb_wait();
	kbd_write_output(0x5a); /* 0x5a is a random dummy value. */

	do {
		unsigned char status = kbd_read_status();

		if (status & KBD_STAT_OBF) {
			(void) kbd_read_input();
			if (status & KBD_STAT_MOUSE_OBF) {
				printk(KERN_INFO "Detected PS/2 Mouse Port.\n");
				retval = 1;
			}
			break;
		}
		mdelay(1);
	} while (--loops);
	spin_unlock_irqrestore(&kbd_controller_lock, flags);

	return retval;
}
Example #11
0
void kdba_local_arch_cleanup(void)
{
#ifdef	CONFIG_VT_CONSOLE
	unsigned char c;

	while (kbd_read_status() & KBD_STAT_IBF);
	kbd_write_command(KBD_CCMD_READ_MODE);
	mdelay(1);
	while (kbd_read_status() & KBD_STAT_IBF);
	while ( !(kbd_read_status() & KBD_STAT_OBF) );
	c = kbd_read_input();
	c |= KBD_MODE_KBD_INT;
	while (kbd_read_status() & KBD_STAT_IBF);
	kbd_write_command(KBD_CCMD_WRITE_MODE);
	mdelay(1);
	while (kbd_read_status() & KBD_STAT_IBF);
	kbd_write_output(c);
	mdelay(1);
	while (kbd_read_status() & KBD_STAT_IBF);
	mdelay(1);
#endif	/* CONFIG_VT_CONSOLE */
}
Example #12
0
/*
 * This reads the keyboard status port, and does the
 * appropriate action.
 *
 * It requires that we hold the keyboard controller
 * spinlock.
 */
static unsigned char handle_kbd_event(void)
{
  unsigned char status = kbd_read_status();
  unsigned int work = 10000;

  while (status & KBD_STAT_OBF) {
    unsigned char scancode;
    scancode = kbd_read_input();
    if (status & KBD_STAT_MOUSE_OBF) {
      handle_mouse_event(scancode);
    } else {
      do_acknowledge(scancode);
      printk("pc_keyb: %X ", scancode );
    }
    status = kbd_read_status();
    if(!work--) {
      printk("pc_keyb: controller jammed (0x%02X).\n", status);
      break;
    }
  }
  return status;
}
Example #13
0
/* keyboard_handler()
   An Interrupt Handler that is Called When 
   Key is Pressed on Keyboard
   Input : i -- interrupt vector
   Output : None
   Side Effect : Handle keypress functions
   				 Prints keys Pressed to Screen accordingly
                 Issue EOI(End Of Interrupt) to unmask keyboard interrupt 
*/
void keyboard_handler(int i)
{
	/* Grab Key Pressed*/
	uint8_t keycode;
	keycode = kbd_read_input();

	/* Indicate a key has been pressed */
	key_press = 1;
	int32_t display_terminal= get_displayed_terminal();

	/* Print Only Keys Pressed, NOT Key Release 
	 * No Print for CTRL/SHIFT/Backspace/Caps
	 * Carries out Functionality Instead */
	if(keycode <= KEY_RELEASE_VALUE){
		/* Condition Key Press */
		if (keycode == ALT)
			alt_press += 1;
		else if(keycode == L_SHIFT || keycode == R_SHIFT)	
			shift_press += 1;
		else if (keycode == CTRL)
			ctrl_press += 1;
		else if (keycode == CAPS_LOCK)
			caps_on = !caps_on;

		/* CTRL-L Clear Screen */
		else if(keycode == L && ctrl_press > 0)
			reset_screen();

		/* Backspace */
		else if (keycode == BACKSPACE){
			/* Don't backspace when reading and at start of buffer*/
			if(read_on[display_terminal] == 0 || (index[display_terminal] != 0 && read_on[display_terminal] == 1))
				backspace();
			update_terminal_buf(BACK,keycode);
		}

		/* Return Press During Read */
		else if (read_on[display_terminal] == 1 && keycode == RETURN){
			printf("\n"); 		// New Line for Return Press
			read_return[display_terminal] = 1;
			update_terminal_buf(KEYS,keycode);
		}
		
		/* ALT-Function Press */
		else if(alt_press > 0 && (keycode == F1 || keycode == F2 || keycode == F3)){
			switch(keycode){
				case F1:
					change_terminal(TERMINAL_1);
					break;
				case F2:
					change_terminal(TERMINAL_2);
					break;
				case F3:
					change_terminal(TERMINAL_3);
				default:
					break;
			}
		}

		/* Caps On */
		else if (caps_on == 1){
			caps_on_handler(keycode);
		}

		/* Shift Press */
		else if (shift_press > 0){
			printf("%c", shift_keys[keycode - 1]);
			update_terminal_buf(SHIFT_KEYS, keycode);
		}

		/* Normal Press */
		else{
			printf("%c", keys[keycode - 1]);
			update_terminal_buf(KEYS, keycode);
		}

	}

	/* Condition Key Releases */
	else if (keycode == (ALT + KEY_RELEASE_VALUE))
		alt_press -= 1;
	else if(keycode == (L_SHIFT + KEY_RELEASE_VALUE) || keycode == (R_SHIFT + KEY_RELEASE_VALUE))
		shift_press -= 1;
	else if (keycode == (CTRL + KEY_RELEASE_VALUE))
		ctrl_press -= 1;

	/* Key Press Serviced */
	key_press = 0;
	send_eoi(KEYBOARD_IRQ);
}