diff options
Diffstat (limited to 'testsuites/validation/tx-call-within-isr.c')
-rw-r--r-- | testsuites/validation/tx-call-within-isr.c | 106 |
1 files changed, 100 insertions, 6 deletions
diff --git a/testsuites/validation/tx-call-within-isr.c b/testsuites/validation/tx-call-within-isr.c index 226647c0bc..8bbe0e7c29 100644 --- a/testsuites/validation/tx-call-within-isr.c +++ b/testsuites/validation/tx-call-within-isr.c @@ -3,14 +3,15 @@ /** * @file * - * @ingroup RTEMSTestSuites + * @ingroup RTEMSTestSuitesValidation * - * @brief This source file contains the implementation of CallWithinISR(), + * @brief This source file contains the implementation of CallWithinISRClear(), + * CallWithinISRGetVector(), CallWithinISR(), CallWithinISRRaise(), * CallWithinISRSubmit(), and CallWithinISRWait(). */ /* - * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2021, 2022 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -44,6 +45,7 @@ #include <rtems/score/chainimpl.h> #include <bsp.h> +#include <bsp/irq-generic.h> /* Some target architectures need this variable for <tm27.h> */ uint32_t Interrupt_nest; @@ -64,13 +66,29 @@ static CallWithinISRContext CallWithinISRInstance = { .pending = CHAIN_INITIALIZER_EMPTY( CallWithinISRInstance.pending ) }; -static void CallWithinISRHandler( rtems_vector_number vector ) +void CallWithinISRRaise( void ) +{ + Cause_tm27_intr(); +} + +void CallWithinISRClear( void ) +{ + Clear_tm27_intr(); +} + +#ifdef TM27_USE_VECTOR_HANDLER +static rtems_isr CallWithinISRHandler( rtems_vector_number arg ) +#else +static void CallWithinISRHandler( void *arg ) +#endif { CallWithinISRContext *ctx; - (void) vector; + (void) arg; ctx = &CallWithinISRInstance; + CallWithinISRClear(); + while ( true ) { rtems_interrupt_lock_context lock_context; CallWithinISRRequest *request; @@ -112,7 +130,7 @@ void CallWithinISRSubmit( CallWithinISRRequest *request ) _Chain_Append_unprotected( &ctx->pending, &request->node ); rtems_interrupt_lock_release( &ctx->lock, &lock_context ); - Cause_tm27_intr(); + CallWithinISRRaise(); } void CallWithinISRWait( const CallWithinISRRequest *request ) @@ -122,6 +140,82 @@ void CallWithinISRWait( const CallWithinISRRequest *request ) } } +#if !defined( TM27_INTERRUPT_VECTOR_DEFAULT ) +static void CallWithinISRIsHandlerInstalled( + void *arg, + const char *info, + rtems_option option, + rtems_interrupt_handler handler, + void *handler_arg +) +{ + (void) info; + (void) option; + (void) handler_arg; + + if ( handler == CallWithinISRHandler && handler_arg == NULL ) { + *(bool *) arg = true; + } +} +#endif + +rtems_vector_number CallWithinISRGetVector( void ) +{ +#if defined( TM27_INTERRUPT_VECTOR_DEFAULT ) + return TM27_INTERRUPT_VECTOR_DEFAULT; +#else + rtems_vector_number vector; + + for ( vector = 0; vector < BSP_INTERRUPT_VECTOR_COUNT; ++vector ) { + bool installed; + + installed = false; + (void) rtems_interrupt_handler_iterate( + vector, + CallWithinISRIsHandlerInstalled, + &installed + ); + + if ( installed ) { + return vector; + } + } + + return UINT32_MAX; +#endif +} + +rtems_vector_number GetSoftwareInterruptVector( void ) +{ +#if defined( TM27_INTERRUPT_VECTOR_ALTERNATIVE ) + return TM27_INTERRUPT_VECTOR_ALTERNATIVE; +#else + return UINT32_MAX; +#endif +} + +rtems_status_code RaiseSoftwareInterrupt( rtems_vector_number vector ) +{ +#if defined( TM27_INTERRUPT_VECTOR_ALTERNATIVE ) + if ( vector == TM27_INTERRUPT_VECTOR_ALTERNATIVE ) { + return _TM27_Raise_alternative(); + } +#endif + + return rtems_interrupt_raise( vector ); +} + +rtems_status_code ClearSoftwareInterrupt( rtems_vector_number vector ) +{ +#if defined( TM27_INTERRUPT_VECTOR_ALTERNATIVE ) + if ( vector == TM27_INTERRUPT_VECTOR_ALTERNATIVE ) { + return _TM27_Clear_alternative(); + } +#endif + + return rtems_interrupt_clear( vector ); +} + static void CallWithinISRInitialize( void ) { Install_tm27_vector( CallWithinISRHandler ); |