Page 1 of 1

APIC Programming Question

Posted: Sat Apr 17, 2010 5:41 pm
by ChewieRFC
I have looked around the Wiki, searched the forums, and Google'd furiously and I can't find an answer to this question. I understand that the newer processors (Pentium on up) are situated with an APIC, vice the standard PIC setup. What I can't find is how to setup and program the APIC for IRQs, like you do with the PIC. The PIC is very straight forward, but nothing I've found shows anything on the APIC, other than APIC I/O, which looks like a SMP type thing, not a uni-core setup. So, my question is, how do you program the APIC for IRQs in a uni-processor system?

Re: APIC Programming Question

Posted: Sat Apr 17, 2010 6:19 pm
by TylerH
I have no idea about anything referring to the PIC or related topics, but when you mentioned the wiki, it made me wonder if you'd seen this article, I think it may be on the topic you're asking about.

Re: APIC Programming Question

Posted: Sat Apr 17, 2010 6:36 pm
by ChewieRFC
I did, thank you. Unfortunately, this article is not very helpful.

Re: APIC Programming Question

Posted: Sat Apr 17, 2010 7:24 pm
by Hangin10
The IOAPIC isn't just for multiprocessor systems.

Re: APIC Programming Question

Posted: Sun Apr 18, 2010 12:38 am
by Brendan
Hi,
Hangin10 wrote:The IOAPIC isn't just for multiprocessor systems.
Correct. Most computers with local APICs and I/O APICs have ACPI and/or MP specification tables too (so you can find out which IRQs are connected to which I/O APIC inputs, etc).

There's actually 4 cases:
  • Single-CPU with no APICs - mostly old computers (e.g. Pentium III or later)
  • Single-CPU with local APIC but no I/O APIC - not as common, but does happen in older computers (especially older servers)
  • Single-CPU with both local APICs and I/O APIC - common for Pentium 4 and later systems
  • Multi-CPU with both local APICs and I/O APIC - all multi-CPU systems since 80486
The "no APICs" case is slightly tricky. All Intel Pentium or later CPUs do have a local APIC built in; but (for backward compatibility) the firmware disables the local APIC during boot and it can't be enabled again (without a reboot/reset, where the firmware just disables it again). On some CPUs it is possible to enable the local APIC after the firmware has disabled it, so if you know enough about the chipset, PCI devices and the CPU you may be able to safely enable the local APIC (where "safely" means that you make sure the area of the physical address space that would be used by the local APIC isn't being used for a PCI device or something else).

For the "local APIC but no I/O APIC" case you still need to use the PICs, but you can use the local APIC timer and the other interrupts built into the local APIC (e.g. termal status interrupt, performance monitoring interrupt). This can make a huge difference for timing (the extra precision of the local APIC timer; plus the ability to know when the TSC frequency changes due to thermal throttling).


Cheers,

Brendan

Re: APIC Programming Question

Posted: Sun Apr 18, 2010 11:37 am
by ChewieRFC
Ahh, ok. Thank you for the clarification. The part that still confuses me is the setup. Do you need to setup the APIC and IOAPIC like you do the 8259A PIC? I also have "The Indispensable PC Hardware Book", which gives a great discussion on the 8259A, but not much on APIC or IOAPIC.

Re: APIC Programming Question

Posted: Wed Apr 21, 2010 12:28 pm
by royalbru
There is a chapter about APIC in Intel Doc : Chapter 9 of volume 3A (http://www.intel.com/products/processor/manuals/)