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.
This commit is contained in:
Sebastian Huber
2021-06-18 16:44:11 +02:00
parent 005c79beb9
commit be96cb4345
15 changed files with 705 additions and 171 deletions

View File

@@ -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.

View File

@@ -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
);

View File

@@ -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.

View File

@@ -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);

View File

@@ -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.

View File

@@ -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

View File

@@ -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
);

View File

@@ -8,28 +8,19 @@
*
*/
#include <rtems.h>
#include <bsp.h>
#include <bsp/irq-generic.h>
static inline void bsp_dispatch_irq(int irq)
/*
* 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 )
{
bsp_interrupt_handler_entry *e =
&bsp_interrupt_handler_table[bsp_interrupt_handler_index(irq)];
bsp_interrupt_assert( irq < BSP_INTERRUPT_VECTOR_COUNT );
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)
{
int irq = vector - 0x10;
/* Let BSP fixup and/or handle incomming IRQ */
irq = bsp_irq_fixup(irq);
bsp_dispatch_irq(irq);
/* Let BSP fixup and/or handle incoming IRQ */
irq = bsp_irq_fixup( irq );
bsp_interrupt_handler_dispatch_unchecked( irq );
}

View File

@@ -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)
{

View File

@@ -32,6 +32,13 @@
TRAP_SYM(_vector):; \
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
*/
@@ -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