Linux1.0内核中断体系的建立

head.S中设置了IDT的指针,共256项,都指向ignore_int函数

ignore_int:
    cld
    pushl %eax
    pushl %ecx
    pushl %edx
    push %ds
    push %es
    push %fs
    movl $(KERNEL_DS),%eax
    mov %ax,%ds
    mov %ax,%es
    mov %ax,%fs
    pushl $int_msg
    call _printk
    popl %eax
    pop %fs
    pop %es
    pop %ds
    popl %edx
    popl %ecx
    popl %eax
    iret

而在Traps.c文件中,对可能出现的异常进行初始化

void trap_init(void)
{
    int i;

    set_trap_gate(0,&divide_error);
    set_trap_gate(1,&debug);
    set_trap_gate(2,&nmi);
    set_system_gate(3,&int3);   /* int3-5 can be called from all */
    set_system_gate(4,&overflow);
    set_system_gate(5,&bounds);
    set_trap_gate(6,&invalid_op);
    set_trap_gate(7,&device_not_available);
    set_trap_gate(8,&double_fault);
    set_trap_gate(9,&coprocessor_segment_overrun);
    set_trap_gate(10,&invalid_TSS);
    set_trap_gate(11,&segment_not_present);
    set_trap_gate(12,&stack_segment);
    set_trap_gate(13,&general_protection);
    set_trap_gate(14,&page_fault);
    set_trap_gate(15,&reserved);
    set_trap_gate(16,&coprocessor_error);
    set_trap_gate(17,&alignment_check);
    for (i=18;i<48;i++)
        set_trap_gate(i,&reserved);
}

至于硬件设备产生的中断,Linux1.0内核专门建立了对应的函数调用表,当产生中断则调用相应的函数。在IRQ.c文件中处理。

void init_IRQ(void)
{
    int i;

    //初始化16个中断执行函数,初始化16个中断处理
    for (i = 0; i < 16 ; i++)
        set_intr_gate(0x20+i,bad_interrupt[i]);

    //挂接2号,2号为连接从芯片,不执行任何事
    if (irqaction(2,&ignore_IRQ))
        printk("Unable to get IRQ2 for cascade\n");

    //挂接irq与math操作,数学协处理器中断
    if (request_irq(13,math_error_irq))
        printk("Unable to get IRQ13 for math-error handler\n");

    /* intialize the bottom half routines. */
    for (i = 0; i < 32; i++) {
        bh_base[i].routine = NULL;
        bh_base[i].data = NULL;
    }
    bh_active = 0;
    intr_count = 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值