中断服务程序在iret上崩溃
我正在写一个32位保护模式内核的中断服务程序(在GnetOS的GPL代码的帮助下)。 我正在研究IDT并启用irq 1来测试键盘处理程序。 ISR看起来像这样:=
.globl keyb_ISR
keyb_ISR:
pusha
pushw %ds
pushw %es
pushw %ss
pushw %ss
popw %ds
popw %es
call keyboard_handler
popw %es
popw %ds
popa
iret
但是,当我到达iret时,处理器崩溃/挂起。 我的IDT是这样设置的:=
desc_table(IDT, 256)
{
};
struct
{
unsigned short limit __attribute__ ((packed));
union DT_entry *idt __attribute__ ((packed));
} __IDT__ = { (256 * sizeof(union DT_entry) - 1), IDT };
void set_vector(void *handler, unsigned char interrupt,
unsigned short control_major,unsigned int selector)
{
IDT[interrupt].gate.offset_low = (unsigned short) (((unsigned long)handler)&0xffff);
IDT[interrupt].gate.selector = selector;
IDT[interrupt].gate.access = control_major;
IDT[interrupt].gate.offset_high = (unsigned short) (((unsigned long)handler) >> 16);
}
Where the vector is set this way :=
set_vector(keyb_ISR, M_VEC+1, D_PRESENT + D_INT + D_DPL3, KERNEL_CS);
问题是,当我到达iret指令时(如果我将printk例程保存在keyboard_handler中),或者如果处理程序中没有printk语句,它会使CPU模拟器(我在Virtual Box上运行)崩溃。 我知道我们不应该在处理程序中有printk,所以有些地方是错误的。 谢谢
我能够在Bochs中看到这个错误消息:=
00076701521p [CPU0] >> PANIC << prefetch:getHostMemAddr否决直接读取,pAddr = 0x00000000000a0000
00076701521i [CPU0] CPU处于保护模式(有效)
00076701521i [CPU0] CS.d_b = 32位
00076701521i [CPU0] SS.d_b = 32位
00076701521i [CPU0] | EAX = ffff111b EBX = 46ed0000 ECX = de000000 EDX = ff2f0011
00076701521i [CPU0] | ESP = 0000ff35 EBP = 00460000 ESI = 00104790 EDI = 6b00ffff
00076701521i [CPU0] | IOPL = 0 id vip vif ac vm rf nt of df if tf SF zf AF PF cf
00076701521i [CPU0] | SEG选择器基数限制GD
00076701521i [CPU0] | SEG sltr(index | ti | rpl)基数限制GD
00076701521i [CPU0] | CS:0010(0002 | 0 | 0)00000000 ffffffff 1 1
00076701521i [CPU0] | DS:0018(0003 | 0 | 0)00000000 ffffffff 1 1
00076701521i [CPU0] | SS:0018(0003 | 0 | 0)00000000 ffffffff 1 1
00076701521i [CPU0] | ES:0018(0003 | 0 | 0)00000000 ffffffff 1 1
00076701521i [CPU0] | FS:002b(0005 | 0 | 3)00000000 ffffffff 1 1
00076701521i [CPU0] | GS:0018(0003 | 0 | 0)00000000 ffffffff 1 1
00076701521i [CPU0] | EIP = 000a0000(0009ffff)
00076701521i [CPU0] | CR0 = 0x60000011 CR2 = 0x00000000
00076701521i [CPU0] | CR3 = 0x00000000 CR4 = 0x00000000
00076701521i [CPU0] 0x0009ffff:(指令不可用)页面拆分指令
00076701521i [CMOS]上一次是1367097632(2013年4月27日17:20:32)
00076701521i [XGUI]退出
00076701521i []恢复默认信号行为
================================================== ======================
Bochs正在退出,并发出以下消息:
[CPU0]预取:getHostMemAddr否决直接读取,pAddr = 0x00000000000a0000
================================================== ======================
链接地址: http://www.djcxy.com/p/85907.html上一篇: interrupt service routine crashes on iret
下一篇: JVM crash in 6.0