drivers/interrupt_controller: Get the IOAPIC RTEs dynamically

The fixed number of 24 RTEs is a legacy thing, and long gone by now.
IOAPICs expose the maximum number of RTEs they have via the version
register, so let's use it.

This avoids to manually tweak a Kconfig option (which is now removed)
and fixes the RTE number for all x86 targets relevantly.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
Tomasz Bursztyka 2021-03-09 19:54:42 +01:00 committed by Anas Nashif
commit 915f4ac3c7
8 changed files with 49 additions and 44 deletions

View file

@ -20,6 +20,7 @@
#include <drivers/interrupt_controller/loapic.h> /* public API declarations */
#include <device.h>
#include <drivers/interrupt_controller/sysapic.h>
#include <drivers/interrupt_controller/ioapic.h>
/* Local APIC Version Register Bits */
@ -192,6 +193,12 @@ static int loapic_init(const struct device *unused)
return 0;
}
uint32_t z_loapic_irq_base(void)
{
return z_ioapic_num_rtes();
}
/**
*
* @brief Set the vector field in the specified RTE
@ -344,7 +351,7 @@ static int loapic_suspend(const struct device *port)
for (loapic_irq = 0; loapic_irq < LOAPIC_IRQ_COUNT; loapic_irq++) {
if (_irq_to_interrupt_vector[LOAPIC_IRQ_BASE + loapic_irq]) {
if (_irq_to_interrupt_vector[z_loapic_irq_base() + loapic_irq]) {
/* Since vector numbers are already present in RAM/ROM,
* We save only the mask bits here.
@ -374,10 +381,11 @@ int loapic_resume(const struct device *port)
for (loapic_irq = 0; loapic_irq < LOAPIC_IRQ_COUNT; loapic_irq++) {
if (_irq_to_interrupt_vector[LOAPIC_IRQ_BASE + loapic_irq]) {
if (_irq_to_interrupt_vector[z_loapic_irq_base() + loapic_irq]) {
/* Configure vector and enable the required ones*/
z_loapic_int_vec_set(loapic_irq,
_irq_to_interrupt_vector[LOAPIC_IRQ_BASE + loapic_irq]);
_irq_to_interrupt_vector[z_loapic_irq_base() +
loapic_irq]);
if (sys_bitfield_test_bit((mem_addr_t) loapic_suspend_buf,
loapic_irq)) {