linux下IRQ和软中断处理函数定义

来源:互联网 发布:java 创建文本文件 编辑:程序博客网 时间:2024/06/05 17:31

0~31是不可屏蔽的中断和异常

32~47是IRQ中断

48~255是软中断

0x80  系统调用的 

 

 

IRQ和软中断的定义如下:

 

在arch/x86_64/i8259.c中

void (*interrupt[NR_IRQS])(void) = {
 IRQLIST_16(0x0),

#ifdef CONFIG_X86_IO_APIC
    IRQLIST_16(0x1), IRQLIST_16(0x2), IRQLIST_16(0x3),
 IRQLIST_16(0x4), IRQLIST_16(0x5), IRQLIST_16(0x6), IRQLIST_16(0x7),
 IRQLIST_16(0x8), IRQLIST_16(0x9), IRQLIST_16(0xa), IRQLIST_16(0xb),
 IRQLIST_16(0xc), IRQLIST_16(0xd)

#ifdef CONFIG_PCI_MSI
 , IRQLIST_14(0xe)
#endif

#endif
};

 

#define IRQ(x,y) \
 IRQ##x##y##_interrupt

#define IRQLIST_16(x) \
 IRQ(x,0), IRQ(x,1), IRQ(x,2), IRQ(x,3), \
 IRQ(x,4), IRQ(x,5), IRQ(x,6), IRQ(x,7), \
 IRQ(x,8), IRQ(x,9), IRQ(x,a), IRQ(x,b), \
 IRQ(x,c), IRQ(x,d), IRQ(x,e), IRQ(x,f)

#define IRQLIST_14(x) \
 IRQ(x,0), IRQ(x,1), IRQ(x,2), IRQ(x,3), \
 IRQ(x,4), IRQ(x,5), IRQ(x,6), IRQ(x,7), \
 IRQ(x,8), IRQ(x,9), IRQ(x,a), IRQ(x,b), \
 IRQ(x,c), IRQ(x,d)

 

在i8259.c中中断初始化如下:

void __init init_IRQ(void)
{
 int i;

 /* all the set up before the call gates are initialised */
 pre_intr_init_hook();

 /*
  * Cover the whole vector space, no vector can escape
  * us. (some of these will be overridden and become
  * 'special' SMP interrupts)
  */
 for (i = 0; i < (NR_VECTORS - FIRST_EXTERNAL_VECTOR); i++) {
  int vector = FIRST_EXTERNAL_VECTOR + i;
  if (i >= NR_IRQS)
   break;
  if (vector != SYSCALL_VECTOR)
   set_intr_gate(vector, interrupt[i]);
 }

 /* setup after call gates are initialised (usually add in
  * the architecture specific gates)
  */
 intr_init_hook();

 /*
  * Set the clock to HZ Hz, we already have a valid
  * vector now:
  */
 setup_pit_timer();

 /*
  * External FPU? Set up irq13 if so, for
  * original braindamaged IBM FERR coupling.
  */
 if (boot_cpu_data.hard_math && !cpu_has_fpu)
  setup_irq(FPU_IRQ, &fpu_irq);

 irq_ctx_init(smp_processor_id());
}