diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-12-12 11:01:54 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-12-15 09:48:35 +0100 |
commit | 654e0b02f56b52dab32b263e09b9d8d53d2c61c8 (patch) | |
tree | 23f0f20e3b2adf86a100f563fb8208e393f40e2b | |
parent | f8d32c543cdbfe056fcce13e5d6e59bba03b8ac7 (diff) |
score: Pass the CPU to watchdog routine
This is useful for periodic watchdogs.
-rw-r--r-- | cpukit/include/rtems/posix/pthreadimpl.h | 5 | ||||
-rw-r--r-- | cpukit/include/rtems/posix/timerimpl.h | 5 | ||||
-rw-r--r-- | cpukit/include/rtems/rtems/ratemonimpl.h | 5 | ||||
-rw-r--r-- | cpukit/include/rtems/rtems/timerimpl.h | 10 | ||||
-rw-r--r-- | cpukit/include/rtems/score/threadimpl.h | 3 | ||||
-rw-r--r-- | cpukit/include/rtems/score/watchdog.h | 6 | ||||
-rw-r--r-- | cpukit/posix/src/alarm.c | 5 | ||||
-rw-r--r-- | cpukit/posix/src/pthreadcreate.c | 7 | ||||
-rw-r--r-- | cpukit/posix/src/timersettime.c | 8 | ||||
-rw-r--r-- | cpukit/posix/src/ualarm.c | 7 | ||||
-rw-r--r-- | cpukit/rtems/src/ratemontimeout.c | 5 | ||||
-rw-r--r-- | cpukit/rtems/src/timercreate.c | 9 | ||||
-rw-r--r-- | cpukit/rtems/src/timerserver.c | 7 | ||||
-rw-r--r-- | cpukit/score/src/threadtimeout.c | 3 | ||||
-rw-r--r-- | cpukit/score/src/watchdogtick.c | 2 | ||||
-rw-r--r-- | testsuites/sptests/spintrcritical08/init.c | 2 | ||||
-rw-r--r-- | testsuites/sptests/spintrcritical09/init.c | 2 | ||||
-rw-r--r-- | testsuites/sptests/spintrcritical10/init.c | 6 | ||||
-rw-r--r-- | testsuites/sptests/spintrcritical16/init.c | 2 | ||||
-rw-r--r-- | testsuites/sptests/spintrcritical20/init.c | 2 | ||||
-rw-r--r-- | testsuites/sptests/spwatchdog/init.c | 11 |
21 files changed, 74 insertions, 38 deletions
diff --git a/cpukit/include/rtems/posix/pthreadimpl.h b/cpukit/include/rtems/posix/pthreadimpl.h index abb4d0f942..968c15baf1 100644 --- a/cpukit/include/rtems/posix/pthreadimpl.h +++ b/cpukit/include/rtems/posix/pthreadimpl.h @@ -59,7 +59,10 @@ RTEMS_INLINE_ROUTINE void _POSIX_Threads_Sporadic_timer_insert( } #endif -void _POSIX_Threads_Sporadic_timer( Watchdog_Control *watchdog ); +void _POSIX_Threads_Sporadic_timer( + Watchdog_Control *watchdog, + Per_CPU_Control *cpu +); /** * @brief POSIX threads sporadic budget callout. diff --git a/cpukit/include/rtems/posix/timerimpl.h b/cpukit/include/rtems/posix/timerimpl.h index 2b4eec1e24..2c1e7c3ada 100644 --- a/cpukit/include/rtems/posix/timerimpl.h +++ b/cpukit/include/rtems/posix/timerimpl.h @@ -75,7 +75,10 @@ RTEMS_INLINE_ROUTINE void _POSIX_Timer_Free ( _Objects_Free( &_POSIX_Timer_Information, &the_timer->Object ); } -void _POSIX_Timer_TSR( Watchdog_Control *the_watchdog ); +void _POSIX_Timer_TSR( + Watchdog_Control *the_watchdog, + Per_CPU_Control *cpu +); /** * @brief POSIX Timer Get diff --git a/cpukit/include/rtems/rtems/ratemonimpl.h b/cpukit/include/rtems/rtems/ratemonimpl.h index eb359b17c8..d2a1f8083d 100644 --- a/cpukit/include/rtems/rtems/ratemonimpl.h +++ b/cpukit/include/rtems/rtems/ratemonimpl.h @@ -86,7 +86,10 @@ RTEMS_INLINE_ROUTINE Rate_monotonic_Control *_Rate_monotonic_Get( _Objects_Get( id, lock_context, &_Rate_monotonic_Information ); } -void _Rate_monotonic_Timeout( Watchdog_Control *watchdog ); +void _Rate_monotonic_Timeout( + Watchdog_Control *the_watchdog, + Per_CPU_Control *cpu +); /** * @brief _Rate_monotonic_Get_status( diff --git a/cpukit/include/rtems/rtems/timerimpl.h b/cpukit/include/rtems/rtems/timerimpl.h index 59b2b9f816..b5e435a6e6 100644 --- a/cpukit/include/rtems/rtems/timerimpl.h +++ b/cpukit/include/rtems/rtems/timerimpl.h @@ -173,9 +173,15 @@ rtems_status_code _Timer_Fire_when( void _Timer_Cancel( Per_CPU_Control *cpu, Timer_Control *the_timer ); -void _Timer_Routine_adaptor( Watchdog_Control *the_watchdog ); +void _Timer_Routine_adaptor( + Watchdog_Control *the_watchdog, + Per_CPU_Control *cpu +); -void _Timer_server_Routine_adaptor( Watchdog_Control *the_watchdog ); +void _Timer_server_Routine_adaptor( + Watchdog_Control *the_watchdog, + Per_CPU_Control *cpu +); RTEMS_INLINE_ROUTINE void _Timer_server_Acquire_critical( Timer_server_Control *timer_server, diff --git a/cpukit/include/rtems/score/threadimpl.h b/cpukit/include/rtems/score/threadimpl.h index d3e69ed91c..265c0d92cc 100644 --- a/cpukit/include/rtems/score/threadimpl.h +++ b/cpukit/include/rtems/score/threadimpl.h @@ -1833,8 +1833,9 @@ void _Thread_Continue( Thread_Control *the_thread, Status_Control status ); * @brief General purpose thread wait timeout. * * @param[in] the_watchdog The thread timer watchdog. + * @param[in] cpu The CPU of the watchdog. */ -void _Thread_Timeout( Watchdog_Control *the_watchdog ); +void _Thread_Timeout( Watchdog_Control *the_watchdog, Per_CPU_Control *cpu ); RTEMS_INLINE_ROUTINE void _Thread_Timer_initialize( Thread_Timer_information *timer, diff --git a/cpukit/include/rtems/score/watchdog.h b/cpukit/include/rtems/score/watchdog.h index 9db87adae8..99d44ed4cb 100644 --- a/cpukit/include/rtems/score/watchdog.h +++ b/cpukit/include/rtems/score/watchdog.h @@ -59,8 +59,10 @@ typedef void Watchdog_Service_routine; * * This type define a pointer to a watchdog service routine. */ -typedef Watchdog_Service_routine - ( *Watchdog_Service_routine_entry )( Watchdog_Control * ); +typedef Watchdog_Service_routine ( *Watchdog_Service_routine_entry )( + Watchdog_Control *, + struct Per_CPU_Control * +); /** * @brief The watchdog header to manage scheduled watchdogs. diff --git a/cpukit/posix/src/alarm.c b/cpukit/posix/src/alarm.c index bbfc96d31d..cf50301aa9 100644 --- a/cpukit/posix/src/alarm.c +++ b/cpukit/posix/src/alarm.c @@ -29,7 +29,10 @@ ISR_LOCK_DEFINE( static, _POSIX_signals_Alarm_lock, "POSIX Alarm" ) -static void _POSIX_signals_Alarm_TSR( Watchdog_Control *the_watchdog ) +static void _POSIX_signals_Alarm_TSR( + Watchdog_Control *the_watchdog, + Per_CPU_Control *cpu +) { int status; diff --git a/cpukit/posix/src/pthreadcreate.c b/cpukit/posix/src/pthreadcreate.c index b70be00217..cdf500c9f7 100644 --- a/cpukit/posix/src/pthreadcreate.c +++ b/cpukit/posix/src/pthreadcreate.c @@ -272,7 +272,7 @@ int pthread_create( the_attr->schedparam.sched_ss_max_repl; if ( schedpolicy == SCHED_SPORADIC ) { - _POSIX_Threads_Sporadic_timer( &api->Sporadic.Timer ); + _POSIX_Threads_Sporadic_timer( &api->Sporadic.Timer, NULL ); } #endif @@ -306,7 +306,10 @@ int pthread_create( } #if defined(RTEMS_POSIX_API) -void _POSIX_Threads_Sporadic_timer( Watchdog_Control *watchdog ) +void _POSIX_Threads_Sporadic_timer( + Watchdog_Control *watchdog, + Per_CPU_Control *cpu +) { POSIX_API_Control *api; Thread_Control *the_thread; diff --git a/cpukit/posix/src/timersettime.c b/cpukit/posix/src/timersettime.c index 9212e49740..5a16289614 100644 --- a/cpukit/posix/src/timersettime.c +++ b/cpukit/posix/src/timersettime.c @@ -51,15 +51,17 @@ static void _POSIX_Timer_Insert( /* * This is the operation that is run when a timer expires */ -void _POSIX_Timer_TSR( Watchdog_Control *the_watchdog ) +void _POSIX_Timer_TSR( + Watchdog_Control *the_watchdog, + Per_CPU_Control *cpu +) { POSIX_Timer_Control *ptimer; ISR_lock_Context lock_context; - Per_CPU_Control *cpu; ptimer = RTEMS_CONTAINER_OF( the_watchdog, POSIX_Timer_Control, Timer ); _ISR_lock_ISR_disable( &lock_context ); - cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context ); + _POSIX_Timer_Acquire_critical( ptimer, &lock_context ); /* Increment the number of expirations. */ ptimer->overrun = ptimer->overrun + 1; diff --git a/cpukit/posix/src/ualarm.c b/cpukit/posix/src/ualarm.c index 371a961c94..972e9d3880 100644 --- a/cpukit/posix/src/ualarm.c +++ b/cpukit/posix/src/ualarm.c @@ -29,7 +29,10 @@ ISR_LOCK_DEFINE( static, _POSIX_signals_Ualarm_lock, "POSIX Ualarm" ) static uint32_t _POSIX_signals_Ualarm_interval; -static void _POSIX_signals_Ualarm_TSR( Watchdog_Control *the_watchdog ) +static void _POSIX_signals_Ualarm_TSR( + Watchdog_Control *the_watchdog, + Per_CPU_Control *cpu +) { int status; ISR_lock_Context lock_context; @@ -57,7 +60,7 @@ static void _POSIX_signals_Ualarm_TSR( Watchdog_Control *the_watchdog ) if ( _POSIX_signals_Ualarm_interval != 0 ) { _Watchdog_Per_CPU_insert_ticks( the_watchdog, - _Per_CPU_Get(), + cpu, _POSIX_signals_Ualarm_interval ); } diff --git a/cpukit/rtems/src/ratemontimeout.c b/cpukit/rtems/src/ratemontimeout.c index e2593f58b8..07549c4492 100644 --- a/cpukit/rtems/src/ratemontimeout.c +++ b/cpukit/rtems/src/ratemontimeout.c @@ -46,7 +46,10 @@ static void _Rate_monotonic_Renew_deadline( _Rate_monotonic_Release( the_period, lock_context ); } -void _Rate_monotonic_Timeout( Watchdog_Control *the_watchdog ) +void _Rate_monotonic_Timeout( + Watchdog_Control *the_watchdog, + Per_CPU_Control *cpu +) { Rate_monotonic_Control *the_period; Thread_Control *owner; diff --git a/cpukit/rtems/src/timercreate.c b/cpukit/rtems/src/timercreate.c index ad47ce505a..ae7c64a535 100644 --- a/cpukit/rtems/src/timercreate.c +++ b/cpukit/rtems/src/timercreate.c @@ -36,13 +36,14 @@ RTEMS_STATIC_ASSERT( Timer_server_Control *volatile _Timer_server; -void _Timer_Routine_adaptor( Watchdog_Control *the_watchdog ) +void _Timer_Routine_adaptor( + Watchdog_Control *the_watchdog, + Per_CPU_Control *cpu +) { - Timer_Control *the_timer; - Per_CPU_Control *cpu; + Timer_Control *the_timer; the_timer = RTEMS_CONTAINER_OF( the_watchdog, Timer_Control, Ticker ); - cpu = _Watchdog_Get_CPU( &the_timer->Ticker ); the_timer->stop_time = _Timer_Get_CPU_ticks( cpu ); ( *the_timer->routine )( the_timer->Object.id, the_timer->user_data ); diff --git a/cpukit/rtems/src/timerserver.c b/cpukit/rtems/src/timerserver.c index 09e792aa1c..95a8e2b53c 100644 --- a/cpukit/rtems/src/timerserver.c +++ b/cpukit/rtems/src/timerserver.c @@ -50,11 +50,13 @@ static void _Timer_server_Release( _ISR_lock_Release_and_ISR_enable( &ts->Lock, lock_context ); } -void _Timer_server_Routine_adaptor( Watchdog_Control *the_watchdog ) +void _Timer_server_Routine_adaptor( + Watchdog_Control *the_watchdog, + Per_CPU_Control *cpu +) { Timer_Control *the_timer; ISR_lock_Context lock_context; - Per_CPU_Control *cpu; Timer_server_Control *ts; bool wakeup; @@ -66,7 +68,6 @@ void _Timer_server_Routine_adaptor( Watchdog_Control *the_watchdog ) _Assert( _Watchdog_Get_state( &the_timer->Ticker ) == WATCHDOG_INACTIVE ); _Watchdog_Set_state( &the_timer->Ticker, WATCHDOG_PENDING ); - cpu = _Watchdog_Get_CPU( &the_timer->Ticker ); the_timer->stop_time = _Timer_Get_CPU_ticks( cpu ); wakeup = _Chain_Is_empty( &ts->Pending ); _Chain_Append_unprotected( &ts->Pending, &the_timer->Ticker.Node.Chain ); diff --git a/cpukit/score/src/threadtimeout.c b/cpukit/score/src/threadtimeout.c index 8ea5a651f0..922d0777b6 100644 --- a/cpukit/score/src/threadtimeout.c +++ b/cpukit/score/src/threadtimeout.c @@ -80,10 +80,11 @@ void _Thread_Continue( Thread_Control *the_thread, Status_Control status ) } } -void _Thread_Timeout( Watchdog_Control *the_watchdog ) +void _Thread_Timeout( Watchdog_Control *the_watchdog, Per_CPU_Control *cpu ) { Thread_Control *the_thread; + (void) cpu; the_thread = RTEMS_CONTAINER_OF( the_watchdog, Thread_Control, diff --git a/cpukit/score/src/watchdogtick.c b/cpukit/score/src/watchdogtick.c index 893f5a0fef..ed9a54e72e 100644 --- a/cpukit/score/src/watchdogtick.c +++ b/cpukit/score/src/watchdogtick.c @@ -39,7 +39,7 @@ void _Watchdog_Tickle( routine = first->routine; _ISR_lock_Release_and_ISR_enable( &cpu->Watchdog.Lock, lock_context ); - ( *routine )( first ); + ( *routine )( first, cpu ); _ISR_lock_ISR_disable_and_acquire( &cpu->Watchdog.Lock, lock_context ); } else { break; diff --git a/testsuites/sptests/spintrcritical08/init.c b/testsuites/sptests/spintrcritical08/init.c index aab5701ed4..8fae74323a 100644 --- a/testsuites/sptests/spintrcritical08/init.c +++ b/testsuites/sptests/spintrcritical08/init.c @@ -59,7 +59,7 @@ static rtems_timer_service_routine test_release_from_isr( rtems_test_assert( getState() == RATE_MONOTONIC_ACTIVE ); - (*watchdog->routine)( watchdog ); + (*watchdog->routine)( watchdog, cpu ); if ( flags == RATE_MONOTONIC_INTEND_TO_BLOCK ) { rtems_test_assert( diff --git a/testsuites/sptests/spintrcritical09/init.c b/testsuites/sptests/spintrcritical09/init.c index 63cfa2b5fb..ea0595c500 100644 --- a/testsuites/sptests/spintrcritical09/init.c +++ b/testsuites/sptests/spintrcritical09/init.c @@ -49,7 +49,7 @@ static rtems_timer_service_routine test_release_from_isr( ) { _Watchdog_Per_CPU_remove( watchdog, cpu_self, header ); - (*watchdog->routine)( watchdog ); + (*watchdog->routine)( watchdog, cpu_self ); if ( is_interrupt_timeout() ) { case_hit = true; diff --git a/testsuites/sptests/spintrcritical10/init.c b/testsuites/sptests/spintrcritical10/init.c index bbdfb54f3f..dfe0f22a6c 100644 --- a/testsuites/sptests/spintrcritical10/init.c +++ b/testsuites/sptests/spintrcritical10/init.c @@ -78,7 +78,7 @@ static void any_satisfy_before_timeout(rtems_id timer, void *arg) ); rtems_test_assert(_Thread_Wait_get_status(thread) == STATUS_SUCCESSFUL); - _Thread_Timeout(&thread->Timer.Watchdog); + _Thread_Timeout(&thread->Timer.Watchdog, _Per_CPU_Get()); rtems_test_assert( *(rtems_event_set *) thread->Wait.return_argument == GREEN @@ -175,7 +175,7 @@ static void all_satisfy_before_timeout(rtems_id timer, void *arg) ); rtems_test_assert(_Thread_Wait_get_status(thread) == STATUS_SUCCESSFUL); - _Thread_Timeout(&thread->Timer.Watchdog); + _Thread_Timeout(&thread->Timer.Watchdog, _Per_CPU_Get()); rtems_test_assert( *(rtems_event_set *) thread->Wait.return_argument == EVENTS @@ -251,7 +251,7 @@ static void timeout_before_satisfied(rtems_id timer, void *arg) ); rtems_test_assert(_Thread_Wait_get_status(thread) == STATUS_SUCCESSFUL); - _Thread_Timeout(&thread->Timer.Watchdog); + _Thread_Timeout(&thread->Timer.Watchdog, _Per_CPU_Get()); rtems_test_assert( *(rtems_event_set *) thread->Wait.return_argument == DEADBEEF diff --git a/testsuites/sptests/spintrcritical16/init.c b/testsuites/sptests/spintrcritical16/init.c index 1879cbd189..65ec869d24 100644 --- a/testsuites/sptests/spintrcritical16/init.c +++ b/testsuites/sptests/spintrcritical16/init.c @@ -43,7 +43,7 @@ static rtems_timer_service_routine test_release_from_isr( } if ( Main_TCB->Wait.queue != NULL ) { - _Thread_Timeout( &Main_TCB->Timer.Watchdog ); + _Thread_Timeout( &Main_TCB->Timer.Watchdog, _Per_CPU_Get() ); } } diff --git a/testsuites/sptests/spintrcritical20/init.c b/testsuites/sptests/spintrcritical20/init.c index f9c52809a9..cf14680293 100644 --- a/testsuites/sptests/spintrcritical20/init.c +++ b/testsuites/sptests/spintrcritical20/init.c @@ -88,7 +88,7 @@ static bool test_body(void *arg) ctx->thread_queue_was_null = true; } - _Thread_Timeout(&ctx->semaphore_task_tcb->Timer.Watchdog); + _Thread_Timeout(&ctx->semaphore_task_tcb->Timer.Watchdog, _Per_CPU_Get()); switch (_Thread_Wait_get_status(ctx->semaphore_task_tcb)) { case STATUS_SUCCESSFUL: diff --git a/testsuites/sptests/spwatchdog/init.c b/testsuites/sptests/spwatchdog/init.c index 998d317ae9..d04667f84c 100644 --- a/testsuites/sptests/spwatchdog/init.c +++ b/testsuites/sptests/spwatchdog/init.c @@ -31,11 +31,15 @@ typedef struct { int counter; } test_watchdog; -static void test_watchdog_routine( Watchdog_Control *base ) +static void test_watchdog_routine( + Watchdog_Control *base, + Per_CPU_Control *cpu +) { test_watchdog *watchdog = (test_watchdog *) base; ++watchdog->counter; + rtems_test_assert( cpu == _Per_CPU_Get_snapshot() ); } static void test_watchdog_static_init( void ) @@ -47,10 +51,7 @@ static void test_watchdog_static_init( void ) memset( &b, 0, sizeof( b ) ); _Watchdog_Preinitialize( &b, _Per_CPU_Get_by_index( 0 ) ); - _Watchdog_Initialize( - &b, - test_watchdog_routine - ); + _Watchdog_Initialize( &b, test_watchdog_routine ); rtems_test_assert( memcmp( &a, &b, sizeof( a ) ) == 0 ); } |