Page 1 of 1

[solved]tripfault on x86 hardware after restoring interrupts

Posted: Fri Sep 16, 2011 10:09 am
by eino
Hi. I'm writing a sort of hobby os with C and the mandatory assembly. I've been reading the Intel I-32 manual, lots of asm books etc and my goal is basically to gain more understanding on how things work.

Anyways I've been using Bran's tutorial as a reference and I'm now facing a strange problem. I'm loading my IDT successfully (thou I have no entries in it and no ISRs yet) but after restoring interrupts with: __asm__ __volatile__ ("sti"); my kernel tripfaults on real hardware. On qemu it seems to work ok.

After loading the IDT I'm able to print out messages on to the screen so I know it crashes on that line.

Does this behaviour sound familiar to anyone? Do I need to implement the IDT entries and ISRs to get it to work? This question is something I can't seem to find info anywhere si I'm asking here to get this clear before I start work on those.

Re: trip fault on x86 hardware after restoring interrupts

Posted: Fri Sep 16, 2011 3:52 pm
by mark3094
You will need some sort of interrupt handler, even if it's just an empty one. You will also need an End of Interrupt routine to tell the PIC that the hardware interrupt is done.
I'd suggest a plan something like this:
  • Setup empty interrupts for the first 32 system interrupts
    Install IDT
    Test with INT instructions
When that works, add to it:
  • Add empty interrupts for hardware
    Remap the PIC's IRQs to the new interrupts
    Install updated IDT
    Enable interrupts with STI
    Test

Once you've done that you can go on with writing meaningful interrupt handlers and programming the PIT

Re: trip fault on x86 hardware after restoring interrupts

Posted: Sun Sep 18, 2011 4:00 am
by eino
Hi. Just as I thought it would be. I didn't want to start writing the ISR's & IRQ's before I knew the facts above because I wanted to make sure that the code so far was not buggy.

Anyways I added the ISR's and IRQ's and am sending the 20h to PIC's correctly. The thing didn't work but after a while I noticed I had a bug on my function that sets an IDT entry.

Works now! Thank you so much and see you again cause this will most likely not be the last question =)