Page 1 of 1

Problem with IRQ, PIC,APIC or I don't know what

Posted: Sat Mar 15, 2014 7:29 am
by wojtek
Hi all!
It's first post in this forum, I'm beginner Os programmers. My English isn't good.
I trying to write my first kernel, and i encountered problem when i try to enable interrupts using sti.
Of course "cli" is first instruction of my kernel.
Then I'm creating GDT & IDT,setting protected mode, reprogram PIC, and "sti".
On Bochs all working fine,emulator hang in never ending loop but on real PC crash and triple fault...

The problem does not occur when:
-without "sti" execute, computer hang in loop
-when i only mask interrupts in PIC, not reprogramming PIC.
Soft generated interrupts ("int $xxx") works good.
Do you have any ideas ?
Maybe I must disable APIC ?

Re: Problem with IRQ, PIC,APIC or I don't know what

Posted: Sat Mar 15, 2014 10:06 am
by sortie
What tutorial did you use for interrupts? I bet your code has a bug, you may wish to post some of your code in a pastebin or link to your online source code repository if you have one.

Re: Problem with IRQ, PIC,APIC or I don't know what

Posted: Sat Mar 15, 2014 10:08 am
by Combuster
Well, since it triple faults, your error handling is broken so you should fix that in the first place.

Start with adding

Code: Select all

mov ax, 0xdead
mov gs, ax
just before where you would normally do STI, and make sure that prints an error message on the screen - on both real hardware and emulators.

Re: Problem with IRQ, PIC,APIC or I don't know what

Posted: Sat Mar 15, 2014 2:49 pm
by siavoshkc
Shouldn't we first set APIC to legacy PIC mode?

Re: Problem with IRQ, PIC,APIC or I don't know what

Posted: Sun Mar 16, 2014 2:39 am
by Combuster
No, because of backwards compatibility the APIC can be ignored until you actively start tinkering with it.

Re: Problem with IRQ, PIC,APIC or I don't know what

Posted: Sun Apr 06, 2014 7:56 am
by wojtek
I solved my probelm by filling all IDT table vector to empty interrupt void before "sti".
Now I have another problem with debugging.