Writing down the main keyboard interrupt handler, throws out the "Unknown key",

I wrote a rudimentary keyboard interrupt handler. It uses common interrupts and is used to print in / var / log / messages, keystrokes. But I get the following error when I try to use the arrow keys and the rest of the keys work fine.

August 19 18:59:06 vim kernel: [112.485102] atkbd serio0: Unknown key released (translated set 2, code 0xe0 on isa0060 / serio0). Aug 19 18:59:06 vim kernel: [112.485108] atkbd serio0: Use "setkeycodes e060" to make it known.

Code insertion.

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/interrupt.h>
#include <asm/io.h>

/* This function services keyboard interrupts */
irq_handler_t irq_handler (int irq, void *dev_id, struct pt_regs *regs) {
  static unsigned char scancode;

  /*
    Read keyboard status
  */
  scancode = inb (0x60);

  if ((scancode == 0x01) || (scancode == 0x81))
    {
      printk ("You pressed Esc !\n");
    }
  }

  return (irq_handler_t) IRQ_HANDLED;
}

/* Initialize the module and Register the IRQ handler */
static int __init keybrd_int_register(void)
{
  int result;
  /* Request IRQ 1, the keyboard IRQ */    
  result = request_irq (1, (irq_handler_t) irq_handler, IRQF_SHARED, "keyboard_stats_irq", (void *)(irq_handler));

  if (result)
    printk(KERN_INFO "can't get shared interrupt for keyboard\n");

  return result;
}

/* Remove the interrupt handler */
static void __exit keybrd_int_unregister(void) {
  free_irq(1, (void *)(irq_handler)); /* i can't pass NULL, this is a shared interrupt handler! */
}

MODULE_LICENSE ("GPL");
module_init(keybrd_int_register);
module_exit(keybrd_int_unregister);

Can someone explain to me why this arrow stops working, when I insert my module and start working with serum, I delete them?

.

+5

All Articles