diff options
Diffstat (limited to 'cpukit/rtems/include/rtems')
-rw-r--r-- | cpukit/rtems/include/rtems/rtems/ratemonimpl.h | 24 | ||||
-rw-r--r-- | cpukit/rtems/include/rtems/rtems/timer.h | 59 | ||||
-rw-r--r-- | cpukit/rtems/include/rtems/rtems/timerimpl.h | 216 |
3 files changed, 157 insertions, 142 deletions
diff --git a/cpukit/rtems/include/rtems/rtems/ratemonimpl.h b/cpukit/rtems/include/rtems/rtems/ratemonimpl.h index 490912eb21..f184c44ba9 100644 --- a/cpukit/rtems/include/rtems/rtems/ratemonimpl.h +++ b/cpukit/rtems/include/rtems/rtems/ratemonimpl.h @@ -129,19 +129,13 @@ RTEMS_INLINE_ROUTINE bool _Rate_monotonic_Is_expired ( /** * @brief Rate Monotonic Timeout * - * This routine is invoked when the period represented - * by ID expires. If the thread which owns this period is blocked - * waiting for the period to expire, then it is readied and the - * period is restarted. If the owning thread is not waiting for the - * period to expire, then the period is placed in the EXPIRED - * state and not restarted. - * - * @param[in] id is the period id - */ -void _Rate_monotonic_Timeout( - rtems_id id, - void *ignored -); + * This routine is invoked when the period represented by the watchdog expires. + * If the thread which owns this period is blocked waiting for the period to + * expire, then it is readied and the period is restarted. If the owning thread + * is not waiting for the period to expire, then the period is placed in the + * EXPIRED state and not restarted. + */ +void _Rate_monotonic_Timeout( Watchdog_Control *watchdog ); /** * @brief _Rate_monotonic_Get_status( @@ -165,7 +159,7 @@ bool _Rate_monotonic_Get_status( ); /** - * @brief Initiate Rate Monotonic Statistics + * @brief Restart Rate Monotonic Period * * This routine is invoked when a period is initiated via an explicit * call to rtems_rate_monotonic_period for the period's first iteration @@ -173,7 +167,7 @@ bool _Rate_monotonic_Get_status( * * @param[in] the_period points to the period being operated upon. */ -void _Rate_monotonic_Initiate_statistics( +void _Rate_monotonic_Restart( Rate_monotonic_Control *the_period ); diff --git a/cpukit/rtems/include/rtems/rtems/timer.h b/cpukit/rtems/include/rtems/rtems/timer.h index 7cc90511ca..032c49525a 100644 --- a/cpukit/rtems/include/rtems/rtems/timer.h +++ b/cpukit/rtems/include/rtems/rtems/timer.h @@ -31,7 +31,7 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * Copyright (c) 2009 embedded brains GmbH. + * Copyright (c) 2009, 2016 embedded brains GmbH. * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at @@ -43,6 +43,7 @@ #include <rtems/rtems/attr.h> #include <rtems/rtems/status.h> +#include <rtems/rtems/tasks.h> #include <rtems/rtems/types.h> #ifdef __cplusplus @@ -63,39 +64,49 @@ extern "C" { */ /**@{*/ +#define TIMER_CLASS_BIT_TIME_OF_DAY 0x1 + +#define TIMER_CLASS_BIT_ON_TASK 0x2 + +#define TIMER_CLASS_BIT_NOT_DORMANT 0x4 + /** * The following enumerated type details the classes to which a timer * may belong. */ typedef enum { /** + * This value indicates the timer is currently not in use. + */ + TIMER_DORMANT, + + /** * This value indicates the timer is currently in use as an interval * timer which will fire in the clock tick ISR. */ - TIMER_INTERVAL, + TIMER_INTERVAL = TIMER_CLASS_BIT_NOT_DORMANT, /** * This value indicates the timer is currently in use as an interval * timer which will fire in the timer server task. */ - TIMER_INTERVAL_ON_TASK, + TIMER_INTERVAL_ON_TASK = + TIMER_CLASS_BIT_NOT_DORMANT | TIMER_CLASS_BIT_ON_TASK, /** * This value indicates the timer is currently in use as an time of day * timer which will fire in the clock tick ISR. */ - TIMER_TIME_OF_DAY, + TIMER_TIME_OF_DAY = + TIMER_CLASS_BIT_NOT_DORMANT | TIMER_CLASS_BIT_TIME_OF_DAY, /** * This value indicates the timer is currently in use as an time of day * timer which will fire in the timer server task. */ - TIMER_TIME_OF_DAY_ON_TASK, - - /** - * This value indicates the timer is currently not in use. - */ - TIMER_DORMANT + TIMER_TIME_OF_DAY_ON_TASK = + TIMER_CLASS_BIT_NOT_DORMANT | TIMER_CLASS_BIT_TIME_OF_DAY | + TIMER_CLASS_BIT_ON_TASK } Timer_Classes; /** @@ -124,6 +135,16 @@ typedef struct { Watchdog_Control Ticker; /** This field indicates what type of timer this currently is. */ Timer_Classes the_class; + /** This field is the timer service routine. */ + rtems_timer_service_routine_entry routine; + /** This field is the timer service routine user data. */ + void *user_data; + /** This field is the timer interval in ticks or seconds. */ + Watchdog_Interval initial; + /** This field is the timer start time point in ticks. */ + Watchdog_Interval start_time; + /** This field is the timer stop time point in ticks. */ + Watchdog_Interval stop_time; } Timer_Control; /** @@ -296,16 +317,22 @@ rtems_status_code rtems_timer_reset( ); /** - * @brief rtems_timer_initiate_server + * @brief Initiates the timer server. * - * This routine implements the rtems_timer_initiate_server directive. - * It creates and starts the server that executes task-based timers. + * This directive creates and starts the server for task-based timers. * It must be invoked before any task-based timers can be initiated. + * + * @param priority The timer server task priority. + * @param stack_size The stack size in bytes for the timer server task. + * @param attribute_set The timer server task attributes. + * + * @return This method returns RTEMS_SUCCESSFUL if successful and an + * error code otherwise. */ rtems_status_code rtems_timer_initiate_server( - uint32_t priority, - uint32_t stack_size, - rtems_attribute attribute_set + rtems_task_priority priority, + size_t stack_size, + rtems_attribute attribute_set ); /** diff --git a/cpukit/rtems/include/rtems/rtems/timerimpl.h b/cpukit/rtems/include/rtems/rtems/timerimpl.h index 55be6343c3..e4b4ca2ec4 100644 --- a/cpukit/rtems/include/rtems/rtems/timerimpl.h +++ b/cpukit/rtems/include/rtems/rtems/timerimpl.h @@ -10,6 +10,8 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * + * Copyright (c) 2016 embedded brains GmbH. + * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at * http://www.rtems.org/license/LICENSE. @@ -35,81 +37,13 @@ extern "C" { * @{ */ -typedef struct Timer_server_Control Timer_server_Control; +typedef struct Timer_server_Control { + ISR_LOCK_MEMBER( Lock ) -/** - * @brief Method used for task based timers. - */ -typedef void (*Timer_server_Method)( - Timer_server_Control *timer_server, - Timer_Control *timer -); + Chain_Control Pending; -typedef struct { - /** - * @brief This watchdog that will be registered in the system tick mechanic - * for timer server wake-up. - */ - Watchdog_Control System_watchdog; - - /** - * @brief Remaining delta of the system watchdog. - */ - Watchdog_Interval system_watchdog_delta; - - /** - * @brief Unique identifier of the context which deals currently with the - * system watchdog. - */ - Thread_Control *system_watchdog_helper; - - /** - * @brief Each insert and tickle operation increases the generation count so - * that the system watchdog dealer notices updates of the watchdog chain. - */ - uint32_t generation; - - /** - * @brief Watchdog header managed by the timer server. - */ - Watchdog_Header Header; - - /** - * @brief Last time snapshot of the timer server. - * - * The units may be ticks or seconds. - */ - Watchdog_Interval last_snapshot; - - /** - * @brief Current time snapshot of the timer server. - * - * The units may be ticks or seconds. - */ - Watchdog_Interval current_snapshot; -} Timer_server_Watchdogs; - -struct Timer_server_Control { - /** - * @brief The cancel method of the timer server. - */ - Timer_server_Method cancel; - - /** - * @brief The schedule operation method of the timer server. - */ - Timer_server_Method schedule_operation; - - /** - * @brief Interval watchdogs triggered by the timer server. - */ - Timer_server_Watchdogs Interval_watchdogs; - - /** - * @brief TOD watchdogs triggered by the timer server. - */ - Timer_server_Watchdogs TOD_watchdogs; -}; + Objects_Id server_id; +} Timer_server_Control; /** * @brief Pointer to default timer server control block. @@ -148,64 +82,124 @@ RTEMS_INLINE_ROUTINE void _Timer_Free ( _Objects_Free( &_Timer_Information, &the_timer->Object ); } -/** - * @brief Timer_Get - * - * This function maps timer IDs to timer control blocks. - * If ID corresponds to a local timer, then it returns - * the timer control pointer which maps to ID and location - * is set to OBJECTS_LOCAL. Otherwise, location is set - * to OBJECTS_ERROR and the returned value is undefined. - */ -RTEMS_INLINE_ROUTINE Timer_Control *_Timer_Get ( +RTEMS_INLINE_ROUTINE Timer_Control *_Timer_Get( Objects_Id id, - Objects_Locations *location + Objects_Locations *location, + ISR_lock_Context *lock_context ) { - return (Timer_Control *) - _Objects_Get( &_Timer_Information, id, location ); + return (Timer_Control *) _Objects_Get_isr_disable( + &_Timer_Information, + id, + location, + lock_context + ); } -/** - * @brief Timer_Is_interval_class - * - * This function returns TRUE if the class is that of an INTERVAL - * timer, and FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Timer_Is_interval_class ( +RTEMS_INLINE_ROUTINE Per_CPU_Control *_Timer_Acquire_critical( + Timer_Control *the_timer, + ISR_lock_Context *lock_context +) +{ + Per_CPU_Control *cpu; + + cpu = _Watchdog_Get_CPU( &the_timer->Ticker ); + _Watchdog_Per_CPU_acquire_critical( cpu, lock_context ); + + return cpu; +} + +RTEMS_INLINE_ROUTINE void _Timer_Release( + Per_CPU_Control *cpu, + ISR_lock_Context *lock_context +) +{ + _Watchdog_Per_CPU_release_critical( cpu, lock_context ); + _ISR_lock_ISR_enable( lock_context ); +} + +RTEMS_INLINE_ROUTINE bool _Timer_Is_interval_class( Timer_Classes the_class ) { - return (the_class == TIMER_INTERVAL) || (the_class == TIMER_INTERVAL_ON_TASK); + Timer_Classes mask = + TIMER_CLASS_BIT_NOT_DORMANT | TIMER_CLASS_BIT_TIME_OF_DAY; + + return ( the_class & mask ) == TIMER_CLASS_BIT_NOT_DORMANT; } -/** - * @brief Timer_Is_time_of_day_class - * - * This function returns TRUE if the class is that of an INTERVAL - * timer, and FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Timer_Is_timer_of_day_class ( +RTEMS_INLINE_ROUTINE bool _Timer_Is_on_task_class( Timer_Classes the_class ) { - return ( the_class == TIMER_TIME_OF_DAY ); + Timer_Classes mask = + TIMER_CLASS_BIT_NOT_DORMANT | TIMER_CLASS_BIT_ON_TASK; + + return ( the_class & mask ) == mask; } -/** - * @brief Timer_Is_dormant_class - * - * This function returns TRUE if the class is that of a DORMANT - * timer, and FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Timer_Is_dormant_class ( +RTEMS_INLINE_ROUTINE Per_CPU_Watchdog_index _Timer_Watchdog_header_index( Timer_Classes the_class ) { - return ( the_class == TIMER_DORMANT ); + return ( the_class & TIMER_CLASS_BIT_TIME_OF_DAY ); +} + +RTEMS_INLINE_ROUTINE Watchdog_Interval _Timer_Get_CPU_ticks( + const Per_CPU_Control *cpu +) +{ + return (Watchdog_Interval) cpu->Watchdog.ticks; } -void _Timer_Cancel( Timer_Control *the_timer ); +rtems_status_code _Timer_Fire( + rtems_id id, + rtems_interval interval, + rtems_timer_service_routine_entry routine, + void *user_data, + Timer_Classes the_class, + Watchdog_Service_routine_entry adaptor +); + +rtems_status_code _Timer_Fire_after( + rtems_id id, + rtems_interval ticks, + rtems_timer_service_routine_entry routine, + void *user_data, + Timer_Classes the_class, + Watchdog_Service_routine_entry adaptor +); + +rtems_status_code _Timer_Fire_when( + rtems_id id, + const rtems_time_of_day *wall_time, + rtems_timer_service_routine_entry routine, + void *user_data, + Timer_Classes the_class, + Watchdog_Service_routine_entry adaptor +); + +void _Timer_Cancel( Per_CPU_Control *cpu, Timer_Control *the_timer ); + +void _Timer_Routine_adaptor( Watchdog_Control *the_watchdog ); + +void _Timer_server_Routine_adaptor( Watchdog_Control *the_watchdog ); + +RTEMS_INLINE_ROUTINE void _Timer_server_Acquire_critical( + Timer_server_Control *timer_server, + ISR_lock_Context *lock_context +) +{ + _ISR_lock_Acquire( &timer_server->Lock, lock_context ); +} + +RTEMS_INLINE_ROUTINE void _Timer_server_Release_critical( + Timer_server_Control *timer_server, + ISR_lock_Context *lock_context +) +{ + _ISR_lock_Release( &timer_server->Lock, lock_context ); +} /**@}*/ |