summaryrefslogtreecommitdiffstats
path: root/bsps
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-06-18 16:44:11 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-06-24 11:36:28 +0200
commitbe96cb4345554fac614b252fe8f78dbf32c3a981 (patch)
treee69c244a4e5ab5dd11bdd4c14ea2c5ef66ef6c34 /bsps
parentbsps: bsp_interrupt_handler_dispatch_unchecked() (diff)
downloadrtems-be96cb4345554fac614b252fe8f78dbf32c3a981.tar.bz2
sparc: Simplify trap table initialization
Move _ISR_Handler() to a separate file since it is now only used if a handler is installed by _CPU_ISR_install_raw_handler(). Statically initialize the traps for external interrupts to use the new _SPARC_Interrupt_trap() which directly dispatches the interrupt handlers installed by rtems_interrupt_handler_install() via the BSP-provided _SPARC_Interrupt_dispatch(). Since the trap table is now fully statically initialized, there is no longer a dependency on the Cache Manager in the default configuration. Update #4458.
Diffstat (limited to 'bsps')
-rw-r--r--bsps/sparc/erc32/include/bsp.h6
-rw-r--r--bsps/sparc/erc32/start/bspstart.c15
-rw-r--r--bsps/sparc/leon2/include/bsp.h6
-rw-r--r--bsps/sparc/leon2/start/bspstart.c2
-rw-r--r--bsps/sparc/leon3/include/bsp.h6
-rw-r--r--bsps/sparc/leon3/start/bspsmp.c24
-rw-r--r--bsps/sparc/leon3/start/bspstart.c34
-rw-r--r--bsps/sparc/shared/irq/bsp_isr_handler.c27
-rw-r--r--bsps/sparc/shared/irq/irq-shared.c21
-rw-r--r--bsps/sparc/shared/start/start.S39
10 files changed, 64 insertions, 116 deletions
diff --git a/bsps/sparc/erc32/include/bsp.h b/bsps/sparc/erc32/include/bsp.h
index 7fb2fa9d72..fd453fb6c2 100644
--- a/bsps/sparc/erc32/include/bsp.h
+++ b/bsps/sparc/erc32/include/bsp.h
@@ -95,12 +95,6 @@ void BSP_fatal_exit(uint32_t error);
/* Interrupt Service Routine (ISR) pointer */
typedef void (*bsp_shared_isr)(void *arg);
-/* Initializes the Shared System Interrupt service */
-extern void BSP_shared_interrupt_init(void);
-
-/* Called directly from IRQ trap handler TRAP[0x10..0x1F] = IRQ[0..15] */
-void bsp_isr_handler(rtems_vector_number vector);
-
/* Registers a shared IRQ handler, and enable it at IRQ controller. Multiple
* interrupt handlers may use the same IRQ number, all ISRs will be called
* when an interrupt on that line is fired.
diff --git a/bsps/sparc/erc32/start/bspstart.c b/bsps/sparc/erc32/start/bspstart.c
index d56d3b2ff2..1979c68308 100644
--- a/bsps/sparc/erc32/start/bspstart.c
+++ b/bsps/sparc/erc32/start/bspstart.c
@@ -12,22 +12,15 @@
#include <bsp.h>
#include <bsp/bootcard.h>
+#include <bsp/irq-generic.h>
#include <rtems/sysinit.h>
/*
- * Called just before drivers are initialized. Is used to initialize shared
- * interrupt handling.
+ * Initialize shared interrupt handling, must be done after IRQ controller has
+ * been found and initialized.
*/
-static void erc32_pre_driver_hook( void )
-{
- /* Initialize shared interrupt handling, must be done after IRQ
- * controller has been found and initialized.
- */
- BSP_shared_interrupt_init();
-}
-
RTEMS_SYSINIT_ITEM(
- erc32_pre_driver_hook,
+ bsp_interrupt_initialize,
RTEMS_SYSINIT_BSP_PRE_DRIVERS,
RTEMS_SYSINIT_ORDER_MIDDLE
);
diff --git a/bsps/sparc/leon2/include/bsp.h b/bsps/sparc/leon2/include/bsp.h
index bdd9c1ca70..510262206b 100644
--- a/bsps/sparc/leon2/include/bsp.h
+++ b/bsps/sparc/leon2/include/bsp.h
@@ -119,12 +119,6 @@ void BSP_fatal_exit(uint32_t error);
/* Interrupt Service Routine (ISR) pointer */
typedef void (*bsp_shared_isr)(void *arg);
-/* Initializes the Shared System Interrupt service */
-extern void BSP_shared_interrupt_init(void);
-
-/* Called directly from IRQ trap handler TRAP[0x10..0x1F] = IRQ[0..15] */
-void bsp_isr_handler(rtems_vector_number vector);
-
/* Registers a shared IRQ handler, and enable it at IRQ controller. Multiple
* interrupt handlers may use the same IRQ number, all ISRs will be called
* when an interrupt on that line is fired.
diff --git a/bsps/sparc/leon2/start/bspstart.c b/bsps/sparc/leon2/start/bspstart.c
index 8ffd0aa2e7..e90cfad5a8 100644
--- a/bsps/sparc/leon2/start/bspstart.c
+++ b/bsps/sparc/leon2/start/bspstart.c
@@ -111,7 +111,7 @@ static void leon2_pre_driver_hook( void )
/* Initialize shared interrupt handling, must be done after IRQ
* controller has been found and initialized.
*/
- BSP_shared_interrupt_init();
+ bsp_interrupt_initialize();
#ifdef RTEMS_DRVMGR_STARTUP
leon2_root_register(&leon2_bus_config, &leon2_amba_res);
diff --git a/bsps/sparc/leon3/include/bsp.h b/bsps/sparc/leon3/include/bsp.h
index 82f1f9f8ac..cb08764eae 100644
--- a/bsps/sparc/leon3/include/bsp.h
+++ b/bsps/sparc/leon3/include/bsp.h
@@ -139,12 +139,6 @@ void rtems_bsp_delay(int usecs);
/* Interrupt Service Routine (ISR) pointer */
typedef void (*bsp_shared_isr)(void *arg);
-/* Initializes the Shared System Interrupt service */
-extern void BSP_shared_interrupt_init(void);
-
-/* Called directly from IRQ trap handler TRAP[0x10..0x1F] = IRQ[0..15] */
-void bsp_isr_handler(rtems_vector_number vector);
-
/* Registers a shared IRQ handler, and enable it at IRQ controller. Multiple
* interrupt handlers may use the same IRQ number, all ISRs will be called
* when an interrupt on that line is fired.
diff --git a/bsps/sparc/leon3/start/bspsmp.c b/bsps/sparc/leon3/start/bspsmp.c
index c73c3fd5d0..f2749bfa06 100644
--- a/bsps/sparc/leon3/start/bspsmp.c
+++ b/bsps/sparc/leon3/start/bspsmp.c
@@ -18,6 +18,7 @@
#include <bsp/fatal.h>
#include <leon.h>
#include <rtems/bspIo.h>
+#include <rtems/sysinit.h>
#include <rtems/score/assert.h>
#include <rtems/score/smpimpl.h>
#include <stdlib.h>
@@ -55,13 +56,10 @@ void bsp_start_on_secondary_processor(Per_CPU_Control *cpu_self)
_SMP_Start_multitasking_on_secondary_processor(cpu_self);
}
-uint32_t _CPU_SMP_Initialize( void )
+static void leon3_install_inter_processor_interrupt( void )
{
rtems_status_code sc;
- if ( !leon3_data_cache_snooping_enabled() )
- bsp_fatal( LEON3_FATAL_INVALID_CACHE_CONFIG_MAIN_PROCESSOR );
-
sc = rtems_interrupt_handler_install(
LEON3_mp_irq,
"IPI",
@@ -70,6 +68,16 @@ uint32_t _CPU_SMP_Initialize( void )
NULL
);
_Assert_Unused_variable_equals( sc, RTEMS_SUCCESSFUL );
+}
+
+uint32_t _CPU_SMP_Initialize( void )
+{
+ if ( !leon3_data_cache_snooping_enabled() )
+ bsp_fatal( LEON3_FATAL_INVALID_CACHE_CONFIG_MAIN_PROCESSOR );
+
+#if !defined(RTEMS_DRVMGR_STARTUP)
+ leon3_install_inter_processor_interrupt();
+#endif
return leon3_get_cpu_count(LEON3_IrqCtrl_Regs);
}
@@ -102,3 +110,11 @@ void _CPU_SMP_Send_interrupt(uint32_t target_processor_index)
/* send interrupt to destination CPU */
LEON3_IrqCtrl_Regs->force[target_processor_index] = 1 << LEON3_mp_irq;
}
+
+#if defined(RTEMS_DRVMGR_STARTUP)
+RTEMS_SYSINIT_ITEM(
+ leon3_install_inter_processor_interrupt,
+ RTEMS_SYSINIT_DRVMGR_LEVEL_1,
+ RTEMS_SYSINIT_ORDER_LAST_BUT_4
+);
+#endif
diff --git a/bsps/sparc/leon3/start/bspstart.c b/bsps/sparc/leon3/start/bspstart.c
index 69ff519189..75042e4c20 100644
--- a/bsps/sparc/leon3/start/bspstart.c
+++ b/bsps/sparc/leon3/start/bspstart.c
@@ -20,6 +20,7 @@
*/
#include <bsp.h>
+#include <bsp/irq-generic.h>
#include <leon.h>
#include <bsp/bootcard.h>
#include <rtems/sysinit.h>
@@ -66,6 +67,10 @@ static inline int set_snooping(void)
void bsp_start( void )
{
CPU_SPARC_HAS_SNOOPING = set_snooping();
+
+#ifndef RTEMS_DRVMGR_STARTUP
+ bsp_interrupt_initialize();
+#endif
}
static void leon3_cpu_index_init(void)
@@ -84,38 +89,13 @@ RTEMS_SYSINIT_ITEM(
RTEMS_SYSINIT_ORDER_FIRST
);
-static void leon3_interrupt_common_init( void )
-{
- /* Initialize shared interrupt handling, must be done after IRQ
- * controller has been found and initialized.
- */
- BSP_shared_interrupt_init();
-}
-
-/*
- * Called just before drivers are initialized. Is used to initialize shared
- * interrupt handling.
- */
-static void leon3_pre_driver_hook( void )
-{
-#ifndef RTEMS_DRVMGR_STARTUP
- leon3_interrupt_common_init();
-#endif
-}
-
-RTEMS_SYSINIT_ITEM(
- leon3_pre_driver_hook,
- RTEMS_SYSINIT_BSP_PRE_DRIVERS,
- RTEMS_SYSINIT_ORDER_MIDDLE
-);
-
-#ifdef RTEMS_DRVMGR_STARTUP
/*
* Initialize shared interrupt handling, must be done after IRQ controller has
* been found and initialized.
*/
+#ifdef RTEMS_DRVMGR_STARTUP
RTEMS_SYSINIT_ITEM(
- leon3_interrupt_common_init,
+ bsp_interrupt_initialize,
RTEMS_SYSINIT_DRVMGR_LEVEL_1,
RTEMS_SYSINIT_ORDER_LAST_BUT_5
);
diff --git a/bsps/sparc/shared/irq/bsp_isr_handler.c b/bsps/sparc/shared/irq/bsp_isr_handler.c
index a4d33b0932..2616b5caae 100644
--- a/bsps/sparc/shared/irq/bsp_isr_handler.c
+++ b/bsps/sparc/shared/irq/bsp_isr_handler.c
@@ -8,28 +8,19 @@
*
*/
-#include <rtems.h>
#include <bsp.h>
#include <bsp/irq-generic.h>
-static inline void bsp_dispatch_irq(int irq)
-{
- bsp_interrupt_handler_entry *e =
- &bsp_interrupt_handler_table[bsp_interrupt_handler_index(irq)];
-
- while (e != NULL) {
- (*e->handler)(e->arg);
- e = e->next;
- }
-}
-
-/* Called directly from IRQ trap handler TRAP[0x10..0x1F] = IRQ[0..15] */
-void bsp_isr_handler(rtems_vector_number vector)
+/*
+ * This function is called directly from _SPARC_Interrupt_trap() for
+ * traps 0x10 to 0x1F which correspond to IRQ 0 to 15 respectively.
+ */
+void _SPARC_Interrupt_dispatch( uint32_t irq )
{
- int irq = vector - 0x10;
+ bsp_interrupt_assert( irq < BSP_INTERRUPT_VECTOR_COUNT );
- /* Let BSP fixup and/or handle incomming IRQ */
- irq = bsp_irq_fixup(irq);
+ /* Let BSP fixup and/or handle incoming IRQ */
+ irq = bsp_irq_fixup( irq );
- bsp_dispatch_irq(irq);
+ bsp_interrupt_handler_dispatch_unchecked( irq );
}
diff --git a/bsps/sparc/shared/irq/irq-shared.c b/bsps/sparc/shared/irq/irq-shared.c
index e0ac7d7f06..a127ab64c2 100644
--- a/bsps/sparc/shared/irq/irq-shared.c
+++ b/bsps/sparc/shared/irq/irq-shared.c
@@ -37,27 +37,6 @@ static inline int bsp_irq_cpu(int irq)
}
#endif
-/* Initialize interrupts */
-void BSP_shared_interrupt_init(void)
-{
- rtems_vector_number vector;
- rtems_isr_entry previous_isr;
- int i;
-
- for (i=0; i <= BSP_INTERRUPT_VECTOR_MAX_STD; i++) {
-#if defined(LEON3) && (defined(RTEMS_SMP) || defined(RTEMS_MULTIPROCESSING))
- /* Don't install IRQ handler on IPI interrupt */
- if (i == LEON3_mp_irq)
- continue;
-#endif
- vector = SPARC_ASYNCHRONOUS_TRAP(i) + 0x10;
- rtems_interrupt_catch(bsp_isr_handler, vector, &previous_isr);
- }
-
- /* Initalize interrupt support */
- bsp_interrupt_initialize();
-}
-
/* Callback from bsp_interrupt_initialize() */
rtems_status_code bsp_interrupt_facility_initialize(void)
{
diff --git a/bsps/sparc/shared/start/start.S b/bsps/sparc/shared/start/start.S
index cd43f08f01..45bd145d4a 100644
--- a/bsps/sparc/shared/start/start.S
+++ b/bsps/sparc/shared/start/start.S
@@ -33,6 +33,13 @@
TRAP(_vector, _SPARC_Bad_trap)
/*
+ * External interrupt trap
+ */
+#define ISR_TRAP(_vector) \
+ TRAP_SYM(_vector):; \
+ TRAP(_vector - 0x10, _SPARC_Interrupt_trap)
+
+/*
* System call optimized trap table entry
*/
#define FPDIS_TRAP(_handler) \
@@ -128,27 +135,27 @@ TRAP_SYM(0x06):
BAD_TRAP(0x0d) ! 0D undefined
BAD_TRAP(0x0e) ! 0E undefined
BAD_TRAP(0x0f) ! 0F undefined
- BAD_TRAP(0x10) ! 10 undefined
/*
* External interrupt traps
*/
- BAD_TRAP(0x11) ! 11 external interrupt 1
- BAD_TRAP(0x12) ! 12 external interrupt 2
- BAD_TRAP(0x13) ! 13 external interrupt 3
- BAD_TRAP(0x14) ! 14 external interrupt 4
- BAD_TRAP(0x15) ! 15 external interrupt 5
- BAD_TRAP(0x16) ! 16 external interrupt 6
- BAD_TRAP(0x17) ! 17 external interrupt 7
- BAD_TRAP(0x18) ! 18 external interrupt 8
- BAD_TRAP(0x19) ! 19 external interrupt 9
- BAD_TRAP(0x1a) ! 1A external interrupt 10
- BAD_TRAP(0x1b) ! 1B external interrupt 11
- BAD_TRAP(0x1c) ! 1C external interrupt 12
- BAD_TRAP(0x1d) ! 1D external interrupt 13
- BAD_TRAP(0x1e) ! 1E external interrupt 14
- BAD_TRAP(0x1f) ! 1F external interrupt 15
+ ISR_TRAP(0x10) ! 10 undefined
+ ISR_TRAP(0x11) ! 11 external interrupt 1
+ ISR_TRAP(0x12) ! 12 external interrupt 2
+ ISR_TRAP(0x13) ! 13 external interrupt 3
+ ISR_TRAP(0x14) ! 14 external interrupt 4
+ ISR_TRAP(0x15) ! 15 external interrupt 5
+ ISR_TRAP(0x16) ! 16 external interrupt 6
+ ISR_TRAP(0x17) ! 17 external interrupt 7
+ ISR_TRAP(0x18) ! 18 external interrupt 8
+ ISR_TRAP(0x19) ! 19 external interrupt 9
+ ISR_TRAP(0x1a) ! 1A external interrupt 10
+ ISR_TRAP(0x1b) ! 1B external interrupt 11
+ ISR_TRAP(0x1c) ! 1C external interrupt 12
+ ISR_TRAP(0x1d) ! 1D external interrupt 13
+ ISR_TRAP(0x1e) ! 1E external interrupt 14
+ ISR_TRAP(0x1f) ! 1F external interrupt 15
BAD_TRAP(0x20) ! 20 undefined
BAD_TRAP(0x21) ! 21 undefined