Hi,
ARISTOS wrote:It is the time to communicate with the hardware. I am reading ACPI specification but I cannot clearly understand what this thing is (is a part of BIOS code-data right?) , what is doing (ok I read the tables, then?) and If there doesn't exist, how to replace them?
ACPI can be described as 2 parts; where the first part is tables that an OS parses to get various pieces of information that can't change while the computer is running, and the second part is a pile of code that an OS can use to get information that can change while the computer is running and handle various events. The code for the second part is stored as byte-code (called AML or ACPI Machine Language) and you need an "AML interpreter" to execute/interpret that code.
Some devices (IO APIC, HPET, etc; plus legacy devices like PIT, RTC) are assumed to be built into the chipset where they can't be changed while the computer is running; so they're described by tables (e.g. ACPI's "APIC/MADT" table describes how many IO APICs there are, how legacy IRQs are connected to those IO APICs, etc).
ACPI has always supported hot-plug PCI; so it assumes that (for some computers) PCI devices may be changed while the computer is running. For this reason PCI devices (and how PCI IRQs are connected to the IO APIC) can't be described by static tables and are described by AML code instead. This means you need an "AML interpreter" to execute/interpret the code to figure out how PCI IRQs are connected to IO APIC inputs.
ARISTOS wrote:At the end I need to set up LAPIC's, IOAPIC and PIC's to handle the hardware Interrupts?
Early during boot you mostly want to mask everything in the PIC and IO APIC; and initialise tables to keep track of what is using each (PIC or IOAPIC) input and what is using each interrupt vector/IDT entry. When you're starting a device driver for a specific device, you install its IRQ handler/s (if any) and then use the information you've obtained to enable/configure that device's IRQ in the PIC or IO APIC. When you're terminating or uninstalling a device driver you do the opposite (mask the device's IRQ in the PIC or IO APIC, then uninstall its IRQ handler/s).
As part of this you'll eventually want some kind of "interrupt vector manager" to allocate and free interrupt vectors/IDT entries. This is important for MSI ("Message Signalled Interrupts") which is a feature of PCI, where the device can send a message to the CPU saying that it wants to interrupt that bypasses the PIC and IO APIC (e.g. doesn't use any IO APIC input). For this the device's PCI configuration space might say it wants 16 IRQs, so you'd use your "interrupt vector manager" to allocate 16 (consecutive) interrupt vectors and then set up the device to use the 16 interrupt vectors that you allocated. Note that ACPI's AML isn't involved for MSI IRQs, which makes it quite attractive if you don't have an AML interpreter yet.
ARISTOS wrote:As I was reading MP specification (is that something more than a manual?)
The MP specification is an old standard that existed before ACPI; that was superseded by ACPI. In general you should search for ACPI tables and use ACPI if it exists, but if there are no ACPI tables (because the computer is too old) then you'd search for MP specification tables and use those instead. If you don't support old computers (e.g. 15 years old, or older) then there's no need to support MP specification's tables.
ARISTOS wrote:I saw that maybe PIT (IRQ0) and DMA (IRQ13) isn't connected to IOAPIC, only to PIC. At wiki I read that in MADT table (ACPI)
that many defined that some IRQ many are connected different from normal. How can I get a list on runtime with the present IRQ's and where they are connected from both sides (sender, receiver(PIC, IOAPIC or both))?
This is (part of) what all the ACPI (and MP specification) tables, and the AML code is for. To determine how devices IRQs are routed to PIC and IO APIC inputs (and how to configure the IO APIC inputs properly - e.g. as "level triggered" or "edge triggered" and as "active high" or "active low") you need to do a lot of work, including having an AML interpreter. There is no simple list that describes everything.
ARISTOS wrote:If some interrupt isn't set to IOAPIC I need to set up PIC's and handle their interrupts. How to do that?
During boot you decide whether you will use PIC or IO APIC. If you chose to use PIC then you do not use IO APIC for anything at all (and leave it disabled/masked). If you chose to use IO APIC then you do not use PIC chips for anything at all (and leave them disabled/masked).
If you chose to use IO APIC and old PIT chip's IRQ isn't connected to the IO APIC; don't use the old PIT chip (e.g. use the RTC and/or the local APIC timer and/or HPET instead).
ARISTOS wrote:I know that PIC's INTR pin is connected to all LAPIC's and how to handle them but how can I disable the sending the interrupts directly to bootstrap processors INTR pin?
You don't. If you're not using the PIC chips, you mask all IRQs in all PIC chips and leave the PIC's INTR pin alone (and tell ACPI's AML that you're using IO APICs and not PICs so that it can do anything else that's has to be done for that computer).
Cheers,
Brendan