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.
[solved]tripfault on x86 hardware after restoring interrupts
[solved]tripfault on x86 hardware after restoring interrupts
Last edited by eino on Sun Sep 18, 2011 4:01 am, edited 1 time in total.
I'm Eino Tuominen from Finland, a web software dev learning low level stuff and reading / trying out kernel dev
Re: trip fault on x86 hardware after restoring interrupts
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:
Once you've done that you can go on with writing meaningful interrupt handlers and programming the PIT
I'd suggest a plan something like this:
- Setup empty interrupts for the first 32 system interrupts
Install IDT
Test with INT instructions
- 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
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 =)
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 =)
I'm Eino Tuominen from Finland, a web software dev learning low level stuff and reading / trying out kernel dev