bochs PIC and APIC
bochs PIC and APIC
Hi,
In my kernel timer interrupts are generated by initializing 8259 PIC and PIT. But now I want to use APIC for generating timer interrupts.
So I recomplied bochs to cpu-level 6 to enable APIC. But now it seems that when I initialize the 8259 PIC, timer interrupts get generated automatically . This happens even when both PIT and APIC timer are disabled. However if I do not initialize the 8259,the code throws a double fault.
I don't understand why is timer interrupt generated just by initializing the PIC.
-Thanks
Vaibhav Jain
In my kernel timer interrupts are generated by initializing 8259 PIC and PIT. But now I want to use APIC for generating timer interrupts.
So I recomplied bochs to cpu-level 6 to enable APIC. But now it seems that when I initialize the 8259 PIC, timer interrupts get generated automatically . This happens even when both PIT and APIC timer are disabled. However if I do not initialize the 8259,the code throws a double fault.
I don't understand why is timer interrupt generated just by initializing the PIC.
-Thanks
Vaibhav Jain
Re: bochs PIC and APIC
AFAIK, timer interrupts are generated at ~17 times per second on boot.
Re: bochs PIC and APIC
So does that mean that we do not need to initialize any timer for timer interrupts ?AFAIK, timer interrupts are generated at ~17 times per second on boot.
Also why does enabling PIC cause a timer interrupt ? Or is it the interrupt by the APIC timer ?
Thanks
Vaibhav Jain
Last edited by vjain20 on Wed Jun 20, 2012 11:50 pm, edited 1 time in total.
- Combuster
- 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: bochs PIC and APIC
Not all BIOSes do it that way.
Re: bochs PIC and APIC
I checked on qemu also. If I do not initialize the PIC I get a double fault. I am unable to
figure out why. I have all the 255 interrupt handlers (stubs printing the interrupt number) installed but none of them gets called.
Here add esp, 0x0000008c is the line just before ret and just after sti. The whole function runs fine but at this point it throws a double fault.
However if I enable the PIC (with PIT disabled), I get a timer interrupt - Interrupt 32.
I don't understand why disabling the PIC is causing a double fault and why enabling it is causing a timer interrupt even when PIT is disabled.
- Thanks
Vaibhav Jain
figure out why. I have all the 255 interrupt handlers (stubs printing the interrupt number) installed but none of them gets called.
Code: Select all
Next at t=219627445
(0) [0x00000000001011a9] 0008:c00011a9 (kmain+185): sti ; fb
<bochs:3> s
(0) [0x00000000001011aa] 0008:c00011aa (kmain+186): add esp, 0x0000008c ; 81c48c000000
<bochs:3> s
Next at t=157572693
(0) [0x0000000000102ce8] 0008:c0002ce8 (isr08+1): push 0x00000008 ; 6808000000
However if I enable the PIC (with PIT disabled), I get a timer interrupt - Interrupt 32.
Code: Select all
(0) [0x00000000001011af] 0008:c00011af (kmain+18b): add esp, 0x0000008c ; 81c48c000000
<bochs:3> s
Next at t=158411476
(0) [0x0000000000102e45] 0008:c0002e45 (isr32+1): push 0x00000000 ; 6800000000
- Thanks
Vaibhav Jain
- Combuster
- 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: bochs PIC and APIC
Because you can't technically disable the PIT.
Re: bochs PIC and APIC
What I meant by disabling PIT is that I am not initializing the PIT channel and counter.Because you can't technically disable the PIT
Does the PIT continue to generate interrupt even if it has not been initialized?
If that is the case how can I use only the local APIC to generate timer interrupts ? I want to do away with the PIT.
-Thanks
Vaibhav Jain
- Combuster
- 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: bochs PIC and APIC
Re: bochs PIC and APIC
ok I read some more and found that PIT is initialized by BIOS (from the PIT wiki)
On reading the 8259_PIC wiki I found that for working with local APIC the PIC needs to be disabled. I did that but found that the code was still throwing double fault but not every time. From this post -
http://forum.osdev.org/viewtopic.php?f=15&t=23096 I got to know that even if all the interrupts are masked the PIC can still send spurious interrupts.
So I first configured the PIC to remap the IRQs and then masked all the interrupts.This stopped the double fault.You'd mask all IRQs in the PIC so they can't occur, and use the I/O APICs instead. However, it is still technically possible for the PIC chips to generate spurious IRQs (which can't be masked or prevented in the PIC); so just in case you'd still need to remap the PICs even though you aren't using them, and have spurious IRQ handlers for the PICs.
Now for configuring the APIC timer I am using the code from the APIC timer and APIC wiki.
But the problem is that APIC timer is not working. I read the code and tried to understand it. I don't see any problem with the code.
The interrupt handler is not getting called . To verify if interrupt is being generated I am reading the current count register in a loop
but the count doesn't seem to change. I don't know what should I do.
(Please excuse me for my lack of effort shown by copying the code for APIC Timer)
-Thanks
Vaibhav Jain