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