From 55318d17b40e491839c874ecbb342925c9b1e5ea Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 11 Nov 2022 16:30:09 +0100 Subject: validation: Improve spurious interrupt test case Use the tm27 support to test a spurious interrupt. This helps to run the validation test case on targets which have no software interrupt available for tests (for example riscv/PLIC/CLINT in the SMP configuration). --- testsuites/validation/tx-call-within-isr.c | 59 ++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 4 deletions(-) (limited to 'testsuites/validation/tx-call-within-isr.c') diff --git a/testsuites/validation/tx-call-within-isr.c b/testsuites/validation/tx-call-within-isr.c index 3b5d1e139d..0767f96edf 100644 --- a/testsuites/validation/tx-call-within-isr.c +++ b/testsuites/validation/tx-call-within-isr.c @@ -5,12 +5,13 @@ * * @ingroup RTEMSTestSuites * - * @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 * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -44,6 +45,7 @@ #include #include +#include /* Some target architectures need this variable for */ uint32_t Interrupt_nest; @@ -64,6 +66,16 @@ static CallWithinISRContext CallWithinISRInstance = { .pending = CHAIN_INITIALIZER_EMPTY( CallWithinISRInstance.pending ) }; +void CallWithinISRRaise( void ) +{ + Cause_tm27_intr(); +} + +void CallWithinISRClear( void ) +{ + Clear_tm27_intr(); +} + static void CallWithinISRHandler( rtems_vector_number vector ) { CallWithinISRContext *ctx; @@ -71,7 +83,7 @@ static void CallWithinISRHandler( rtems_vector_number vector ) (void) vector; ctx = &CallWithinISRInstance; - Clear_tm27_intr(); + CallWithinISRClear(); while ( true ) { rtems_interrupt_lock_context lock_context; @@ -114,7 +126,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 ) @@ -124,6 +136,45 @@ void CallWithinISRWait( const CallWithinISRRequest *request ) } } +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 == (rtems_interrupt_handler) CallWithinISRHandler ) { + *(bool *) arg = true; + } +} + +rtems_vector_number CallWithinISRGetVector( void ) +{ + 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; +} + static void CallWithinISRInitialize( void ) { Install_tm27_vector( CallWithinISRHandler ); -- cgit v1.2.3