History log of /haiku/src/system/kernel/arch/x86/ioapic.cpp
Revision Date Author Comments
# b140858b 31-Mar-2024 PulkoMandy <pulkomandy@pulkomandy.tk>

ioapic: more useful logging

Back when this log was introduced, it could not be tested because no
hardware hitting that limit was known. Now there is some.

Add the actual number of IOAPIC redirection entries to the log, so we
can know how many redirection entries we need, and also add a missing
newline.

Change-Id: I00fa0c21628fc336c364cd975dd48801add75302
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7579
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# e223e8e9 29-May-2023 Augustin Cavalier <waddlesplash@gmail.com>

kernel/x86: Initialize IO-APIC only after PCI enumeration is complete.

Before the PCI refactor, PCI initialization/enumeration occurred
immediately after the PCI module was loaded, and so by the time
we got to IOAPIC initialization, it was already complete.

After the refactor, PCI enumeration is deferred until slightly later,
and so we would try to initialize IO-APICs without knowing PCI
information. This would fail, as read_irq_routing_table needs to
have that available.

Hopefully fixes #18425, #18393, #18398.

Change-Id: I1e4b06367da26eeb10085a1c6322ed39885b632b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6476
Reviewed-by: X512 <danger_mail@list.ru>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# fe2bcea7 10-Apr-2022 milek7 <me@milek7.pl>

Move irq_routing_table from x86 to generic.

There is nothing really x86-specific there, other platforms use
ACPI interrupt routing for PCI too.

Change-Id: Ib02e2917902a161c3d79a1049bcd16ba40bb7814
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5277
Reviewed-by: David Karoly <karolyd577@gmail.com>
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>


# 36aafa56 04-Dec-2020 X512 <danger_mail@list.ru>

fix build after CObjectDeleter interface change

Change-Id: I76e217abcd13c22c4d68170e07333cdde4d7a891
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3461
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


# 3108c9be 12-Mar-2016 Michael Lotz <mmlr@mlotz.ch>

ioapic: Fix 64 bit build with tracing enabled, some cleanup.

* Use print format macros to fix the 64 bit build.
* Correct a typo in the shift of the trigger mode definition. As the
value is 0 either way, this does not make a functional difference.
* Use macros instead of values in comparisons.


# 66395144 19-Dec-2013 Pawel Dziepak <pdziepak@quarnos.org>

x86[_64]: Support assigning MSI IRQs to arbitrary CPU


# d897a478 17-Nov-2013 Pawel Dziepak <pdziepak@quarnos.org>

kernel: Allow reassigning IRQs to logical processors


# 6a164daa 17-Nov-2013 Pawel Dziepak <pdziepak@quarnos.org>

kernel: Track load produced by interrupt handlers


# 2bd8cdc1 24-Oct-2013 Jérôme Duval <jerome.duval@gmail.com>

acpi: switch acpi_object from a struct to a union

* this way the size of acpi_object_type matches the size of ACPI_OBJECT
for 32-bit and 64-bit builds.
* adjust users of the type acpi_object_type.


# fa6327c9 09-Aug-2012 Alex Smith <alex@alex-smith.me.uk>

Compile remaining x86 bits for x86_64.

The IOAPIC and IRQ routing code now gets compiled for x86_64, though
they won't be used yet as there is no ACPI support currently.


# 62d36f98 22-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Removed the addr_t conversion operators from FixedWidthPointer which makes comparison against NULL work properly.


# d8efc6ca 21-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Changes to kernel_args to make it identical for x86 and x86_64.

* Added a FixedWidthPointer template class which uses 64-bit storage to hold
a pointer. This is used in place of raw pointers in kernel_args.
* Added __attribute__((packed)) to kernel_args and all structures contained
within it. This is necessary due to different alignment behaviour for
32-bit and 64-bit compilation with GCC.
* With these changes, kernel_args will now come out the same size for both
the x86_64 kernel and the loader, excluding the preloaded_image structure
which has not yet been changed.
* Tested both an x86 GCC2 and GCC4 build, no problems caused by these changes.


# c59b279b 19-Jan-2012 Jérôme Duval <jerome.duval@gmail.com>

Added workarounds and options for gcc 4.6.2

* add -Wno-unused-but-set-variable for gcc 4.6.x with a TODO
* fix warnings about wrong size of pointer cast in ioapic.cpp and AudioBuffer.cpp


# fc2d7cb0 12-Oct-2011 Michael Lotz <mmlr@mlotz.ch>

* Introduce {reserve|allocate|free}_io_interrupt_vectors() that can generically
be used to mark certain io interrupt vectors as reserved and to allocate from
the still free ones. It is a kernel private API for now though.
* Make the MSI code use that functionality instead of implementing its own which
slims it down considerably and also removes quite a bit of hardcoded knowledge
about the interrupt layout that didn't really belong there.
* Mark the various in-use interrupts as reserved from the components that
actually know about them (PIC, IO-APIC, SMP, APIC timer and interrupt setup).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42832 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cb4e75d3 21-May-2011 Michael Lotz <mmlr@mlotz.ch>

* When configuring a link device failed, fall back and keep the currently
active config and update the info for the remaining shared link device
entries. Seen on KVM for the (PCI) ACPI interrupt, but happens where there is
no _SRS method for a device (as this one is optional). I find that a bit
strange however as in such a case no _PRS (possible resources) should be
present either, especially not one advertising a config different from the
current one.
* Print the routing table later, after enabling irq routing, so that possible
changes due to such a fallback are included.
* Fix a typo.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41652 a95241bf-73f2-0310-859d-f6bbb57e9c96


# aa373c43 16-May-2011 Michael Lotz <mmlr@mlotz.ch>

We have to decouple the enumeration and marking of the NMIs from the actual NMI
pin configuration as the configuration only happens after preparing the
configuration where we already need the NMI mask.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41536 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 74e9ede3 16-May-2011 Michael Lotz <mmlr@mlotz.ch>

Simplify and clean up. Removed most of the shifts and made direct masks out of
the macros. This makes things more readable and also fixes the few remaining
80 char limit violations. No functional change intended.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41533 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bc409b49 16-May-2011 Michael Lotz <mmlr@mlotz.ch>

Fix minor debug output oversight in the last commit.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41532 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9ae3fdcb 16-May-2011 Michael Lotz <mmlr@mlotz.ch>

* Move redirection entry configuration into a separate function and allow to
specify the delivery mode.
* Use that function from ioapic_configure_io_interrupt() and use it when
configuring NMI sources to actually set the entries to NMI.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41531 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 86d59c04 16-May-2011 Michael Lotz <mmlr@mlotz.ch>

Support NMI sources. Any non maskable interrupt (NMI) will be marked as
unavailable for routing so that we don't end up configuring anything on them.
I haven't seen these in actual use though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41530 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 22d72c8e 16-May-2011 Michael Lotz <mmlr@mlotz.ch>

Guard against IO-APICs with too many entries. We only support 64 entries because
we use a 64 bit level triggered mask. In practice these don't exist as far as I
know. If we encounter them at a later stage we need to revisit the mask.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41529 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fb5a1727 15-May-2011 Michael Lotz <mmlr@mlotz.ch>

* Implement interrupt source overrides. We install a relay interrupt handler
at the override entry to trigger the overriden vector so that we don't need
to configure any additional redirections.
* Also configures the polarity and trigger modes found in the override entry.
* When disabling the legacy PIC, retrieve the enabled interrupts and re-enable
then in the IO-APIC. This will for example make the ACPI SCI work that is
installed prior to switching interrupt models. Through the transparent support
for interrupt source overrides it'll also automatically relay from the old to
the new vector.

This should make ACPI interrupts work and should support relocating the ISA PIT
from irq 0 to a different global system interrupt (usually 2) so that it can
still work when IO-APICs are in use.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41528 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9c1714ec 16-May-2011 Michael Lotz <mmlr@mlotz.ch>

Enable IO-APICs by default. It's been tested on a broad spectrum of hardware and
all reports so far have been positive. We fall back to legacy mode in the cases
where we can't figure out the correct routing.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41527 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8908aef9 13-May-2011 Michael Lotz <mmlr@mlotz.ch>

* Don't map the IO-APIC within the bootloader. We don't need it to set up SMP
at all and, since there can be multiple IO-APICs, we need to do the
enumeration again in the kernel anyway. Also only set ioapic_phys the first
time we encounter an IO-APIC object as it looks cleaner when we arrive at the
first IO-APIC default address.
* Therefore we don't have to worry about already mapped IO-APICs when
enumerating them in the kernel.
* Also remove the mapping function that is now not used anymore.
* We still use the ioapic_phys field of the kernel args to determine whether
there is an IO-APIC at all to avoid needlessly doing the enumeration again.

This fixes multi IO-APIC configurations, because before we would indeed map
the last IO-APIC listed in the MADT, but then in the kernel assumed we mapped
the first one. We'd end up with mapping the last listed IO-APIC twice and the
first IO-APIC never, always programming the last one when we actually targetted
the first one.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41476 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0798779a 11-May-2011 Michael Lotz <mmlr@mlotz.ch>

Resolve TODO: Take the writing order into account. Ensure the mask bit is
written first/last depending on the operation to avoid modifying entries that
are still unmasked or unmasking entries that aren't set up yet.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41457 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f91cbdde 11-May-2011 Michael Lotz <mmlr@mlotz.ch>

Better watch those 1s. These are actually signed 32 bit values, so they will
have unexpected side effects once we shift them more than 30 bits.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41452 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ca00b28e 11-May-2011 Michael Lotz <mmlr@mlotz.ch>

Fix another case where the local interrupt vector would be added instead of the
global system one.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41451 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0414a203 11-May-2011 Michael Lotz <mmlr@mlotz.ch>

Print some more MADT entries when debug output is enabled. Right now they are
informational only, but most of these entries actually need to be handled.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41450 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 63475256 11-May-2011 Michael Lotz <mmlr@mlotz.ch>

* Always retrieve the APIC ID from the descriptors.
* Actually program the IO-APIC ID when configuring the IO-APIC.
* Moved some debug output around.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41447 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a56cbb2a 11-May-2011 Michael Lotz <mmlr@mlotz.ch>

* When initializing MSI support, don't assume a single 24 entry IO-APIC. Instead
mark the ISA interrupts as unusable and then use ioapic_is_interrupt_available
to determine if that vector is possibly taken by an IO-APIC. If IO-APICs are
not used, this will simply always return false, leaving all vectors free for
MSI use.
* The msi_init() now has to be done after a potential IO-APIC init, so it is now
done after ioapic_init() instead of inside apic_init().
* Add apic_disable_local_ints() to clear the local ints on the local APIC once
we are in APIC mode (i.e. the IO-APIC is set up and we don't need the external
routing anymore).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41445 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0f91697f 11-May-2011 Michael Lotz <mmlr@mlotz.ch>

Fix previous commit and add printing APIC id fields.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41437 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cdb247a3 11-May-2011 Michael Lotz <mmlr@mlotz.ch>

Extended and fix some of the debug output.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41436 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7a8ce431 11-May-2011 Michael Lotz <mmlr@mlotz.ch>

Obviously we want to use the GSI as interrupt vector as well...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41435 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e9d55697 11-May-2011 Michael Lotz <mmlr@mlotz.ch>

Only make GSI 0 into an ExtInt and GSIs 1-15 ISA interrupts. When having
multiple IO-APICs every IO-APIC was initialized to the standard mapping before.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41434 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ca67ddb3 11-May-2011 Michael Lotz <mmlr@mlotz.ch>

When enumerating IO-APICs failed, try to still get the routing done with how far
we got. If the routing is possible with the limited IO-APICs everythings good,
if not we will simply fail at the routing preparation stage where we can still
fall back gracefully. This makes things a bit more error resilient.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41432 a95241bf-73f2-0310-859d-f6bbb57e9c96


# eda74390 11-May-2011 Michael Lotz <mmlr@mlotz.ch>

Provide an interrupt availability check callback instead of a maximum IRQ
number. This accounts for possible gaps in the IO-APIC GSI mappings. Since most
of the time there will be only a single IO-APIC the extra overhead is relatively
small.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41431 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d11e32a8 11-May-2011 Michael Lotz <mmlr@mlotz.ch>

Enumerate IO-APICs using the ACPI Multiple APIC Descriptor Table (MADT). We do
the same for the first IO-APIC in the bootloader (also using the MADT), but
here we can use the ACPI module. The enumerated IO-APICs are added to the list
and should be usable from there on. For lack of hardware I wasn't able to really
test that though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41430 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5d01e61a 10-May-2011 Michael Lotz <mmlr@mlotz.ch>

* Prepared everything to eventually support multiple IO-APICs.
* Added some TODOs regarding register write order that might have bad side
effects.
* Some cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41428 a95241bf-73f2-0310-859d-f6bbb57e9c96


# dc14d97b 10-May-2011 Michael Lotz <mmlr@mlotz.ch>

* Move the legacy PIC and the IO-APIC code into their own source file. No
functional change intended.
* Use an appropriately sized sLevelTriggeredInterrupts for each controller type.
This also fixes an out of bound access for IO-APICs with more than 32 entries
and also returns the right mode in such cases.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41426 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 663951443784bb63d60abe742f1d1379fb153e18 19-Dec-2013 Pawel Dziepak <pdziepak@quarnos.org>

x86[_64]: Support assigning MSI IRQs to arbitrary CPU


# d897a478d7c01054aad29b23f7f545073c797530 17-Nov-2013 Pawel Dziepak <pdziepak@quarnos.org>

kernel: Allow reassigning IRQs to logical processors


# 6a164daad43169daf0a407fb1f6b0484671ff466 17-Nov-2013 Pawel Dziepak <pdziepak@quarnos.org>

kernel: Track load produced by interrupt handlers


# 2bd8cdc16ba6292d6d13ddf871a101e86b2fd43f 24-Oct-2013 Jérôme Duval <jerome.duval@gmail.com>

acpi: switch acpi_object from a struct to a union

* this way the size of acpi_object_type matches the size of ACPI_OBJECT
for 32-bit and 64-bit builds.
* adjust users of the type acpi_object_type.


# fa6327c9f48f89f3be1f229d5aca749241b55bf0 09-Aug-2012 Alex Smith <alex@alex-smith.me.uk>

Compile remaining x86 bits for x86_64.

The IOAPIC and IRQ routing code now gets compiled for x86_64, though
they won't be used yet as there is no ACPI support currently.


# 62d36f98331067e472188f6c020c2ccd808f48cf 22-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Removed the addr_t conversion operators from FixedWidthPointer which makes comparison against NULL work properly.


# d8efc6caf6babe278c48e8aa3277376fb68ff455 21-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Changes to kernel_args to make it identical for x86 and x86_64.

* Added a FixedWidthPointer template class which uses 64-bit storage to hold
a pointer. This is used in place of raw pointers in kernel_args.
* Added __attribute__((packed)) to kernel_args and all structures contained
within it. This is necessary due to different alignment behaviour for
32-bit and 64-bit compilation with GCC.
* With these changes, kernel_args will now come out the same size for both
the x86_64 kernel and the loader, excluding the preloaded_image structure
which has not yet been changed.
* Tested both an x86 GCC2 and GCC4 build, no problems caused by these changes.


# c59b279b7173bcafb8f266aa753b2f9e6c578849 19-Jan-2012 Jérôme Duval <jerome.duval@gmail.com>

Added workarounds and options for gcc 4.6.2

* add -Wno-unused-but-set-variable for gcc 4.6.x with a TODO
* fix warnings about wrong size of pointer cast in ioapic.cpp and AudioBuffer.cpp


# fc2d7cb04d7ad78424169fd0df4d236de2bb17d1 12-Oct-2011 Michael Lotz <mmlr@mlotz.ch>

* Introduce {reserve|allocate|free}_io_interrupt_vectors() that can generically
be used to mark certain io interrupt vectors as reserved and to allocate from
the still free ones. It is a kernel private API for now though.
* Make the MSI code use that functionality instead of implementing its own which
slims it down considerably and also removes quite a bit of hardcoded knowledge
about the interrupt layout that didn't really belong there.
* Mark the various in-use interrupts as reserved from the components that
actually know about them (PIC, IO-APIC, SMP, APIC timer and interrupt setup).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42832 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cb4e75d3ebefcb87cee402f56144caae7d11a8f5 21-May-2011 Michael Lotz <mmlr@mlotz.ch>

* When configuring a link device failed, fall back and keep the currently
active config and update the info for the remaining shared link device
entries. Seen on KVM for the (PCI) ACPI interrupt, but happens where there is
no _SRS method for a device (as this one is optional). I find that a bit
strange however as in such a case no _PRS (possible resources) should be
present either, especially not one advertising a config different from the
current one.
* Print the routing table later, after enabling irq routing, so that possible
changes due to such a fallback are included.
* Fix a typo.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41652 a95241bf-73f2-0310-859d-f6bbb57e9c96


# aa373c439f4301205486aa55358addcd52326e29 16-May-2011 Michael Lotz <mmlr@mlotz.ch>

We have to decouple the enumeration and marking of the NMIs from the actual NMI
pin configuration as the configuration only happens after preparing the
configuration where we already need the NMI mask.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41536 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 74e9ede3b28d6de6b558a8b5c4b351790781fe3c 16-May-2011 Michael Lotz <mmlr@mlotz.ch>

Simplify and clean up. Removed most of the shifts and made direct masks out of
the macros. This makes things more readable and also fixes the few remaining
80 char limit violations. No functional change intended.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41533 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bc409b4915c96f3313138043b94754efdcaed422 16-May-2011 Michael Lotz <mmlr@mlotz.ch>

Fix minor debug output oversight in the last commit.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41532 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9ae3fdcb02b3815e163d7b983ba77a8b3aaf6e1c 16-May-2011 Michael Lotz <mmlr@mlotz.ch>

* Move redirection entry configuration into a separate function and allow to
specify the delivery mode.
* Use that function from ioapic_configure_io_interrupt() and use it when
configuring NMI sources to actually set the entries to NMI.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41531 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 86d59c04c642e3ae972ff9f43f0a75052780a864 16-May-2011 Michael Lotz <mmlr@mlotz.ch>

Support NMI sources. Any non maskable interrupt (NMI) will be marked as
unavailable for routing so that we don't end up configuring anything on them.
I haven't seen these in actual use though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41530 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 22d72c8ee12897715e08a5ec1ca105c3aa968b11 16-May-2011 Michael Lotz <mmlr@mlotz.ch>

Guard against IO-APICs with too many entries. We only support 64 entries because
we use a 64 bit level triggered mask. In practice these don't exist as far as I
know. If we encounter them at a later stage we need to revisit the mask.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41529 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fb5a1727f46e21307d58922debc859731156e652 15-May-2011 Michael Lotz <mmlr@mlotz.ch>

* Implement interrupt source overrides. We install a relay interrupt handler
at the override entry to trigger the overriden vector so that we don't need
to configure any additional redirections.
* Also configures the polarity and trigger modes found in the override entry.
* When disabling the legacy PIC, retrieve the enabled interrupts and re-enable
then in the IO-APIC. This will for example make the ACPI SCI work that is
installed prior to switching interrupt models. Through the transparent support
for interrupt source overrides it'll also automatically relay from the old to
the new vector.

This should make ACPI interrupts work and should support relocating the ISA PIT
from irq 0 to a different global system interrupt (usually 2) so that it can
still work when IO-APICs are in use.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41528 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9c1714ec1a3c8c4769198af90694450c170da007 16-May-2011 Michael Lotz <mmlr@mlotz.ch>

Enable IO-APICs by default. It's been tested on a broad spectrum of hardware and
all reports so far have been positive. We fall back to legacy mode in the cases
where we can't figure out the correct routing.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41527 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8908aef9c2c62225bce2d8216e81397c872316e8 13-May-2011 Michael Lotz <mmlr@mlotz.ch>

* Don't map the IO-APIC within the bootloader. We don't need it to set up SMP
at all and, since there can be multiple IO-APICs, we need to do the
enumeration again in the kernel anyway. Also only set ioapic_phys the first
time we encounter an IO-APIC object as it looks cleaner when we arrive at the
first IO-APIC default address.
* Therefore we don't have to worry about already mapped IO-APICs when
enumerating them in the kernel.
* Also remove the mapping function that is now not used anymore.
* We still use the ioapic_phys field of the kernel args to determine whether
there is an IO-APIC at all to avoid needlessly doing the enumeration again.

This fixes multi IO-APIC configurations, because before we would indeed map
the last IO-APIC listed in the MADT, but then in the kernel assumed we mapped
the first one. We'd end up with mapping the last listed IO-APIC twice and the
first IO-APIC never, always programming the last one when we actually targetted
the first one.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41476 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0798779a2f2e923f53c34b72fed88e2a32e3acf9 11-May-2011 Michael Lotz <mmlr@mlotz.ch>

Resolve TODO: Take the writing order into account. Ensure the mask bit is
written first/last depending on the operation to avoid modifying entries that
are still unmasked or unmasking entries that aren't set up yet.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41457 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f91cbdde46a37400b4e9ac593eeb357c15fb7c2e 11-May-2011 Michael Lotz <mmlr@mlotz.ch>

Better watch those 1s. These are actually signed 32 bit values, so they will
have unexpected side effects once we shift them more than 30 bits.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41452 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ca00b28e8bfdba68f80b1a973f367a6844af2a8f 11-May-2011 Michael Lotz <mmlr@mlotz.ch>

Fix another case where the local interrupt vector would be added instead of the
global system one.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41451 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0414a2033051c4b457a01935601faa276d37535a 11-May-2011 Michael Lotz <mmlr@mlotz.ch>

Print some more MADT entries when debug output is enabled. Right now they are
informational only, but most of these entries actually need to be handled.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41450 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 63475256073603ec0d2d9d81ba0411f753aeb803 11-May-2011 Michael Lotz <mmlr@mlotz.ch>

* Always retrieve the APIC ID from the descriptors.
* Actually program the IO-APIC ID when configuring the IO-APIC.
* Moved some debug output around.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41447 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a56cbb2afbf4dbfb4a07dfdd95f10637a195a053 11-May-2011 Michael Lotz <mmlr@mlotz.ch>

* When initializing MSI support, don't assume a single 24 entry IO-APIC. Instead
mark the ISA interrupts as unusable and then use ioapic_is_interrupt_available
to determine if that vector is possibly taken by an IO-APIC. If IO-APICs are
not used, this will simply always return false, leaving all vectors free for
MSI use.
* The msi_init() now has to be done after a potential IO-APIC init, so it is now
done after ioapic_init() instead of inside apic_init().
* Add apic_disable_local_ints() to clear the local ints on the local APIC once
we are in APIC mode (i.e. the IO-APIC is set up and we don't need the external
routing anymore).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41445 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0f91697fd77a7cc27518e93c29bfcd66c2c09b58 11-May-2011 Michael Lotz <mmlr@mlotz.ch>

Fix previous commit and add printing APIC id fields.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41437 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cdb247a328966a5b9181c500589ad93483cbb2d1 11-May-2011 Michael Lotz <mmlr@mlotz.ch>

Extended and fix some of the debug output.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41436 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7a8ce431b5b168e4a862eb508840198d2abe8acb 11-May-2011 Michael Lotz <mmlr@mlotz.ch>

Obviously we want to use the GSI as interrupt vector as well...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41435 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e9d556974028df143081ecdba3a605514ddf3f9f 11-May-2011 Michael Lotz <mmlr@mlotz.ch>

Only make GSI 0 into an ExtInt and GSIs 1-15 ISA interrupts. When having
multiple IO-APICs every IO-APIC was initialized to the standard mapping before.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41434 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ca67ddb3539baff65715bbc068643e36f110132b 11-May-2011 Michael Lotz <mmlr@mlotz.ch>

When enumerating IO-APICs failed, try to still get the routing done with how far
we got. If the routing is possible with the limited IO-APICs everythings good,
if not we will simply fail at the routing preparation stage where we can still
fall back gracefully. This makes things a bit more error resilient.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41432 a95241bf-73f2-0310-859d-f6bbb57e9c96


# eda743903ea64c85411430c0a7e660d77f51e246 11-May-2011 Michael Lotz <mmlr@mlotz.ch>

Provide an interrupt availability check callback instead of a maximum IRQ
number. This accounts for possible gaps in the IO-APIC GSI mappings. Since most
of the time there will be only a single IO-APIC the extra overhead is relatively
small.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41431 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d11e32a807384f4c348e214a4eef1786d3070cbb 11-May-2011 Michael Lotz <mmlr@mlotz.ch>

Enumerate IO-APICs using the ACPI Multiple APIC Descriptor Table (MADT). We do
the same for the first IO-APIC in the bootloader (also using the MADT), but
here we can use the ACPI module. The enumerated IO-APICs are added to the list
and should be usable from there on. For lack of hardware I wasn't able to really
test that though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41430 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5d01e61a91370ddcea262d5dd2b86a2454aae7a6 10-May-2011 Michael Lotz <mmlr@mlotz.ch>

* Prepared everything to eventually support multiple IO-APICs.
* Added some TODOs regarding register write order that might have bad side
effects.
* Some cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41428 a95241bf-73f2-0310-859d-f6bbb57e9c96


# dc14d97b7f70aa318483d53e007913b26a12f5d0 10-May-2011 Michael Lotz <mmlr@mlotz.ch>

* Move the legacy PIC and the IO-APIC code into their own source file. No
functional change intended.
* Use an appropriately sized sLevelTriggeredInterrupts for each controller type.
This also fixes an out of bound access for IO-APICs with more than 32 entries
and also returns the right mode in such cases.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41426 a95241bf-73f2-0310-859d-f6bbb57e9c96