2015-04-11 07:44:37 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2014 Wind River Systems, Inc.
|
|
|
|
*
|
2017-01-19 09:01:01 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2015-04-11 07:44:37 +08:00
|
|
|
*/
|
|
|
|
|
2015-12-04 23:09:39 +08:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief ARCv2 interrupt management
|
|
|
|
*
|
2015-04-11 07:44:37 +08:00
|
|
|
*
|
|
|
|
* Interrupt management:
|
|
|
|
*
|
|
|
|
* - enabling/disabling
|
|
|
|
*
|
2015-10-23 02:59:54 +08:00
|
|
|
* An IRQ number passed to the @a irq parameters found in this file is a
|
2015-04-11 07:44:37 +08:00
|
|
|
* number from 16 to last IRQ number on the platform.
|
|
|
|
*/
|
|
|
|
|
2016-12-23 21:35:34 +08:00
|
|
|
#include <kernel.h>
|
2015-05-29 01:56:47 +08:00
|
|
|
#include <arch/cpu.h>
|
2015-04-11 07:44:37 +08:00
|
|
|
#include <misc/__assert.h>
|
|
|
|
#include <toolchain.h>
|
|
|
|
#include <sections.h>
|
|
|
|
#include <sw_isr_table.h>
|
2016-02-26 05:21:02 +08:00
|
|
|
#include <irq.h>
|
2015-04-11 07:44:37 +08:00
|
|
|
|
|
|
|
/*
|
2015-07-02 05:51:40 +08:00
|
|
|
* @brief Enable an interrupt line
|
2015-04-11 07:44:37 +08:00
|
|
|
*
|
|
|
|
* Clear possible pending interrupts on the line, and enable the interrupt
|
|
|
|
* line. After this call, the CPU will receive interrupts for the specified
|
2015-10-23 02:59:54 +08:00
|
|
|
* @a irq.
|
2015-04-11 07:44:37 +08:00
|
|
|
*
|
2015-07-02 05:29:04 +08:00
|
|
|
* @return N/A
|
2015-04-11 07:44:37 +08:00
|
|
|
*/
|
|
|
|
|
2016-02-26 05:21:02 +08:00
|
|
|
void _arch_irq_enable(unsigned int irq)
|
2015-04-11 07:44:37 +08:00
|
|
|
{
|
2015-08-13 05:53:54 +08:00
|
|
|
int key = irq_lock();
|
2015-04-11 07:44:37 +08:00
|
|
|
|
|
|
|
_arc_v2_irq_unit_int_enable(irq);
|
2015-08-13 05:53:54 +08:00
|
|
|
irq_unlock(key);
|
2015-04-11 07:44:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2015-07-02 05:51:40 +08:00
|
|
|
* @brief Disable an interrupt line
|
2015-04-11 07:44:37 +08:00
|
|
|
*
|
|
|
|
* Disable an interrupt line. After this call, the CPU will stop receiving
|
2015-10-23 02:59:54 +08:00
|
|
|
* interrupts for the specified @a irq.
|
2015-04-11 07:44:37 +08:00
|
|
|
*
|
2015-07-02 05:29:04 +08:00
|
|
|
* @return N/A
|
2015-04-11 07:44:37 +08:00
|
|
|
*/
|
|
|
|
|
2016-02-26 05:21:02 +08:00
|
|
|
void _arch_irq_disable(unsigned int irq)
|
2015-04-11 07:44:37 +08:00
|
|
|
{
|
2015-08-13 05:53:54 +08:00
|
|
|
int key = irq_lock();
|
2015-04-11 07:44:37 +08:00
|
|
|
|
|
|
|
_arc_v2_irq_unit_int_disable(irq);
|
2015-08-13 05:53:54 +08:00
|
|
|
irq_unlock(key);
|
2015-04-11 07:44:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2015-08-13 03:15:48 +08:00
|
|
|
* @internal
|
|
|
|
*
|
2015-07-02 05:51:40 +08:00
|
|
|
* @brief Set an interrupt's priority
|
2015-04-11 07:44:37 +08:00
|
|
|
*
|
2016-08-17 01:58:40 +08:00
|
|
|
* Lower values take priority over higher values. Special case priorities are
|
|
|
|
* expressed via mutually exclusive flags.
|
2016-07-26 02:34:34 +08:00
|
|
|
|
2016-08-17 01:58:40 +08:00
|
|
|
* The priority is verified if ASSERT_ON is enabled; max priority level
|
|
|
|
* depends on CONFIG_NUM_IRQ_PRIO_LEVELS.
|
2015-04-11 07:44:37 +08:00
|
|
|
*
|
2015-07-02 05:29:04 +08:00
|
|
|
* @return N/A
|
2015-04-11 07:44:37 +08:00
|
|
|
*/
|
|
|
|
|
2017-04-21 23:55:34 +08:00
|
|
|
void _irq_priority_set(unsigned int irq, unsigned int prio, u32_t flags)
|
2015-04-11 07:44:37 +08:00
|
|
|
{
|
2016-08-17 01:58:40 +08:00
|
|
|
ARG_UNUSED(flags);
|
|
|
|
|
2015-08-13 05:53:54 +08:00
|
|
|
int key = irq_lock();
|
2015-04-11 07:44:37 +08:00
|
|
|
|
2016-08-17 01:58:40 +08:00
|
|
|
__ASSERT(prio < CONFIG_NUM_IRQ_PRIO_LEVELS,
|
|
|
|
"invalid priority %d for irq %d", prio, irq);
|
2015-04-11 07:44:37 +08:00
|
|
|
_arc_v2_irq_unit_prio_set(irq, prio);
|
2015-08-13 05:53:54 +08:00
|
|
|
irq_unlock(key);
|
2015-04-11 07:44:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2015-07-02 05:51:40 +08:00
|
|
|
* @brief Spurious interrupt handler
|
2015-04-11 07:44:37 +08:00
|
|
|
*
|
|
|
|
* Installed in all dynamic interrupt slots at boot time. Throws an error if
|
|
|
|
* called.
|
|
|
|
*
|
2015-07-02 05:29:04 +08:00
|
|
|
* @return N/A
|
2015-04-11 07:44:37 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <misc/printk.h>
|
2015-04-23 21:49:36 +08:00
|
|
|
void _irq_spurious(void *unused)
|
2015-04-11 07:44:37 +08:00
|
|
|
{
|
|
|
|
ARG_UNUSED(unused);
|
2015-04-23 21:49:36 +08:00
|
|
|
printk("_irq_spurious(). Spinning...\n");
|
2015-04-11 07:44:37 +08:00
|
|
|
for (;;)
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|