diff --git a/arch/misoc/src/lm32/Make.defs b/arch/misoc/src/lm32/Make.defs index 83381543884..cc4b72da664 100644 --- a/arch/misoc/src/lm32/Make.defs +++ b/arch/misoc/src/lm32/Make.defs @@ -42,8 +42,9 @@ CMN_CSRCS = misoc_uart.c CHIP_ASRCS = lm32_syscall.S CHIP_CSRCS = lm32_allocateheap.c lm32_assert.c lm32_blocktask.c -CHIP_CSRCS += lm32_copystate.c lm32_createstack.c lm32_doirq.c lm32_dumpstate.c -CHIP_CSRCS += lm32_dumpstate.c lm32_exit.c lm32_idle.c lm32_initialize.c -CHIP_CSRCS += lm32_initialstate.c lm32_interruptcontext.c lm32_irq.c -CHIP_CSRCS += lm32_releasepending.c lm32_releasestack.c -CHIP_CSRCS += lm32_stackframe.c lm32_swint.c lm32_unblocktask.c +CHIP_CSRCS += lm32_copystate.c lm32_createstack.c lm32_decodeirq.c +CHIP_CSRCS += lm32_doirq.c lm32_dumpstate.c lm32_dumpstate.c lm32_exit.c +CHIP_CSRCS += lm32_idle.c lm32_initialize.c lm32_initialstate.c +CHIP_CSRCS += lm32_interruptcontext.c lm32_irq.c lm32_releasepending.c +CHIP_CSRCS += lm32_releasestack.c lm32_stackframe.c lm32_swint.c +CHIP_CSRCS += lm32_unblocktask.c diff --git a/arch/misoc/src/lm32/lm32_decodeirq.c b/arch/misoc/src/lm32/lm32_decodeirq.c new file mode 100644 index 00000000000..a532331ca3b --- /dev/null +++ b/arch/misoc/src/lm32/lm32_decodeirq.c @@ -0,0 +1,92 @@ +/******************************************************************************** + * arch/misoc/src/lm32/lm32_decodeirq.c + * + * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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. + * 3. Neither the name NuttX nor the names of its contributors may be + * 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. + * + ********************************************************************************/ + +/******************************************************************************** + * Included Files + ********************************************************************************/ + +#include + +#include "chip.h" +#include "lm32.h" + +/******************************************************************************** + * Public Functions + ********************************************************************************/ + +/**************************************************************************** + * Name: lm32_decodeirq + * + * Description: + * This function is called from the IRQ vector handler in lm32_vectors.S. + * At this point, the interrupt has been taken and the registers have + * been saved on the stack. This function simply needs to determine the + * the irq number of the interrupt and then to call lm32_doirq to dispatch + * the interrupt. + * + * Input parameters: + * regs - A pointer to the register save area on the stack. + * + ****************************************************************************/ + +uint32_t *lm32_decodeirq(uint32_t *regs) +{ + uint32_t im; + int irq; + + /* Read the interrupt acknowledge register and get the interrupt ID */ + + im = getreg32(GIC_ICCIAR); + irq = (im & GIC_ICCIAR_INTID_MASK) >> GIC_ICCIAR_INTID_SHIFT; + + irqinfo("irq=%d\n", irq); + + /* Ignore spurions IRQs. ICCIAR will report 1023 if there is no pending + * interrupt. + */ + + DEBUGASSERT(irq < NR_IRQS || irq == 1023); + if (irq < NR_IRQS) + { + /* Dispatch the interrupt */ + + regs = lm32_doirq(irq, regs); + } + + /* Write to the end-of-interrupt register */ + + putreg32(im, GIC_ICCEOIR); + return regs; +} diff --git a/arch/misoc/src/lm32/lm32_vectors.S b/arch/misoc/src/lm32/lm32_vectors.S index 70187767dd4..f672fa7fda8 100644 --- a/arch/misoc/src/lm32/lm32_vectors.S +++ b/arch/misoc/src/lm32/lm32_vectors.S @@ -112,7 +112,7 @@ _interrupt_handler: sw (sp+0), ra calli .save_all rcsr r1, IP - calli lm32_doirq + calli lm32_decodeirq bi .restore_all_and_eret nop nop