diff options
Diffstat (limited to 'testsuites/validation/tx-support.c')
-rw-r--r-- | testsuites/validation/tx-support.c | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/testsuites/validation/tx-support.c b/testsuites/validation/tx-support.c index 2820a8c6d1..c6f66c5c5f 100644 --- a/testsuites/validation/tx-support.c +++ b/testsuites/validation/tx-support.c @@ -375,6 +375,64 @@ void WaitForExecutionStop( rtems_id task_id ) #endif } +void GetTaskTimerInfo( rtems_id id, TaskTimerInfo *info ) +{ + Thread_Control *thread; + + info->expire_ticks = 0; + info->expire_timespec.tv_sec = -1; + info->expire_timespec.tv_nsec = -1; + + thread = GetThread( id ); + + if ( thread != NULL ) { + ISR_lock_Context lock_context; + ISR_lock_Context lock_context_2; + Per_CPU_Control *cpu; + + _ISR_lock_ISR_disable_and_acquire( &thread->Timer.Lock, &lock_context ); + info->expire_ticks = thread->Timer.Watchdog.expire; +#if defined( RTEMS_SMP ) + cpu = thread->Timer.Watchdog.cpu; +#else + cpu = _Per_CPU_Get(); +#endif + _Watchdog_Per_CPU_acquire_critical( cpu, &lock_context_2 ); + + if ( _Watchdog_Is_scheduled( &thread->Timer.Watchdog ) ) { + const Watchdog_Header *hdr; + + hdr = thread->Timer.header; + + if ( hdr == &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_TICKS ] ) { + info->state = TASK_TIMER_TICKS; + } else { + _Watchdog_Ticks_to_timespec( + info->expire_ticks, + &info->expire_timespec + ); + + if ( hdr == &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_REALTIME ] ) { + info->state = TASK_TIMER_REALTIME; + } else { + T_quiet_eq_ptr( + hdr, + &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_MONOTONIC ] + ); + info->state = TASK_TIMER_MONOTONIC; + } + } + } else { + info->state = TASK_TIMER_INACTIVE; + } + + _Watchdog_Per_CPU_release_critical( cpu, &lock_context_2 ); + _ISR_lock_Release_and_ISR_enable( &thread->Timer.Lock, &lock_context ); + } else { + info->state = TASK_TIMER_INVALID; + } +} + #if defined( RTEMS_SMP ) static void DoWatchdogTick( void *arg ) { @@ -395,3 +453,74 @@ void ClockTick( void ) #endif _Thread_Dispatch_enable( cpu_self ); } + +static void FinalWatchdogTick( Per_CPU_Control *cpu ) +{ + ISR_lock_Context lock_context; + Watchdog_Header *header; + Watchdog_Control *first; + + _ISR_lock_ISR_disable_and_acquire( &cpu->Watchdog.Lock, &lock_context ); + + header = &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_TICKS ]; + first = _Watchdog_Header_first( header ); + + if ( first != NULL ) { + _Watchdog_Tickle( + header, + first, + UINT64_MAX, + &cpu->Watchdog.Lock, + &lock_context + ); + } + + header = &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_MONOTONIC ]; + first = _Watchdog_Header_first( header ); + + if ( first != NULL ) { + _Watchdog_Tickle( + header, + first, + UINT64_MAX, + &cpu->Watchdog.Lock, + &lock_context + ); + } + + header = &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_REALTIME ]; + first = _Watchdog_Header_first( header ); + + if ( first != NULL ) { + _Watchdog_Tickle( + header, + first, + UINT64_MAX, + &cpu->Watchdog.Lock, + &lock_context + ); + } + + _ISR_lock_Release_and_ISR_enable( &cpu->Watchdog.Lock, &lock_context ); +} + +#if defined( RTEMS_SMP ) +static void DoFinalWatchdogTick( void *arg ) +{ + (void) arg; + FinalWatchdogTick( _Per_CPU_Get() ); +} +#endif + +void FinalClockTick( void ) +{ + Per_CPU_Control *cpu_self; + + cpu_self = _Thread_Dispatch_disable(); +#if defined( RTEMS_SMP ) + _SMP_Broadcast_action( DoFinalWatchdogTick, NULL ); +#else + FinalWatchdogTick( cpu_self ); +#endif + _Thread_Dispatch_enable( cpu_self ); +} |