IDT already set,but still restart again and again

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
raywill

IDT already set,but still restart again and again

Post by raywill »

I did setup IDT,using '_common_interupt' as all IDTs' ISR.
But when I enalbe timer or keyboard,my program restart again and again(as to keyboard,when I press a key). :-[

I know there should be something wrong with my IDT setting or something like that.
But really,I can't find where IS the problem.

Have anyone had similar experience?How you solved it?
Or any suggestion? ??? ??? ???

Thanks
Warrior

Re:IDT already set,but still restart again and again

Post by Warrior »

Do you remap the PICs? The OSFaq has a few "troubleshooting" stages you can go through.
raywill

Re:IDT already set,but still restart again and again

Post by raywill »

Nelson wrote: Do you remap the PICs? The OSFaq has a few "troubleshooting" stages you can go through.
Mapped already.
User avatar
Kevin McGuire
Member
Member
Posts: 843
Joined: Tue Nov 09, 2004 12:00 am
Location: United States
Contact:

Re:IDT already set,but still restart again and again

Post by Kevin McGuire »

Make sure you're lidt instruction is correctly loading the address and length of your IDT table by using bochsdbg.exe, place a HLT and two NOP instructions right before the LIDT, start bochs and type C to continue. Wait a little bit and press ctrl+c, then use S and step though the code until after the lidt. Then type dump_cpu, and check the LIDT value in the list.

If the LIDT is correctly pointed to your table, then try moving the IDT table to memory location 0x0 and see if that helps. If not then try telling the PIC to mask all interrupts, and make sure you remap them if not masking them.

Try using:
struct idt{
unsigned short address_low;
unsigned short selector;
unsigned short flags;
unsigned short address_high;
};
void intAdd(unsigned char index, unsigned int offset, unsigned short selector, unsigned char dpl){
   intEntry[index].address_low = (unsigned short)offset;
   intEntry[index].address_high = (unsigned short)(offset >> 16);
   intEntry[index].flags = 0x8E00 | (dpl << 13);
   intEntry[index].selector = selector;
   return;
}

If that still does not work, try masking all IRQs, then add a exception handler for divide by zero exception at index 0x0. Run bochs step past the LIDT instruction, use the LIDT offset from dump_cpu, and type xp <LIDT OFFSET> to display the 32 bit value at that address and ensure it contains the address of your handler and the entry is correct. Then add a divide by zero operation after the LIDT and step to it and see if the code jumps to your exception handler. They may be working but it may something wrong with the handler.

If it still triple faults and it never reaches the exception handler(jumps to) then go back over your GDT or, use the GDT you boot with to find some way to make sure the GDT is correct.

Also make sure the GDT and IDT, if you don't place the IDT at 0x0 in memory are both not in areas of memory reserved for BIOS things. Move them around and see if things start working. I'd stick the IDT at 0x0 in bochs at first just to make sure that is not the problem, when it starts working try moving it somewhere else.
User avatar
Kevin McGuire
Member
Member
Posts: 843
Joined: Tue Nov 09, 2004 12:00 am
Location: United States
Contact:

Re:IDT already set,but still restart again and again

Post by Kevin McGuire »

Also, as a last resort although moving the GDT and IDT around has a good chance of fixing it. You may want to make sure you do not have stack problems or any code that is running amock and corrupting memory in places.

The GDT and/or IDT may become corrupt in your system by means of foobar code.
Post Reply