Separate the probing of the interrupt controller from the initialization. --- bsps/sparc/leon3/include/bsp/leon3.h | 82 ++++++++++++++++++++++++++++ bsps/sparc/leon3/include/leon.h | 10 +--- bsps/sparc/leon3/start/amba.c | 9 --- bsps/sparc/leon3/start/eirq.c | 15 ++++- 4 files changed, 95 insertions(+), 21 deletions(-) create mode 100644 bsps/sparc/leon3/include/bsp/leon3.h
diff --git a/bsps/sparc/leon3/include/bsp/leon3.h b/bsps/sparc/leon3/include/bsp/leon3.h new file mode 100644 index 0000000000..c0105e02f0 --- /dev/null +++ b/bsps/sparc/leon3/include/bsp/leon3.h @@ -0,0 +1,82 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup sparc_leon3 + * + * @brief This header file provides interfaces used by the BSP implementation. + */ + +/* + * Copyright (C) 2021 embedded brains GmbH & Co. KG + * + * 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. + * + * 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. + */ + +#ifndef _BSP_LEON3_H +#define _BSP_LEON3_H + +#include <rtems.h> +#include <grlib/grlib.h> + +struct ambapp_dev; + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup sparc_leon3 + * + * @{ + */ + +/** + * @brief This lock serializes the interrupt controller access. + */ +extern rtems_interrupt_lock LEON3_IrqCtrl_Lock; + +/** + * @brief This pointer provides the IRQ(A)MP register block address. + */ +extern volatile struct irqmp_regs *LEON3_IrqCtrl_Regs; + +/** + * @brief This pointer provides the IRQ(A)MP device information block. + */ +extern struct ambapp_dev *LEON3_IrqCtrl_Adev; + +/** + * @brief Initializes the interrupt controller for the boot processor. + * + * @param[in, out] regs is the IRQ(A)MP register block address. + */ +void leon3_ext_irq_init( volatile struct irqmp_regs *regs ); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* _BSP_LEON3_H */ diff --git a/bsps/sparc/leon3/include/leon.h b/bsps/sparc/leon3/include/leon.h index 6294feb8a7..0623eaa4ff 100644 --- a/bsps/sparc/leon3/include/leon.h +++ b/bsps/sparc/leon3/include/leon.h @@ -44,6 +44,7 @@ #include <rtems.h> #include <amba.h> +#include <bsp/leon3.h> #ifdef __cplusplus extern "C" { @@ -146,10 +147,6 @@ extern "C" { #define LEON3_REG_CACHE_CTRL_FI 0x00200000 /* Flush instruction cache */ #define LEON3_REG_CACHE_CTRL_DS 0x00800000 /* Data cache snooping */ -/* LEON3 Interrupt Controller */ -extern volatile struct irqmp_regs *LEON3_IrqCtrl_Regs; -extern struct ambapp_dev *LEON3_IrqCtrl_Adev; - /* LEON3 GP Timer */ extern volatile struct gptimer_regs *LEON3_Timer_Regs; extern struct ambapp_dev *LEON3_Timer_Adev; @@ -193,8 +190,6 @@ static __inline__ int bsp_irq_fixup(int irq) * store the result back are vulnerable. */ -extern rtems_interrupt_lock LEON3_IrqCtrl_Lock; - #define LEON3_IRQCTRL_ACQUIRE( _lock_context ) \ rtems_interrupt_lock_acquire( &LEON3_IrqCtrl_Lock, _lock_context ) @@ -410,9 +405,6 @@ extern int leon3_timer_core_index; */ extern unsigned int leon3_timer_prescaler; -/* GRLIB extended IRQ controller register */ -void leon3_ext_irq_init(void); - RTEMS_NO_RETURN void leon3_power_down_loop(void); static inline uint32_t leon3_get_cpu_count( diff --git a/bsps/sparc/leon3/start/amba.c b/bsps/sparc/leon3/start/amba.c index 15b72dcbe8..5ce3de6bdd 100644 --- a/bsps/sparc/leon3/start/amba.c +++ b/bsps/sparc/leon3/start/amba.c @@ -115,9 +115,6 @@ RTEMS_SYSINIT_ITEM( ); #endif -rtems_interrupt_lock LEON3_IrqCtrl_Lock = - RTEMS_INTERRUPT_LOCK_INITIALIZER("LEON3 IrqCtrl"); - /* Pointers to Interrupt Controller configuration registers */ volatile struct irqmp_regs *LEON3_IrqCtrl_Regs; struct ambapp_dev *LEON3_IrqCtrl_Adev; @@ -166,12 +163,6 @@ static void amba_initialize(void) icsel = (icsel >> ((7 - (LEON3_Cpu_Index & 0x7)) * 4)) & 0xf; LEON3_IrqCtrl_Regs += icsel; } - LEON3_IrqCtrl_Regs->mask[LEON3_Cpu_Index] = 0; - LEON3_IrqCtrl_Regs->force[LEON3_Cpu_Index] = 0; - LEON3_IrqCtrl_Regs->iclear = 0xffffffff; - - /* Init Extended IRQ controller if available */ - leon3_ext_irq_init(); /* find GP Timer */ adev = (void *)ambapp_for_each(plb, (OPTIONS_ALL|OPTIONS_APB_SLVS), diff --git a/bsps/sparc/leon3/start/eirq.c b/bsps/sparc/leon3/start/eirq.c index d8ff6d2a82..0371cfe98f 100644 --- a/bsps/sparc/leon3/start/eirq.c +++ b/bsps/sparc/leon3/start/eirq.c @@ -38,12 +38,19 @@ /* GRLIB extended IRQ controller IRQ number */ int LEON3_IrqCtrl_EIrq = -1; +rtems_interrupt_lock LEON3_IrqCtrl_Lock = + RTEMS_INTERRUPT_LOCK_INITIALIZER("LEON3 IrqCtrl"); + /* Initialize Extended Interrupt controller */ -void leon3_ext_irq_init(void) +void leon3_ext_irq_init(volatile struct irqmp_regs *regs) { - if ( (LEON3_IrqCtrl_Regs->mpstat >> 16) & 0xf ) { + regs->mask[LEON3_Cpu_Index] = 0; + regs->force[LEON3_Cpu_Index] = 0; + regs->iclear = 0xffffffff; + + if ( (regs->mpstat >> 16) & 0xf ) { /* Extended IRQ controller available */ - LEON3_IrqCtrl_EIrq = (LEON3_IrqCtrl_Regs->mpstat >> 16) & 0xf; + LEON3_IrqCtrl_EIrq = (regs->mpstat >> 16) & 0xf; } } @@ -76,6 +83,8 @@ void bsp_interrupt_facility_initialize(void) leon3_interrupt_affinities[i] = affinity; } #endif + + leon3_ext_irq_init(LEON3_IrqCtrl_Regs); } rtems_status_code bsp_interrupt_get_attributes( -- 2.35.3 _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel