中断服务程序在iret上崩溃

时间:2013-04-24 01:09:01

标签: assembly kernel interrupt

我正在为我正在编写的32位保护模式内核开发一个中断服务程序(来自网络的GPL代码的帮助;来自GazOS)。我正在研究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 例如,如果处理程序中没有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选择器基极限G D

00076701521i [CPU0] | SEG sltr(指数| ti | rpl)基本限制G D

00076701521i [CPU0] | CS:0010(0002 | 0 | 0)00000000 ffffffff 1 1

00076701521i [CPU0] | DS:0018(0003 | 0 | 0)00000000 fffffff 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 fffffff 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(Sat Apr 27 17:20:32 2013)

00076701521i [XGUI]退出

00076701521i []恢复默认信号行为

=============================================== =========================

Bochs退出时发出以下消息:

[CPU0] prefetch:getHostMemAddr否决直接读取,pAddr = 0x00000000000a0000

=============================================== =========================

0 个答案:

没有答案