Finding the interrupt vector of a given IRQ

11 messages, 6 authors, 2012-10-20 · open the first message on its own page

Finding the interrupt vector of a given IRQ

From: Mark Farnell <hidden>
Date: 2012-05-27 00:02:51

In the kernel, how can I find out the interrupt vector number of a
given IRQ (for example, IRQ7)?

Within the kernel module, I would like to manually set the IRQ using
the assembly code:

asm("int $<irq vector>");

and let the IRQ handler installed by a different module catch that interrupt.

Is this possible?

Thanks!

Mark

Finding the interrupt vector of a given IRQ

From: richard -rw- weinberger <hidden>
Date: 2012-05-27 21:27:04

On Sun, May 27, 2012 at 2:02 AM, Mark Farnell [off-list ref] wrote:
In the kernel, how can I find out the interrupt vector number of a
given IRQ (for example, IRQ7)?

Within the kernel module, I would like to manually set the IRQ using
the assembly code:

asm("int $<irq vector>");

and let the IRQ handler installed by a different module catch that interrupt.

Is this possible?
No really because not all IRQ have an interrupt line to the CPU.
Linux can multiplex and emulate them. Think of GPIO drivers with
interrupt support.
Anyway, why to you think you need to trigger the raw IRQ manually?
This sounds really odd...


-- 
Thanks,
//richard

Finding the interrupt vector of a given IRQ

From: Mark Farnell <hidden>
Date: 2012-05-27 22:09:17

This is for an assignment, where the student needs to write an
interrupt handler.

Since the OS is run on a virtual machine,  I need to find a way to
trigger the IRQ to let the students' interrupt handler to handle the
interrupt.





On Mon, May 28, 2012 at 9:27 AM, richard -rw- weinberger
[off-list ref] wrote:
On Sun, May 27, 2012 at 2:02 AM, Mark Farnell [off-list ref] wrote:
quoted
In the kernel, how can I find out the interrupt vector number of a
given IRQ (for example, IRQ7)?

Within the kernel module, I would like to manually set the IRQ using
the assembly code:

asm("int $<irq vector>");

and let the IRQ handler installed by a different module catch that interrupt.

Is this possible?
No really because not all IRQ have an interrupt line to the CPU.
Linux can multiplex and emulate them. Think of GPIO drivers with
interrupt support.
Anyway, why to you think you need to trigger the raw IRQ manually?
This sounds really odd...


--
Thanks,
//richard

Finding the interrupt vector of a given IRQ

From: Chauhan, Himanshu <hidden>
Date: 2012-05-28 01:07:23

AKAIK I think is possible. For example int 3 in x86 is actually an
interrupt so to say. I don't want to go in other details about exception vs
interrupts and stack saving. But in short you can achieve what you are
trying here.

Search for breakpoint handler probably in entry.S and from the trace back
to IDT initialization. Replace the vector 3 with your handlers address. Now
you can do int 3 from elsewhere in inline assembly.

On May 28, 2012 3:40 AM, "Mark Farnell" [off-list ref] wrote:
This is for an assignment, where the student needs to write an
interrupt handler.

Since the OS is run on a virtual machine,  I need to find a way to
trigger the IRQ to let the students' interrupt handler to handle the
interrupt.





On Mon, May 28, 2012 at 9:27 AM, richard -rw- weinberger
[off-list ref] wrote:
quoted
On Sun, May 27, 2012 at 2:02 AM, Mark Farnell [off-list ref]
wrote:
quoted
quoted
In the kernel, how can I find out the interrupt vector number of a
given IRQ (for example, IRQ7)?

Within the kernel module, I would like to manually set the IRQ using
the assembly code:

asm("int $<irq vector>");

and let the IRQ handler installed by a different module catch that
interrupt.
quoted
quoted
Is this possible?
No really because not all IRQ have an interrupt line to the CPU.
Linux can multiplex and emulate them. Think of GPIO drivers with
interrupt support.
Anyway, why to you think you need to trigger the raw IRQ manually?
This sounds really odd...


--
Thanks,
//richard
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20120528/735f59b7/attachment.html 

Finding the interrupt vector of a given IRQ

From: anish singh <hidden>
Date: 2012-05-28 03:46:21

On Mon, May 28, 2012 at 2:57 AM, richard -rw- weinberger
[off-list ref] wrote:
On Sun, May 27, 2012 at 2:02 AM, Mark Farnell [off-list ref] wrote:
quoted
In the kernel, how can I find out the interrupt vector number of a
given IRQ (for example, IRQ7)?

Within the kernel module, I would like to manually set the IRQ using
the assembly code:

asm("int $<irq vector>");

and let the IRQ handler installed by a different module catch that interrupt.

Is this possible?
No really because not all IRQ have an interrupt line to the CPU.
Linux can multiplex and emulate them. Think of GPIO drivers with
interrupt support.
Can you please describe this in detail?It would really help a lot of
people like me.Does multiplex mean that all numbers starting from
0,1,2,3,...... TOTAL-interrupt will have interrupt lines associated with it
eventhough all interrupt numbers are not linear?
Anyway, why to you think you need to trigger the raw IRQ manually?
This sounds really odd...


--
Thanks,
//richard

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

Finding the interrupt vector of a given IRQ

From: richard -rw- weinberger <hidden>
Date: 2012-05-28 09:53:58

On Mon, May 28, 2012 at 12:09 AM, Mark Farnell [off-list ref] wrote:
This is for an assignment, where the student needs to write an
interrupt handler.

Since the OS is run on a virtual machine, ?I need to find a way to
trigger the IRQ to let the students' interrupt handler to handle the
interrupt.
What a stupid assignment!
Assignments like this make only sense if you have real hardware...

Anyway, create a timer (e.g struct timer_list) which calls your ISR.
That's how people test their ISRs.

-- 
Thanks,
//richard

Finding the interrupt vector of a given IRQ

From: Mulyadi Santosa <hidden>
Date: 2012-05-29 05:14:39

Hi..

On Mon, May 28, 2012 at 5:09 AM, Mark Farnell [off-list ref] wrote:
This is for an assignment, where the student needs to write an
interrupt handler.

Since the OS is run on a virtual machine, ?I need to find a way to
trigger the IRQ to let the students' interrupt handler to handle the
interrupt.

If you use Qemu, better consult Qemu folks in qemu-devel.

Anyway, just for example, timer interrupt in Qemu is actually coming
from user space timer trigger (setitimer maybe.... lately it could be
coming from HPET too). So, perhaps what you need to do is add another
Qemu monitor commands that manually triggers this timer function.

Pay attention for the reentrancy issues though.

Hope it helps...

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

Finding the interrupt vector of a given IRQ

From: Mark Farnell <hidden>
Date: 2012-05-30 00:11:40

Finally got it working.......

First, at the kernel source, you need to go to:

arch/x86/include/asm/irq_vectors.h

to find out which interrupt vector your IRQ is mapped to (replace x86
with your architechure, but for this purpose, amd64 also falls into
x86).


Then within the kernel space (i.e. in a kernel module function such as
ioctl()), make an assembly call:

asm("int $<interrupt vector>");

to set the interrupt.  In this case, IRQ7 is mapped to 55 for
x86/amd64 architecture.

Cheers,

Mark





On Mon, May 28, 2012 at 3:46 PM, anish singh
[off-list ref] wrote:
On Mon, May 28, 2012 at 2:57 AM, richard -rw- weinberger
[off-list ref] wrote:
quoted
On Sun, May 27, 2012 at 2:02 AM, Mark Farnell [off-list ref] wrote:
quoted
In the kernel, how can I find out the interrupt vector number of a
given IRQ (for example, IRQ7)?

Within the kernel module, I would like to manually set the IRQ using
the assembly code:

asm("int $<irq vector>");

and let the IRQ handler installed by a different module catch that interrupt.

Is this possible?
No really because not all IRQ have an interrupt line to the CPU.
Linux can multiplex and emulate them. Think of GPIO drivers with
interrupt support.
Can you please describe this in detail?It would really help a lot of
people like me.Does multiplex mean that all numbers starting from
0,1,2,3,...... TOTAL-interrupt will have interrupt lines associated with it
eventhough all interrupt numbers are not linear?
quoted
Anyway, why to you think you need to trigger the raw IRQ manually?
This sounds really odd...


--
Thanks,
//richard

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

Finding the interrupt vector of a given IRQ

From: Arun KS <hidden>
Date: 2012-10-19 05:04:45

Hi Anish,

On Mon, May 28, 2012 at 9:16 AM, anish singh [off-list ref]wrote:
On Mon, May 28, 2012 at 2:57 AM, richard -rw- weinberger
[off-list ref] wrote:
quoted
On Sun, May 27, 2012 at 2:02 AM, Mark Farnell [off-list ref]
wrote:
quoted
quoted
In the kernel, how can I find out the interrupt vector number of a
given IRQ (for example, IRQ7)?

Within the kernel module, I would like to manually set the IRQ using
the assembly code:

asm("int $<irq vector>");

and let the IRQ handler installed by a different module catch that
interrupt.
quoted
quoted
Is this possible?
No really because not all IRQ have an interrupt line to the CPU.
Linux can multiplex and emulate them. Think of GPIO drivers with
interrupt support.
Can you please describe this in detail?It would really help a lot of
people like me.Does multiplex mean that all numbers starting from
0,1,2,3,...... TOTAL-interrupt will have interrupt lines associated with it
eventhough all interrupt numbers are not linear?
GPIOs are grouped as banks. Let?s say 32 gpios are in a bank.
There will be only single interrupt line to interrupt controller for a bank.


Consider that you have configured gpio1 and gpio16 as interrupts.
Even if interrupt happens on gpio 1 or gpio 16, the same interrupt line
will be triggered to

Interrupt controller.


Now the gpio driver has to figure out reading the Interrupt status

Register of GPIO to find which interrupt (gpio1 or gpio16) has really fired.

So in this case a single interrupt line is multiplex for 32 gpio interrupts.

HTH.

Thanks,
Arun

quoted
Anyway, why to you think you need to trigger the raw IRQ manually?
This sounds really odd...


--
Thanks,
//richard

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20121019/f9379164/attachment.html 

Finding the interrupt vector of a given IRQ

From: anish kumar <hidden>
Date: 2012-10-20 04:08:55

On Fri, 2012-10-19 at 10:34 +0530, Arun KS wrote:
Hi Anish,

On Mon, May 28, 2012 at 9:16 AM, anish singh
[off-list ref] wrote:
        On Mon, May 28, 2012 at 2:57 AM, richard -rw- weinberger
        [off-list ref] wrote:
        > On Sun, May 27, 2012 at 2:02 AM, Mark Farnell
        [off-list ref] wrote:
        >> In the kernel, how can I find out the interrupt vector
        number of a
        >> given IRQ (for example, IRQ7)?
        >>
        >> Within the kernel module, I would like to manually set the
        IRQ using
        >> the assembly code:
        >>
        >> asm("int $<irq vector>");
        >>
        >> and let the IRQ handler installed by a different module
        catch that interrupt.
        >>
        >> Is this possible?
        >
        > No really because not all IRQ have an interrupt line to the
        CPU.
        > Linux can multiplex and emulate them. Think of GPIO drivers
        with
        > interrupt support.
        
        Can you please describe this in detail?It would really help a
        lot of
        people like me.Does multiplex mean that all numbers starting
        from
        0,1,2,3,...... TOTAL-interrupt will have interrupt lines
        associated with it
        eventhough all interrupt numbers are not linear?

GPIOs are grouped as banks. Let?s say 32 gpios are in a bank.
There will be only single interrupt line to interrupt controller for a
bank.


Consider that you have configured gpio1 and gpio16 as interrupts.
Even if interrupt happens on gpio 1 or gpio 16, the same interrupt
line will be triggered to 
  
Interrupt controller.


Now the gpio driver has to figure out reading the Interrupt status 

Register of GPIO to find which interrupt (gpio1 or gpio16) has really
fired.
And this is done by this way:
Suppose we have a chip(mfd-multi-funcion-driver) driver which is
connected to processor using a gpio - this gpio line acts as interrupt
line from the processor

++++++++++++              ++++++++++
+ Processor+              + Chip   +---->USB  interrupt handler
+          +gpio--------->+ MFD    +---->dock interrupt handler
++++++++++++              +        +---->UART interrupt handler
			  ++++++++++---->Factory cable interrupt handler

So the code will be as follows:

handler_function()
{	
	/* find out which interrupt is triggered */
	/* it can be usb,dock,uart or factory cable */
	ret_irq = read_mfd_register();
	/*
        * ok we found out the interrupt line, get a corresponding
	* software linux irq number by calling
        * irq_domain_add_linear 
        * irq_create_mapping 
        * you would have made this calls in the probe probably
	*/ 
 	handle_nested_irq(ret_irq); 
}

handle_nested_irq inturn will call all the irq_handlers in the system
for your UART,usb and dock driver.

mfd_driver()
{	
	request_irq(gpio_to_irq(gpio), handler_function);
}

Hope I have not missed anything.
So in this case a single interrupt line is multiplex for 32 gpio
interrupts.


HTH.

Thanks,
Arun
 
        > Anyway, why to you think you need to trigger the raw IRQ
        manually?
        > This sounds really odd...
        >
        >
        > --
        > Thanks,
        > //richard
        >
        > _______________________________________________
        > Kernelnewbies mailing list
        > Kernelnewbies at kernelnewbies.org
        >
        http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
        
        _______________________________________________
        Kernelnewbies mailing list
        Kernelnewbies at kernelnewbies.org
        http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
        

Finding the interrupt vector of a given IRQ

From: Arun KS <hidden>
Date: 2012-10-20 06:56:23

Hi Anish,

On Sat, Oct 20, 2012 at 9:38 AM, anish kumar [off-list ref]wrote:
On Fri, 2012-10-19 at 10:34 +0530, Arun KS wrote:
quoted
Hi Anish,

On Mon, May 28, 2012 at 9:16 AM, anish singh
[off-list ref] wrote:
        On Mon, May 28, 2012 at 2:57 AM, richard -rw- weinberger
        [off-list ref] wrote:
        > On Sun, May 27, 2012 at 2:02 AM, Mark Farnell
        [off-list ref] wrote:
        >> In the kernel, how can I find out the interrupt vector
        number of a
        >> given IRQ (for example, IRQ7)?
        >>
        >> Within the kernel module, I would like to manually set the
        IRQ using
        >> the assembly code:
        >>
        >> asm("int $<irq vector>");
        >>
        >> and let the IRQ handler installed by a different module
        catch that interrupt.
        >>
        >> Is this possible?
        >
        > No really because not all IRQ have an interrupt line to the
        CPU.
        > Linux can multiplex and emulate them. Think of GPIO drivers
        with
        > interrupt support.

        Can you please describe this in detail?It would really help a
        lot of
        people like me.Does multiplex mean that all numbers starting
        from
        0,1,2,3,...... TOTAL-interrupt will have interrupt lines
        associated with it
        eventhough all interrupt numbers are not linear?

GPIOs are grouped as banks. Let?s say 32 gpios are in a bank.
There will be only single interrupt line to interrupt controller for a
bank.


Consider that you have configured gpio1 and gpio16 as interrupts.
Even if interrupt happens on gpio 1 or gpio 16, the same interrupt
line will be triggered to

Interrupt controller.


Now the gpio driver has to figure out reading the Interrupt status

Register of GPIO to find which interrupt (gpio1 or gpio16) has really
fired.
And this is done by this way:
Suppose we have a chip(mfd-multi-funcion-driver) driver which is
connected to processor using a gpio - this gpio line acts as interrupt
line from the processor
Interrupt lines are to the interrupt controllor(IC) and only two interrupts
lines fom IC(irq and fiq in case of ARM) goes to processor.
++++++++++++              ++++++++++
+ Processor+              + Chip   +---->USB  interrupt handler
+          +gpio--------->+ MFD    +---->dock interrupt handler
++++++++++++              +        +---->UART interrupt handler
                          ++++++++++---->Factory cable interrupt handler

So the code will be as follows:

handler_function()
{
        /* find out which interrupt is triggered */
        /* it can be usb,dock,uart or factory cable */
        ret_irq = read_mfd_register();
        /*
        * ok we found out the interrupt line, get a corresponding
        * software linux irq number by calling
        * irq_domain_add_linear
        * irq_create_mapping
        * you would have made this calls in the probe probably
        */
        handle_nested_irq(ret_irq);
}

handle_nested_irq inturn will call all the irq_handlers in the system
for your UART,usb and dock driver.

mfd_driver()
{
        request_irq(gpio_to_irq(gpio), handler_function);
}

Yes. This is another example of interrupt multipexing...
Here you have two levels of multiplexing. One for the mfd devices functions
and other for gpio.

Thanks,
Arun
Hope I have not missed anything.
quoted
So in this case a single interrupt line is multiplex for 32 gpio
interrupts.


HTH.

Thanks,
Arun

        > Anyway, why to you think you need to trigger the raw IRQ
        manually?
        > This sounds really odd...
        >
        >
        > --
        > Thanks,
        > //richard
        >
        > _______________________________________________
        > Kernelnewbies mailing list
        > Kernelnewbies at kernelnewbies.org
        >
        http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

        _______________________________________________
        Kernelnewbies mailing list
        Kernelnewbies at kernelnewbies.org
        http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20121020/d7d34f5f/attachment.html 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help