2008-09-19 00:56:32 +02:00
|
|
|
/****************************************************************************
|
2014-08-08 22:31:15 +02:00
|
|
|
* sched/irq/irq_dispatch.c
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
2017-03-03 15:55:16 +01:00
|
|
|
* Copyright (C) 2007, 2008, 2017 Gregory Nutt. All rights reserved.
|
2012-07-14 21:30:31 +02:00
|
|
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
2008-09-19 00:56:32 +02:00
|
|
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
2007-02-18 00:21:28 +01:00
|
|
|
* used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
2008-09-19 00:56:32 +02:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2008-09-19 00:56:32 +02:00
|
|
|
/****************************************************************************
|
2007-02-18 00:21:28 +01:00
|
|
|
* Included Files
|
2008-09-19 00:56:32 +02:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2009-12-14 19:39:29 +01:00
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
2008-09-19 00:56:32 +02:00
|
|
|
#include <debug.h>
|
2007-02-18 00:21:28 +01:00
|
|
|
#include <nuttx/arch.h>
|
|
|
|
#include <nuttx/irq.h>
|
2017-03-30 15:38:37 +02:00
|
|
|
#include <nuttx/random.h>
|
2008-09-19 00:56:32 +02:00
|
|
|
|
2014-08-08 22:31:15 +02:00
|
|
|
#include "irq/irq.h"
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2008-09-19 00:56:32 +02:00
|
|
|
/****************************************************************************
|
2007-02-18 00:21:28 +01:00
|
|
|
* Public Functions
|
2008-09-19 00:56:32 +02:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2008-09-19 00:56:32 +02:00
|
|
|
/****************************************************************************
|
2007-02-18 00:21:28 +01:00
|
|
|
* Name: irq_dispatch
|
|
|
|
*
|
|
|
|
* Description:
|
2017-03-30 15:38:37 +02:00
|
|
|
* This function must be called from the architecture-specific logic in
|
2012-07-14 21:30:31 +02:00
|
|
|
* order to dispatch an interrupt to the appropriate, registered handling
|
|
|
|
* logic.
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
2015-10-03 01:43:18 +02:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2007-02-27 22:17:21 +01:00
|
|
|
void irq_dispatch(int irq, FAR void *context)
|
2007-02-18 00:21:28 +01:00
|
|
|
{
|
|
|
|
xcpt_t vector;
|
2017-02-27 13:27:56 +01:00
|
|
|
FAR void *arg;
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
/* Perform some sanity checks */
|
|
|
|
|
2007-02-27 22:17:21 +01:00
|
|
|
#if NR_IRQS > 0
|
2017-03-03 15:55:16 +01:00
|
|
|
if ((unsigned)irq >= NR_IRQS)
|
2007-02-18 00:21:28 +01:00
|
|
|
{
|
|
|
|
vector = irq_unexpected_isr;
|
2017-02-27 13:27:56 +01:00
|
|
|
arg = NULL;
|
2007-02-18 00:21:28 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-03 15:55:16 +01:00
|
|
|
#ifdef CONFIG_ARCH_MINIMAL_VECTORTABLE
|
2017-03-03 17:20:40 +01:00
|
|
|
irq_mapped_t ndx = g_irqmap[irq];
|
|
|
|
if (ndx >= CONFIG_ARCH_NUSER_INTERRUPTS)
|
2017-03-03 15:55:16 +01:00
|
|
|
{
|
|
|
|
vector = irq_unexpected_isr;
|
|
|
|
arg = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
vector = g_irqvector[ndx].handler;
|
|
|
|
arg = g_irqvector[ndx].arg;
|
|
|
|
}
|
|
|
|
#else
|
2017-02-27 13:27:56 +01:00
|
|
|
vector = g_irqvector[irq].handler;
|
|
|
|
arg = g_irqvector[irq].arg;
|
2017-03-03 15:55:16 +01:00
|
|
|
#endif
|
2007-02-18 00:21:28 +01:00
|
|
|
}
|
2017-03-03 15:55:16 +01:00
|
|
|
|
2007-02-27 22:17:21 +01:00
|
|
|
#else
|
|
|
|
vector = irq_unexpected_isr;
|
2017-03-03 15:55:16 +01:00
|
|
|
arg = NULL;
|
2007-02-27 22:17:21 +01:00
|
|
|
#endif
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2017-03-30 15:38:37 +02:00
|
|
|
#ifdef CONFIG_CRYPTO_RANDOM_POOL_COLLECT_IRQ_RANDOMNESS
|
|
|
|
/* Add interrupt timing randomness to entropy pool */
|
|
|
|
|
|
|
|
add_irq_randomness(irq);
|
|
|
|
#endif
|
|
|
|
|
2007-02-18 00:21:28 +01:00
|
|
|
/* Then dispatch to the interrupt handler */
|
|
|
|
|
2017-02-27 13:27:56 +01:00
|
|
|
vector(irq, context, arg);
|
2007-02-18 00:21:28 +01:00
|
|
|
}
|