LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 10-12-2009, 12:26 AM   #1
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,622
Blog Entries: 29

Rep: Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896
disabling the keyboard interrupt handler


friends,

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

thanks !

Last edited by TheIndependentAquarius; 10-12-2009 at 06:48 AM. Reason: question modified
 
Old 11-26-2009, 11:52 PM   #2
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,622
Blog Entries: 29

Original Poster
Rep: Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896
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");
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
control is not going to interrupt handler when interrupt remyasj LinuxQuestions.org Member Intro 1 11-12-2009 12:56 AM
Keyboard interrupt handler and more john_crichton Programming 5 07-16-2009 10:30 AM
control is not going to interrupt handler when interrupt comes in serial driver sateeshalla Linux - Kernel 1 05-04-2006 09:43 AM
printk in the interrupt handler lordofring Programming 3 08-23-2005 08:00 PM
<0>Kernel panic: Aiee, killing interrupt handler! In interrupt handler - not syncing mrb Linux - Newbie 2 01-09-2005 09:47 AM


All times are GMT -5. The time now is 01:08 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration