[PATCH 2/4] sparc: Add SPARC_IS_INTERRUPT_TRAP()
Sebastian Huber
sebastian.huber at embedded-brains.de
Thu Nov 5 15:09:02 UTC 2020
Update #4171.
---
bsps/sparc/erc32/include/erc32.h | 4 +---
bsps/sparc/erc32/start/setvec.c | 9 +++------
bsps/sparc/leon2/include/leon.h | 4 +---
bsps/sparc/leon2/start/setvec.c | 9 +++------
bsps/sparc/leon3/include/leon.h | 4 +---
bsps/sparc/leon3/start/setvec.c | 9 +++------
cpukit/score/cpu/sparc/include/rtems/score/sparc.h | 14 ++++++++++++++
7 files changed, 26 insertions(+), 27 deletions(-)
diff --git a/bsps/sparc/erc32/include/erc32.h b/bsps/sparc/erc32/include/erc32.h
index 7db4a6c91b..2d278fc669 100644
--- a/bsps/sparc/erc32/include/erc32.h
+++ b/bsps/sparc/erc32/include/erc32.h
@@ -87,9 +87,7 @@ extern "C" {
#define ERC32_TRAP_SOURCE( _trap ) ((_trap) - 0x10)
-#define ERC32_Is_MEC_Trap( _trap ) \
- ( (_trap) >= ERC32_TRAP_TYPE( ERC32_INTERRUPT_MASKED_ERRORS ) && \
- (_trap) <= ERC32_TRAP_TYPE( ERC32_INTERRUPT_WATCHDOG_TIMEOUT ) )
+#define ERC32_Is_MEC_Trap( _trap ) SPARC_IS_INTERRUPT_TRAP( _trap )
/*
* Structure for ERC32 memory mapped registers.
diff --git a/bsps/sparc/erc32/start/setvec.c b/bsps/sparc/erc32/start/setvec.c
index 0200f422a1..73bcc99083 100644
--- a/bsps/sparc/erc32/start/setvec.c
+++ b/bsps/sparc/erc32/start/setvec.c
@@ -37,8 +37,6 @@ rtems_isr_entry set_vector( /* returns old vector */
)
{
rtems_isr_entry previous_isr;
- uint32_t real_trap;
- uint32_t source;
if ( type ) {
rtems_interrupt_catch( handler, vector, &previous_isr );
@@ -50,11 +48,10 @@ rtems_isr_entry set_vector( /* returns old vector */
);
}
- real_trap = SPARC_REAL_TRAP_NUMBER( vector );
+ if ( SPARC_IS_INTERRUPT_TRAP( vector ) ) {
+ uint32_t source;
- if ( ERC32_Is_MEC_Trap( real_trap ) ) {
-
- source = ERC32_TRAP_SOURCE( real_trap );
+ source = ERC32_TRAP_SOURCE( SPARC_REAL_TRAP_NUMBER( vector ) );
ERC32_Clear_interrupt( source );
ERC32_Unmask_interrupt( source );
diff --git a/bsps/sparc/leon2/include/leon.h b/bsps/sparc/leon2/include/leon.h
index 2b3379f713..49af3086ed 100644
--- a/bsps/sparc/leon2/include/leon.h
+++ b/bsps/sparc/leon2/include/leon.h
@@ -84,9 +84,7 @@ extern "C" {
#define LEON_TRAP_SOURCE( _trap ) ((_trap) - 0x10)
-#define LEON_INT_TRAP( _trap ) \
- ( (_trap) >= LEON_TRAP_TYPE( LEON_INTERRUPT_CORRECTABLE_MEMORY_ERROR ) && \
- (_trap) <= LEON_TRAP_TYPE( LEON_INTERRUPT_EMPTY6 ) )
+#define LEON_INT_TRAP( _trap ) SPARC_IS_INTERRUPT_TRAP( _trap )
/*
* Structure for LEON memory mapped registers.
diff --git a/bsps/sparc/leon2/start/setvec.c b/bsps/sparc/leon2/start/setvec.c
index 3e4120611d..51647e3ee4 100644
--- a/bsps/sparc/leon2/start/setvec.c
+++ b/bsps/sparc/leon2/start/setvec.c
@@ -43,19 +43,16 @@ rtems_isr_entry set_vector( /* returns old vector */
)
{
rtems_isr_entry previous_isr;
- uint32_t real_trap;
- uint32_t source;
if ( type )
rtems_interrupt_catch( handler, vector, &previous_isr );
else
_CPU_ISR_install_raw_handler( vector, handler, (void *)&previous_isr );
- real_trap = SPARC_REAL_TRAP_NUMBER( vector );
+ if ( SPARC_IS_INTERRUPT_TRAP( vector ) ) {
+ uint32_t source;
- if ( LEON_INT_TRAP( real_trap ) ) {
-
- source = LEON_TRAP_SOURCE( real_trap );
+ source = LEON_TRAP_SOURCE( SPARC_REAL_TRAP_NUMBER( vector ) );
LEON_Clear_interrupt( source );
LEON_Unmask_interrupt( source );
diff --git a/bsps/sparc/leon3/include/leon.h b/bsps/sparc/leon3/include/leon.h
index f70fae5709..5ab0d45125 100644
--- a/bsps/sparc/leon3/include/leon.h
+++ b/bsps/sparc/leon3/include/leon.h
@@ -46,9 +46,7 @@ extern "C" {
#define LEON_TRAP_SOURCE( _trap ) ((_trap) - 0x10)
-#define LEON_INT_TRAP( _trap ) \
- ( (_trap) >= 0x11 && \
- (_trap) <= 0x1F )
+#define LEON_INT_TRAP( _trap ) SPARC_IS_INTERRUPT_TRAP( _trap )
/* /\* */
/* * This is used to manipulate the on-chip registers. */
diff --git a/bsps/sparc/leon3/start/setvec.c b/bsps/sparc/leon3/start/setvec.c
index 5b5888d51a..987e505c35 100644
--- a/bsps/sparc/leon3/start/setvec.c
+++ b/bsps/sparc/leon3/start/setvec.c
@@ -42,19 +42,16 @@ rtems_isr_entry set_vector( /* returns old vector */
)
{
rtems_isr_entry previous_isr;
- uint32_t real_trap;
- uint32_t source;
if ( type )
rtems_interrupt_catch( handler, vector, &previous_isr );
else
_CPU_ISR_install_raw_handler( vector, handler, (void *)&previous_isr );
- real_trap = SPARC_REAL_TRAP_NUMBER( vector );
+ if ( SPARC_IS_INTERRUPT_TRAP( vector ) ) {
+ uint32_t source;
- if ( LEON_INT_TRAP( real_trap ) ) {
-
- source = LEON_TRAP_SOURCE( real_trap );
+ source = LEON_TRAP_SOURCE( SPARC_REAL_TRAP_NUMBER( vector ) );
LEON_Clear_interrupt( source );
LEON_Unmask_interrupt( source );
diff --git a/cpukit/score/cpu/sparc/include/rtems/score/sparc.h b/cpukit/score/cpu/sparc/include/rtems/score/sparc.h
index 7e127f1fd5..c2b6aeea6b 100644
--- a/cpukit/score/cpu/sparc/include/rtems/score/sparc.h
+++ b/cpukit/score/cpu/sparc/include/rtems/score/sparc.h
@@ -197,6 +197,20 @@ extern "C" {
*/
#define SPARC_REAL_TRAP_NUMBER( _trap ) ( ( _trap ) % 256 )
+/**
+ * @brief Returns true, if the specified real hardware vector number,
+ * synchronous trap number, or asynchronous trap number is an interrupt trap.
+ *
+ * Interrupt traps are defined by Table 7-1 "Exception and Interrupt Request
+ * Priority and tt Values" in "The SPARC Architecture Manual: Version 8".
+ *
+ * @brief _trap is the real hardware vector number, synchronous trap number, or
+ * asynchronous trap number to check.
+ */
+#define SPARC_IS_INTERRUPT_TRAP( _trap ) \
+ ( SPARC_REAL_TRAP_NUMBER( _trap ) >= 0x11 \
+ && SPARC_REAL_TRAP_NUMBER( _trap) <= 0x1f )
+
#ifndef ASM
/**
--
2.26.2
More information about the devel
mailing list