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

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
User avatar
wojtek
Posts: 4
Joined: Sat Mar 15, 2014 4:59 am

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

Post 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 ?
Sorry about my english.
Host OS: Linux Debian
Kernel type: microkernel
Kernel format: now flat binary, in future ELF.
User avatar
sortie
Member
Member
Posts: 931
Joined: Wed Mar 21, 2012 3:01 pm
Libera.chat IRC: sortie

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

Post 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.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

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

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
siavoshkc
Member
Member
Posts: 40
Joined: Wed Feb 19, 2014 11:10 am

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

Post by siavoshkc »

Shouldn't we first set APIC to legacy PIC mode?
Check out my FSB Data Integrity Tester at http://fsbdit.sourceforge.net/.

Siavosh
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

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

Post by Combuster »

No, because of backwards compatibility the APIC can be ignored until you actively start tinkering with it.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
wojtek
Posts: 4
Joined: Sat Mar 15, 2014 4:59 am

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

Post 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.
Sorry about my english.
Host OS: Linux Debian
Kernel type: microkernel
Kernel format: now flat binary, in future ELF.
Post Reply