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
|
|
|
|
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-11 01:44:37 +02:00
|
|
|
|
2021-03-09 19:54:42 +01:00
|
|
|
#define IS_IOAPIC_IRQ(irq) (irq < z_loapic_irq_base())
|
|
|
|
#define HARDWARE_IRQ_LIMIT ((z_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
|
|
|
*
|
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 20:39:12 +02:00
|
|
|
* 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-07-01 23:22:39 +02:00
|
|
|
*/
|
2021-03-17 21:49:39 +01:00
|
|
|
__boot_func
|
2019-06-28 22:06:37 +02:00
|
|
|
void z_irq_controller_irq_config(unsigned int vector, unsigned int irq,
|
2020-05-27 18:26:57 +02:00
|
|
|
uint32_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 {
|
2021-03-09 19:54:42 +01:00
|
|
|
z_loapic_int_vec_set(irq - z_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
|
|
|
*/
|
2021-03-17 21:49:39 +01:00
|
|
|
__pinned_func
|
2019-11-07 21:43:29 +01:00
|
|
|
void 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 {
|
2021-03-09 19:54:42 +01:00
|
|
|
z_loapic_irq_enable(irq - z_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
|
|
|
*/
|
2021-03-17 21:49:39 +01:00
|
|
|
__pinned_func
|
2019-11-07 21:43:29 +01:00
|
|
|
void 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 {
|
2021-03-09 19:54:42 +01:00
|
|
|
z_loapic_irq_disable(irq - z_loapic_irq_base());
|
2015-07-03 00:59:02 +02:00
|
|
|
}
|
|
|
|
}
|