OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 9:58 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: [SOLVED] PIT in combination with IO APIC
PostPosted: Wed Feb 01, 2017 4:31 am 
Offline
Member
Member

Joined: Fri May 16, 2014 2:40 pm
Posts: 36
I'm currently trying to get the PIT timer to work. My problem however is that I am not receiving any interrupts generated by the timer.
I'm using the I/O APIC to map the IRQs. I know that the I/O APIC code is working properly, because other irqs get mapped correctly. The RTC timer interrupts just fine and keyboard interrupts work too.

What I'm currently doing is the following:
-Map an interrupthandler to interrupt 34 (Which is not yet used)
-Map IRQ 0 to interrupt 34 with the I/O APIC
-Enable channel 0 of the pittimer with a divider value of 11931 to get roughly 100 hz.

The code I'm using to enable the PIT timer:
Code:
uint16_t divisor = 11931;
outb(0x43, 0x36);
outb(0x40, divisor & 0xff);
outb(0x40, (divisor >> 8) & 0xff);


I have the feeling that I'm missing something trivial since the interrupt handling works, and initializing the PIT itself shouldn't be too hard.

Anyone any hints on what might be going wrong here?


Last edited by robbiedobbie on Thu Feb 02, 2017 6:53 am, edited 3 times in total.

Top
 Profile  
 
 Post subject: Re: PIT in combination with IO APIC
PostPosted: Wed Feb 01, 2017 6:13 am 
Offline
Member
Member

Joined: Fri May 16, 2014 2:40 pm
Posts: 36
I actually solved it. Apparantly PIT timer interrupts are IRQ2 on the I/O APIC instead of IRQ0. I found this information in the wiki at the HPET topic, section "Legacy Replacement Mapping".

Maybe this should be added to the PIT timer page as well?


Top
 Profile  
 
 Post subject: Re: [Solved] PIT in combination with IO APIC
PostPosted: Wed Feb 01, 2017 10:31 am 
Offline
Member
Member
User avatar

Joined: Sat Nov 22, 2014 6:33 pm
Posts: 934
Location: USA
The IRQ override from IRQ0 to IRQ2 is in the ACPI's MADT block.

If you are going to use the IOAPIC, you need to parse the ACPI and the MADT to get these overrides as well as get the base address of the IOAPIC.

i.e.: You should not assume 0xFEC00000.


Top
 Profile  
 
 Post subject: Re: [Solved] PIT in combination with IO APIC
PostPosted: Wed Feb 01, 2017 11:31 am 
Offline
Member
Member

Joined: Fri May 16, 2014 2:40 pm
Posts: 36
D'oh. I'm already getting the IOAPIC address from the MADT table. I completely forgot about the ISO entries in the table.

I was so naive to assume that since the HPET mentioned IRQ2 on IOAPIC, that this was always the case. Thank you for the help!


Top
 Profile  
 
 Post subject: Re: PIT in combination with IO APIC
PostPosted: Wed Feb 01, 2017 2:03 pm 
Offline
Member
Member

Joined: Fri May 16, 2014 2:40 pm
Posts: 36
Actually, I tried implement the interrupt source override, however qemu doesn't have such entries, eventhough irq0 is rerouted to irq2. Is this a known bug in qemu?


Top
 Profile  
 
 Post subject: Re: PIT in combination with IO APIC
PostPosted: Wed Feb 01, 2017 4:37 pm 
Offline
Member
Member
User avatar

Joined: Sat Nov 22, 2014 6:33 pm
Posts: 934
Location: USA
QEMU does emulate the overrides, at least the version I am using.

https://qemu.weilnetz.de/

Ben
http://www.fysnet.net/the_universal_serial_bus.htm


Top
 Profile  
 
 Post subject: Re: PIT in combination with IO APIC
PostPosted: Thu Feb 02, 2017 6:53 am 
Offline
Member
Member

Joined: Fri May 16, 2014 2:40 pm
Posts: 36
I'm stupid. Turns out that qemu indeed does have the entries. I forgot to remove a break in my loop going over all the table entries. As soon as it found the first IO APIC it stopped searching.

Thank you for all the help!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 57 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group