Page 1 of 1

[SOLVED - UPDATED] APIC: can I just don't care?

Posted: Tue Apr 29, 2014 9:33 am
by etamponi
Hi forum members,

this is my very first post, and I hope not to look silly with this (probably) very trivial question, but I looked around on the internet and in the forums for some hours and I haven't found an answer.

UPDATE: I wrote the kernel as in the Bran's Kernel Development Tutorial without disabling the APIC and it worked without problems. This means that the Local APIC adds features but can be used without changing any code if ignored.

I am trying to write my own long mode os, just for fun, and I am trying to understand the exact role of the Local APIC and of the I/O APIC.

I know that in recent intel processor there is a Local APIC that can be used to do fancy things with interrupts like waking a sleeping thread and communicating between cpus. What I cannot understand is:
  • is it enabled when booting up (I think the answer to this one is yes)? If so, can I write code in the same way as not having any APIC?
  • if it is enabled when booting up but I have to know about it, do you know any tutorial or guide on how to get the same functionality of a 8259A PIC? (at least for now, until I have my OS booting up and handling IRQ properly)
  • is the I/O APIC enabled at boot? I think that the answer to this question is no, so that a standard 8259A PIC communicates with the Local APIC through one of the interrupt pins of the cpu.
As far as I understand, the Local APIC can be seen as a layer between the cpu and the interrupt pins (plus other things), so that as far I am not interested in the advanced functionality of the Local APIC, I can just ignore its existence. But in this case, what I do not understand is why in the Intel manual (Chapter 10, Part 3) it says: "Note that the local APIC can be disabled (see Section 10.4.3, “Enabling or Disabling the Local APIC”). This allows an associated processor core to receive interrupts directly from an 8259A interrupt controller.".

Thank you in advance,

Emanuele T.

Re: APIC: if I don't want to use it, can I just don't care?

Posted: Tue Apr 29, 2014 9:46 am
by TylerH
I may be underestimating the complexity of what you're asking, but try the first 2 sentences here: http://wiki.osdev.org/APIC#Local_APIC_configuration.

Re: APIC: if I don't want to use it, can I just don't care?

Posted: Tue Apr 29, 2014 9:54 am
by etamponi
TylerH wrote:I may be underestimating the complexity of what you're asking, but try the first 2 sentences here: http://wiki.osdev.org/APIC#Local_APIC_configuration.
Thank you for your answer, but I really still don't understand the point. Once you "enabled" the Local APIC, what does actually changes in the standard ISR+IRQs pairing found in almost every tutorial out there about writing a basic kernel?

Re: APIC: if I don't want to use it, can I just don't care?

Posted: Tue Apr 29, 2014 10:26 am
by TylerH
To answer your first question directly, yes it's enabled at boot. To answer the second, just disable it, then you get interrupts directly from an 8259A. This would mean everything you read in tutorials about the old PIC will work and you can ignore the LAPIC until you're ready to use the extra features it provides.

Re: APIC: if I don't want to use it, can I just don't care?

Posted: Tue Apr 29, 2014 10:30 am
by etamponi
TylerH wrote:To answer your first question directly, yes it's enabled at boot. To answer the second, just disable it, then you get interrupts directly from an 8259A. This would mean everything you read in tutorials about the old PIC will work and you can ignore the LAPIC until you're ready to use the extra features it provides.
Thank you very much! I hope to find out some resources on how to use it later :) If you have any link please let me know :)

Emanuele

Re: APIC: if I don't want to use it, can I just don't care?

Posted: Tue Apr 29, 2014 1:56 pm
by etamponi
TylerH wrote:To answer your first question directly, yes it's enabled at boot. To answer the second, just disable it, then you get interrupts directly from an 8259A. This would mean everything you read in tutorials about the old PIC will work and you can ignore the LAPIC until you're ready to use the extra features it provides.
Actually, everything works without flaws even if I don't disable the Local APIC. Probably it is set as "legacy mode" until we start changing its settings somehow.

Emanuele

Re: [SOLVED - UPDATED] APIC: can I just don't care?

Posted: Sat May 03, 2014 9:36 am
by SpyderTL
Yes, you can ignore the APIC until you need to support multiple processors.