2015-04-11 01:44:37 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2013-2015, Wind River Systems, Inc.
|
|
|
|
*
|
2017-01-19 02:01:01 +01:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2015-04-11 01:44:37 +02:00
|
|
|
*/
|
|
|
|
|
2015-12-04 16:09:39 +01:00
|
|
|
/**
|
2015-09-07 14:22:55 +02:00
|
|
|
* @file
|
|
|
|
* @brief system module for variants with LOAPIC
|
|
|
|
*
|
2015-07-01 23:22:39 +02:00
|
|
|
*/
|
2015-04-11 01:44:37 +02:00
|
|
|
|
2019-06-26 16:33:39 +02:00
|
|
|
#include <sys/__assert.h>
|
2016-12-04 21:59:37 +01:00
|
|
|
#include <kernel.h>
|
2015-05-28 19:56:47 +02:00
|
|
|
#include <arch/cpu.h>
|
2019-06-21 18:54:15 +02:00
|
|
|
#include <drivers/interrupt_controller/ioapic.h>
|
|
|
|
#include <drivers/interrupt_controller/loapic.h>
|
|
|
|
#include <drivers/interrupt_controller/sysapic.h>
|
2016-03-03 18:50:39 +01:00
|
|
|
#include <irq.h>
|
2015-04-11 01:44:37 +02:00
|
|
|
|
2016-08-02 21:05:08 +02:00
|
|
|
#define IS_IOAPIC_IRQ(irq) (irq < LOAPIC_IRQ_BASE)
|
|
|
|
#define HARDWARE_IRQ_LIMIT ((LOAPIC_IRQ_BASE + LOAPIC_IRQ_COUNT) - 1)
|
2015-07-03 00:59:02 +02:00
|
|
|
|
2015-07-01 23:22:39 +02:00
|
|
|
/**
|
|
|
|
*
|
2015-07-01 23:51:40 +02:00
|
|
|
* @brief Program interrupt controller
|
2015-07-01 23:22:39 +02:00
|
|
|
*
|
2015-07-27 17:02:41 +02:00
|
|
|
* This routine programs the interrupt controller with the given vector
|
|
|
|
* based on the given IRQ parameter.
|
2015-07-01 23:22:39 +02:00
|
|
|
*
|
2016-01-27 19:07:31 +01:00
|
|
|
* Drivers call this routine instead of IRQ_CONNECT() when interrupts are
|
2015-07-01 23:22:39 +02:00
|
|
|
* configured statically.
|
|
|
|
*
|
2015-11-03 00:06:08 +01:00
|
|
|
* The Galileo board virtualizes IRQs as follows:
|
2015-07-01 23:22:39 +02:00
|
|
|
*
|
2015-07-28 20:39:12 +02:00
|
|
|
* - The first CONFIG_IOAPIC_NUM_RTES IRQs are provided by the IOAPIC so the
|
|
|
|
* IOAPIC is programmed for these IRQs
|
2015-07-01 23:51:40 +02:00
|
|
|
* - The remaining IRQs are provided by the LOAPIC and hence the LOAPIC is
|
2015-07-01 23:22:39 +02:00
|
|
|
* programmed.
|
2015-10-20 18:42:33 +02:00
|
|
|
*
|
|
|
|
* @param vector the vector number
|
|
|
|
* @param irq the virtualized IRQ
|
2015-11-03 00:06:08 +01:00
|
|
|
* @param flags interrupt flags
|
2015-10-20 18:42:33 +02:00
|
|
|
*
|
2015-07-01 23:22:39 +02:00
|
|
|
*/
|
2019-06-28 22:06:37 +02:00
|
|
|
void z_irq_controller_irq_config(unsigned int vector, unsigned int irq,
|
2017-04-21 17:03:20 +02:00
|
|
|
u32_t flags)
|
2015-04-11 01:44:37 +02:00
|
|
|
{
|
2018-02-17 02:20:32 +01:00
|
|
|
__ASSERT(irq <= HARDWARE_IRQ_LIMIT, "invalid irq line");
|
2016-08-02 21:05:08 +02:00
|
|
|
|
2015-07-03 00:59:02 +02:00
|
|
|
if (IS_IOAPIC_IRQ(irq)) {
|
2019-03-08 22:19:05 +01:00
|
|
|
z_ioapic_irq_set(irq, vector, flags);
|
2015-04-11 01:44:37 +02:00
|
|
|
} else {
|
2019-03-08 22:19:05 +01:00
|
|
|
z_loapic_int_vec_set(irq - LOAPIC_IRQ_BASE, vector);
|
2015-04-11 01:44:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-01 23:22:39 +02:00
|
|
|
/**
|
|
|
|
*
|
2015-07-01 23:51:40 +02:00
|
|
|
* @brief Enable an individual interrupt (IRQ)
|
2015-07-01 23:22:39 +02:00
|
|
|
*
|
|
|
|
* The public interface for enabling/disabling a specific IRQ for the IA-32
|
2015-07-27 17:02:41 +02:00
|
|
|
* architecture is defined as follows in include/arch/x86/arch.h
|
2015-07-01 23:22:39 +02:00
|
|
|
*
|
|
|
|
* extern void irq_enable (unsigned int irq);
|
|
|
|
* extern void irq_disable (unsigned int irq);
|
|
|
|
*
|
2015-07-27 17:02:41 +02:00
|
|
|
* The irq_enable() routine is provided by the interrupt controller driver due
|
|
|
|
* to the IRQ virtualization that is performed by this platform. See the
|
2016-08-02 21:05:08 +02:00
|
|
|
* comments in _interrupt_vector_allocate() for more information regarding IRQ
|
2015-07-27 17:02:41 +02:00
|
|
|
* virtualization.
|
2015-07-01 23:22:39 +02:00
|
|
|
*
|
2015-07-01 23:29:04 +02:00
|
|
|
* @return N/A
|
2015-07-01 23:22:39 +02:00
|
|
|
*/
|
2019-03-08 22:19:05 +01:00
|
|
|
void z_arch_irq_enable(unsigned int irq)
|
2015-04-11 01:44:37 +02:00
|
|
|
{
|
2015-07-03 00:59:02 +02:00
|
|
|
if (IS_IOAPIC_IRQ(irq)) {
|
2019-03-08 22:19:05 +01:00
|
|
|
z_ioapic_irq_enable(irq);
|
2015-04-11 01:44:37 +02:00
|
|
|
} else {
|
2019-03-08 22:19:05 +01:00
|
|
|
z_loapic_irq_enable(irq - LOAPIC_IRQ_BASE);
|
2015-04-11 01:44:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-01 23:22:39 +02:00
|
|
|
/**
|
|
|
|
*
|
2015-07-01 23:51:40 +02:00
|
|
|
* @brief Disable an individual interrupt (IRQ)
|
2015-07-01 23:22:39 +02:00
|
|
|
*
|
2015-07-27 17:02:41 +02:00
|
|
|
* The irq_disable() routine is provided by the interrupt controller driver due
|
|
|
|
* to the IRQ virtualization that is performed by this platform. See the
|
2016-08-02 21:05:08 +02:00
|
|
|
* comments in _interrupt_vector_allocate() for more information regarding IRQ
|
2015-07-27 17:02:41 +02:00
|
|
|
* virtualization.
|
2015-07-01 23:22:39 +02:00
|
|
|
*
|
2015-07-01 23:29:04 +02:00
|
|
|
* @return N/A
|
2015-07-01 23:22:39 +02:00
|
|
|
*/
|
2019-03-08 22:19:05 +01:00
|
|
|
void z_arch_irq_disable(unsigned int irq)
|
2015-04-11 01:44:37 +02:00
|
|
|
{
|
2015-07-03 00:59:02 +02:00
|
|
|
if (IS_IOAPIC_IRQ(irq)) {
|
2019-03-08 22:19:05 +01:00
|
|
|
z_ioapic_irq_disable(irq);
|
2015-04-11 01:44:37 +02:00
|
|
|
} else {
|
2019-03-08 22:19:05 +01:00
|
|
|
z_loapic_irq_disable(irq - LOAPIC_IRQ_BASE);
|
2015-07-03 00:59:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|