Linux1.0内核中断体系的建立
2015-06-27 18:16
351 查看
head.S中设置了IDT的指针,共256项,都指向ignore_int函数
而在Traps.c文件中,对可能出现的异常进行初始化
至于硬件设备产生的中断,Linux1.0内核专门建立了对应的函数调用表,当产生中断则调用相应的函数。在IRQ.c文件中处理。
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,÷_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; }
相关文章推荐
- Linux 下crontab简单使用
- Linux访问受限,访问Linux总是Forbidden
- Linux中强制结束一个进程的终极方法
- Linux虚拟机与外面系统ping不通,或者连不上网
- Linux cp 命令
- Linux入门篇之五:使用的克隆虚拟机
- Step by Step:Linux C多线程编程入门(基本API及多线程的同步与互斥)
- MacBook 连接Centos服务器
- php的入门第一个例子(包括linux的环境安装与包括页面跳转,以及curl命令的调用)
- CentOS虚拟机设置静态ip
- Linux输入/输出重定向的使用
- CentOS 6.6 yum 搭建LAMP环境
- linux grep命令详解
- linux sed 命令详解
- linux sort,uniq,cut,wc命令详解
- Linux awk命令详解
- LINUX下MYSQL的启动及相关配置
- 更新centos6.5yum源
- SynaptiCAD.AllProducts.v19.00c windows32 64/linux32 64 SOLARIS(电子设计自动化工具集)
- Linux下expect批量更改交换机端口属性