LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   disabling the keyboard interrupt handler (http://www.linuxquestions.org/questions/linux-general-1/disabling-the-keyboard-interrupt-handler-761272/)

TheIndependentAquarius 10-12-2009 01:26 AM

disabling the keyboard interrupt handler
 
friends,

How to find which key has been pressed while writing a keyboard interrupt handler ?

thanks !

TheIndependentAquarius 11-27-2009 12:52 AM

I marked this thread as solved long back but didn't post the solution code. So here it is:

Code:

#include <linux/kernel.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 ("\nYou pressed Esc !");
        }

        return (irq_handler_t) IRQ_HANDLED;
}

/*
 Initialize the module − register the IRQ handler
*/
int init_module ()
{
        /*
        Request IRQ 1, the keyboard IRQ, to go to our irq_handler SA_SHIRQ means we're willing to have othe handlers on this IRQ. SA_INTERRUPT can be used to make the handler into a fast interrupt.
        */
        return request_irq (1, (irq_handler_t) irq_handler, SA_SHIRQ, "test_keyboard_irq_handler", (void *)(irq_handler));
}

MODULE_LICENSE ("GPL");



All times are GMT -5. The time now is 07:38 AM.