了解IRQ的用法

时间:2014-09-12 17:14:52

标签: linux kernel interrupt

在过去的几天里,我试图在C中实现一个简单的中断处理程序。到目前为止,我认为我已经完成了我的初始任务。我的最终目标是通过位翻转一些CPU寄存器来在内核中注入一些错误。在阅读thisthisthis后,我选择了IRQ编号10,因为它似乎是一个免费的“开放中断”。我的疑问是:我怎么知道这是否是调用我的中断处理程序的“最佳”IRQ?我怎么可能决定这个?

谢谢,一切顺利, 若昂

P.S。:据我所知,有16条IRQ线,但Linux有256条IDT条目,如/include/asm/irq_vectors.h中所述(请参见下文)。这似乎也令我感到困惑。

/*
 * Linux IRQ vector layout.
 *
 * There are 256 IDT entries (per CPU - each entry is 8 bytes) which can
 * be defined by Linux. They are used as a jump table by the CPU when a
 * given vector is triggered - by a CPU-external, CPU-internal or
 * software-triggered event.
 *
 * Linux sets the kernel code address each entry jumps to early during
 * bootup, and never changes them. This is the general layout of the
 * IDT entries:
 *
 *  Vectors   0 ...  31 : system traps and exceptions - hardcoded events
 *  Vectors  32 ... 127 : device interrupts
 *  Vector  128         : legacy int80 syscall interface
 *  Vectors 129 ... 237 : device interrupts
 *  Vectors 238 ... 255 : special interrupts
 *
 * 64-bit x86 has per CPU IDT tables, 32-bit has one shared IDT table.
 *
 * This file enumerates the exact layout of them:
 */

0 个答案:

没有答案