APIC Timer leads to lots of prerequisites?
Posted: Sun Aug 05, 2012 9:17 pm
Hi,
I have worked on some basic concepts for my OS and have been reasonably successful but I took a step back to make sure I was taking a more holistic approach. I am having some trouble getting my APIC timer working and thought I better reach out for help. As I continue to research, I find myself falling into a bottomless pit.
Since I want my OS to be able to use multi-cores and/or multi-processors, I understand that I need to make use of the APIC. The APIC will be necessary for coordinating between the processors. In implementing use of the APIC, the 8259 PIC must be disabled. In disabling the 8259, I am forced to use the APIC timer. I did query CPUID to make sure I have an APIC available before I start and went through the exercise to calibrate the APIC timer.
When I enable interrupts, I am getting an immediate Interrupt 0 (no division by 0, though, and I have put in the proper checks to prevent it), followed by an Interrupt 8 (double fault) and then repeating Interrupt 13s (GPF). I have some odd anomalies in the SS selector when I dump the registers on Interrupt 0, but I am thinking that it is a symptom rather than the problem. I am expecting an Interrupt 32 (for my APIC timer), but I do not get any triggers on Interrupt 32.
What is noteworthy is that in debugging, I am seeing that the Interrupt 0 is actually in response to a IRQ. As hinted above, I have set my APIC timer interrupt vector to 32 in periodic mode. I have tried to send the APIC an EOI before enabling interrupts, but that had no effect.
With all that said, my research points me to the need to setup the IOAPIC before I enable interrupts (details are a still little hazy on having to do this for the APIC timer...). In order to begin setting up the IOAPIC, I need to parse the MADT from ACPI in order to get some basic information required. In order to find the information for the ACPI, I need to get the address from memory (which I assume [for now] I take the starting address for the block reported), following the multiboot specification and what is reported by INT15. I cannot query INT15 myself as I am already in protected mode and I'm not really interested or prepared to switch back to real mode.
I cannot help the feeling that I have fallen down a rabbit hole I didn't intend and I am missing something far more fundamental. I can easily fall back to the 8259 PIC, but that will not deliver the ultimate multi-processor functionality I am looking for.
I have read everything I can find on APIC timer not working. At the point I setup the APIC timer, I have setup a GDT, IDT, the Heap is created and Paging is enabled (with 0xfee00000 identity mapped).
Thanks in advance for any assistance and/or advice you are willing to provide. If you would like to see code, please let me know.
Thank you!
I have worked on some basic concepts for my OS and have been reasonably successful but I took a step back to make sure I was taking a more holistic approach. I am having some trouble getting my APIC timer working and thought I better reach out for help. As I continue to research, I find myself falling into a bottomless pit.
Since I want my OS to be able to use multi-cores and/or multi-processors, I understand that I need to make use of the APIC. The APIC will be necessary for coordinating between the processors. In implementing use of the APIC, the 8259 PIC must be disabled. In disabling the 8259, I am forced to use the APIC timer. I did query CPUID to make sure I have an APIC available before I start and went through the exercise to calibrate the APIC timer.
When I enable interrupts, I am getting an immediate Interrupt 0 (no division by 0, though, and I have put in the proper checks to prevent it), followed by an Interrupt 8 (double fault) and then repeating Interrupt 13s (GPF). I have some odd anomalies in the SS selector when I dump the registers on Interrupt 0, but I am thinking that it is a symptom rather than the problem. I am expecting an Interrupt 32 (for my APIC timer), but I do not get any triggers on Interrupt 32.
What is noteworthy is that in debugging, I am seeing that the Interrupt 0 is actually in response to a IRQ. As hinted above, I have set my APIC timer interrupt vector to 32 in periodic mode. I have tried to send the APIC an EOI before enabling interrupts, but that had no effect.
With all that said, my research points me to the need to setup the IOAPIC before I enable interrupts (details are a still little hazy on having to do this for the APIC timer...). In order to begin setting up the IOAPIC, I need to parse the MADT from ACPI in order to get some basic information required. In order to find the information for the ACPI, I need to get the address from memory (which I assume [for now] I take the starting address for the block reported), following the multiboot specification and what is reported by INT15. I cannot query INT15 myself as I am already in protected mode and I'm not really interested or prepared to switch back to real mode.
I cannot help the feeling that I have fallen down a rabbit hole I didn't intend and I am missing something far more fundamental. I can easily fall back to the 8259 PIC, but that will not deliver the ultimate multi-processor functionality I am looking for.
I have read everything I can find on APIC timer not working. At the point I setup the APIC timer, I have setup a GDT, IDT, the Heap is created and Paging is enabled (with 0xfee00000 identity mapped).
Thanks in advance for any assistance and/or advice you are willing to provide. If you would like to see code, please let me know.
Thank you!