interrupt service routine crashes on iret
I am working on an interrupt service routine for a 32 bit protected mode kernel I was writing (with the help from GPL codes from the net; from GazOS). I am working on the IDT and enabling of irq 1 to test out the keyboard handler. The ISR looks like this :=
.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
However, when I reach iret, the processor crashes/hangs. My IDT is setup this way :=
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);
The problem is it either hangs when I reach the iret instruction (if I keep the printk routine inside the keyboard_handler) or it crashes the CPU emulator (I am running on Virtual Box) if there is no printk statement inside the handler. I know we are not supposed to have printk inside a handler, so something is wrong. Thanks
I was able to see this error message in Bochs :=
00076701521p[CPU0 ] >>PANIC<< prefetch: getHostMemAddr vetoed direct read, pAddr=0x00000000000a0000
00076701521i[CPU0 ] CPU is in protected mode (active)
00076701521i[CPU0 ] CS.d_b = 32 bit
00076701521i[CPU0 ] SS.d_b = 32 bit
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 selector base limit GD
00076701521i[CPU0 ] | SEG sltr(index|ti|rpl) base limit 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: (instruction unavailable) page split instruction
00076701521i[CMOS ] Last time is 1367097632 (Sat Apr 27 17:20:32 2013)
00076701521i[XGUI ] Exit
00076701521i[ ] restoring default signal behavior
========================================================================
Bochs is exiting with the following message:
[CPU0 ] prefetch: getHostMemAddr vetoed direct read, pAddr=0x00000000000a0000
========================================================================
链接地址: http://www.djcxy.com/p/85908.html上一篇: itoa实施崩溃?
下一篇: 中断服务程序在iret上崩溃