idt was loaded but isr fail when exception occur[solved]
Posted: Mon Nov 26, 2007 5:41 pm
hi, i am new and i meet a strange problem.
i have loaded idt successfully, but when exception occur, cpu can not route interrupt service function.
and this is my init function:
this is bochs output:
this is bochs display:
i have loaded idt successfully, but when exception occur, cpu can not route interrupt service function.
Code: Select all
void pic_install(){
// ICW1
OUTB(0x11, 0x20);
OUTB(0x11, 0xA0);
// ICW2
OUTB(0x20, 0x21);
OUTB(0x28, 0xA1);
// ICW3
OUTB(0x04, 0x21);
OUTB(0x02, 0xA1);
// ICW4
OUTB(0x01, 0x21);
OUTB(0x01, 0xA1);
OUTB(0xFF, 0x21); // IRQ0-IRQ7
OUTB(0xFF, 0xA1); // IRQ8-IRQ15
}
void fill_idt(int idx, int offset, int dpl, int type, short sel) {
_IDT idt_entry = {
(sel << 16) | (offset & 0xffff),
(offset & 0xffff0000) | 0x8000 | (dpl << 13) | (type << 8 )
};
g_idt[idx] = idt_entry;
}
void idt_install(){
/*install defined exception */
int i = 0;
for ( ; i < 256; ++i){
fill_idt(i, (int)test, 0, INTR_GATE_TYPE, CODE_SEL); //just a test
}
CLI();
_IDT_descr idt_descr = {IDT_SIZE, (int)g_idt}, t;
idt_descr.len = IDT_SIZE;
idt_descr.addr = (int)g_idt;
asm __volatile__ ("lidt %0\n\t"::"m"(idt_descr));
asm __volatile__ ("sidt %0\n\t"::"m"(t));
video_display_format("dump idt, len:%X, addr:%X\n", t.len, t.addr);
asm __volatile__ ("lidt %0\n\t"::"m"(idt_descr));
}
void test(){
video_display_str("just a test:\n");
HALT();
}
Code: Select all
void k_init(){
video_display_str("[!]install idt\n");
idt_install();
video_display_str("[!]install pic\n");
pic_install();
video_display_str("[!]enable interrupt\n");
STI();
}
Code: Select all
....
00133138297i[FDD ] read() on floppy image returns 0
00133161789e[KBD ] unsupported io write to keyboard port 64, value = bf
00133220750e[CPU ] interrupt(): not code segment
00133220750e[CPU ] interrupt(): not code segment
00133220750i[CPU ] protected mode
00133220750i[CPU ] CS.d_b = 32 bit
00133220750i[CPU ] SS.d_b = 32 bit
00133220750i[CPU ] | EAX=00000004 EBX=00009000 ECX=0009ff3d EDX=00000000
00133220750i[CPU ] | ESP=0009ffd0 EBP=0009fff8 ESI=00019200 EDI=00009200
00133220750i[CPU ] | IOPL=0 id vip vif ac vm RF nt of df IF tf sf ZF af PF cf
00133220750i[CPU ] | SEG selector base limit G D
00133220750i[CPU ] | SEG sltr(index|ti|rpl) base limit G D
00133220750i[CPU ] | CS:0008( 0001| 0| 0) 00000000 000fffff 1 1
00133220750i[CPU ] | DS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00133220750i[CPU ] | SS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00133220750i[CPU ] | ES:0010( 0002| 0| 0) 00000000 000fffff 1 1
00133220750i[CPU ] | FS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00133220750i[CPU ] | GS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00133220750i[CPU ] | EIP=0000011a (0000011a)
00133220750i[CPU ] | CR0=0x00000011 CR1=0 CR2=0x00000000
00133220750i[CPU ] | CR3=0x00000000 CR4=0x00000000
00133220750i[CPU ] >> idiv eax, dword ptr ss:[ebp+0xfffffffc] : F77DFC
00133220750e[CPU ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting
00133220750i[SYS ] bx_pc_system_c::Reset(SOFTWARE) called
00133220750e[CPU ] CPU_LOOP bx_guard.interrupt_requested=1
Next at t=133220750
(0) [0x0000011a] 0008:011a (unk. ctxt): idiv eax, dword ptr ss:[ebp+0xfffffffc] ; f77dfc
Code: Select all
[!]install idt
dump idt, len:0x800, addr:0x10A0
[!]instal pic
[!]install interrupt