APIC Programming Question

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
ChewieRFC
Posts: 5
Joined: Thu Jul 02, 2009 8:51 pm
Location: California, USA
Contact:

APIC Programming Question

Post 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?
TylerH
Member
Member
Posts: 285
Joined: Tue Apr 13, 2010 8:00 pm
Contact:

Re: APIC Programming Question

Post 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.
User avatar
ChewieRFC
Posts: 5
Joined: Thu Jul 02, 2009 8:51 pm
Location: California, USA
Contact:

Re: APIC Programming Question

Post by ChewieRFC »

I did, thank you. Unfortunately, this article is not very helpful.
Hangin10
Member
Member
Posts: 162
Joined: Wed Feb 27, 2008 12:40 am

Re: APIC Programming Question

Post by Hangin10 »

The IOAPIC isn't just for multiprocessor systems.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: APIC Programming Question

Post 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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
ChewieRFC
Posts: 5
Joined: Thu Jul 02, 2009 8:51 pm
Location: California, USA
Contact:

Re: APIC Programming Question

Post 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.
royalbru
Posts: 10
Joined: Tue Jul 08, 2008 12:44 pm

Re: APIC Programming Question

Post by royalbru »

There is a chapter about APIC in Intel Doc : Chapter 9 of volume 3A (http://www.intel.com/products/processor/manuals/)
Post Reply