2 IRQ中断的处理过程

2009-05-13 08:07:58来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折


代码:
/*
* Macros for interrupt interrupt entry, call to handler, and exit.
*/
#define INTR(irq_num, vec_name) \
  .text ; \
  SUPERALIGN_TEXT ; \
IDTVEC(vec_name) ; \
  pushl $0 ; /* dummy error code */ \
  pushl $0 ; /* dummy trap type */ \
  pushal ; /* 8 ints */ \
  pushl %ds ; /* save data and extra segments ... */ \
  pushl %es ; \
  pushl %fs ; \
  mov $KDSEL,%ax ; /* load kernel ds, es and fs */ \
  mov %ax,%ds ; \
  mov %ax,%es ; \
  mov $KPSEL,%ax ; \
  mov %ax,%fs ; \
; \
  FAKE_MCOUNT(13*4(%esp)) ; /* XXX late to avoid double count */ \
  pushl $irq_num; /* pass the IRQ */ \
  call atpic_handle_intr ; \
  addl $4, %esp ; /* discard the parameter */ \
; \
  MEXITCOUNT ; \
  jmp doreti
IRQ产生时,系统根据产生中断的IRQ号找到相应的中断向量入口,即此处的IDT_VEC(vec_name), 再这里,构造好函数atpic_handle_intr()的调用栈后,将转到atpic_handle_intr()进行处理。 同系统调用一样,这里的调用栈struct intrframe既是atpic_handle_intr()的参数,也是中断返回时用以恢复现场的寄存器状态。
代码:
/* Interrupt stack frame */
struct intrframe {
  int if_vec;
  int if_fs;
  int if_es;
  int if_ds;
  int if_edi;
  int if_esi;
  int if_ebp;
  int :32;
  int if_ebx;
  int if_edx;
  int if_ecx;
  int if_eax;
  int :32; /* for compat with trap frame - trapno */
  int :32; /* for compat with trap frame - err */
  /* below portion defined in 386 hardware */
  int if_eip;
  int if_cs;
  int if_eflags;
  /* below only when crossing rings (e.g. user to kernel) */
  int if_esp;
  int if_ss;
};
void
atpic_handle_intr(struct intrframe iframe)
{
  struct intsrc *isrc;
  KASSERT((uint)iframe.if_vec  ICU_LEN,
    ("unknown int %d\n", iframe.if_vec));
  isrc = &atintrs[iframe.if_vec].at_intsrc;
  /*
  * If we don't have an ithread, see if this is a spurious
  * interrupt.
  */
  if (isrc->is_ithread == NULL &&
    (iframe.if_vec == 7 || iframe.if_vec == 15)) {
    int port, isr;
    /*
    * Read the ISR register to see if IRQ 7/15 is really
    * pending. Reset read register back to IRR when done.
    */

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:1.2 8259A的登记过程

下一篇:3 软件中断swi