RTEMS
timerimpl.h
Go to the documentation of this file.
1 
9 /*
10  * COPYRIGHT (c) 1989-2011.
11  * On-Line Applications Research Corporation (OAR).
12  *
13  * Copyright (c) 2016 embedded brains GmbH.
14  *
15  * The license and distribution terms for this file may be
16  * found in the file LICENSE in this distribution or at
17  * http://www.rtems.org/license/LICENSE.
18  */
19 
20 #ifndef _RTEMS_RTEMS_TIMER_INL
21 #define _RTEMS_RTEMS_TIMER_INL
22 
23 #include <rtems/rtems/timerdata.h>
24 #include <rtems/score/objectimpl.h>
25 #include <rtems/score/thread.h>
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
40 typedef struct Timer_server_Control {
41  ISR_LOCK_MEMBER( Lock )
42 
43  Chain_Control Pending;
44 
45  Objects_Id server_id;
47 
53 extern Timer_server_Control *volatile _Timer_server;
54 
62 {
64 }
65 
73  Timer_Control *the_timer
74 )
75 {
76  _Objects_Free( &_Timer_Information, &the_timer->Object );
77 }
78 
80  Objects_Id id,
81  ISR_lock_Context *lock_context
82 )
83 {
84  return (Timer_Control *) _Objects_Get(
85  id,
86  lock_context,
88  );
89 }
90 
91 RTEMS_INLINE_ROUTINE Per_CPU_Control *_Timer_Acquire_critical(
92  Timer_Control *the_timer,
93  ISR_lock_Context *lock_context
94 )
95 {
96  Per_CPU_Control *cpu;
97 
98  cpu = _Watchdog_Get_CPU( &the_timer->Ticker );
99  _Watchdog_Per_CPU_acquire_critical( cpu, lock_context );
100 
101  return cpu;
102 }
103 
104 RTEMS_INLINE_ROUTINE void _Timer_Release(
105  Per_CPU_Control *cpu,
106  ISR_lock_Context *lock_context
107 )
108 {
109  _Watchdog_Per_CPU_release_critical( cpu, lock_context );
110  _ISR_lock_ISR_enable( lock_context );
111 }
112 
113 RTEMS_INLINE_ROUTINE bool _Timer_Is_interval_class(
114  Timer_Classes the_class
115 )
116 {
117  Timer_Classes mask =
119 
120  return ( the_class & mask ) == TIMER_CLASS_BIT_NOT_DORMANT;
121 }
122 
123 RTEMS_INLINE_ROUTINE bool _Timer_Is_on_task_class(
124  Timer_Classes the_class
125 )
126 {
127  Timer_Classes mask =
129 
130  return ( the_class & mask ) == mask;
131 }
132 
133 RTEMS_INLINE_ROUTINE Per_CPU_Watchdog_index _Timer_Watchdog_header_index(
134  Timer_Classes the_class
135 )
136 {
137  return ( the_class & TIMER_CLASS_BIT_TIME_OF_DAY );
138 }
139 
140 RTEMS_INLINE_ROUTINE Watchdog_Interval _Timer_Get_CPU_ticks(
141  const Per_CPU_Control *cpu
142 )
143 {
144  return (Watchdog_Interval) cpu->Watchdog.ticks;
145 }
146 
147 rtems_status_code _Timer_Fire(
148  rtems_id id,
149  rtems_interval interval,
151  void *user_data,
152  Timer_Classes the_class,
154 );
155 
156 rtems_status_code _Timer_Fire_after(
157  rtems_id id,
158  rtems_interval ticks,
160  void *user_data,
161  Timer_Classes the_class,
163 );
164 
165 rtems_status_code _Timer_Fire_when(
166  rtems_id id,
167  const rtems_time_of_day *wall_time,
169  void *user_data,
170  Timer_Classes the_class,
172 );
173 
174 void _Timer_Cancel( Per_CPU_Control *cpu, Timer_Control *the_timer );
175 
176 void _Timer_Routine_adaptor( Watchdog_Control *the_watchdog );
177 
178 void _Timer_server_Routine_adaptor( Watchdog_Control *the_watchdog );
179 
180 RTEMS_INLINE_ROUTINE void _Timer_server_Acquire_critical(
181  Timer_server_Control *timer_server,
182  ISR_lock_Context *lock_context
183 )
184 {
185  _ISR_lock_Acquire( &timer_server->Lock, lock_context );
186 }
187 
188 RTEMS_INLINE_ROUTINE void _Timer_server_Release_critical(
189  Timer_server_Control *timer_server,
190  ISR_lock_Context *lock_context
191 )
192 {
193  _ISR_lock_Release( &timer_server->Lock, lock_context );
194 }
195 
198 #ifdef __cplusplus
199 }
200 #endif
201 
202 #endif
203 /* end of include file */
Watchdog_Service_routine(* Watchdog_Service_routine_entry)(Watchdog_Control *)
Pointer to a watchdog service routine.
Definition: watchdog.h:66
#define TIMER_CLASS_BIT_ON_TASK
%
Definition: timer.h:93
uint32_t Watchdog_Interval
Type is used to specify the length of intervals.
Definition: watchdogticks.h:38
#define TIMER_CLASS_BIT_TIME_OF_DAY
%
Definition: timer.h:84
Timer_Classes
%
Definition: timer.h:120
static __inline__ void _Timer_Free(Timer_Control *the_timer)
Timer_Free.
Definition: timerimpl.h:72
Inlined Routines in the Watchdog Handler.
uint64_t ticks
Protects all watchdog operations on this processor.
Definition: percpu.h:467
Objects_Information _Timer_Information
The Classic Timer objects information.
The control block used to manage each watchdog timer.
Definition: watchdog.h:90
#define _ISR_lock_ISR_enable(_context)
Restores the saved interrupt state of the ISR lock context.
Definition: isrlock.h:416
Objects_Control Object
Definition: timerdata.h:43
#define TIMER_CLASS_BIT_NOT_DORMANT
%
Definition: timer.h:102
Objects_Control * _Objects_Allocate(Objects_Information *information)
Allocates an object.
static __inline__ Timer_Control * _Timer_Allocate(void)
Timer_Allocate.
Definition: timerimpl.h:61
Per_CPU_Watchdog_index
Per-CPU watchdog header index.
Definition: percpu.h:308
Inlined Routines in the Object Handler.
This type is used to represent the calendar time in the Classic API.
Definition: types.h:258
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:82
#define ISR_LOCK_MEMBER(_designator)
Defines an ISR lock member.
Definition: isrlock.h:87
Watchdog_Control Ticker
Definition: timerdata.h:45
static __inline__ Per_CPU_Control * _Watchdog_Get_CPU(const Watchdog_Control *the_watchdog)
Gets the watchdog&#39;s cpu.
Definition: watchdogimpl.h:177
Per CPU Core Structure.
Definition: percpu.h:347
Timer_server_Control *volatile _Timer_server
Pointer to default timer server control block.
Definition: timercreate.c:37
struct Per_CPU_Control::@13 Watchdog
Watchdog state for this processor.
static __inline__ void _Watchdog_Per_CPU_release_critical(Per_CPU_Control *cpu, ISR_lock_Context *lock_context)
Releases the per cpu watchdog lock in a critical section.
Definition: watchdogimpl.h:575
#define _ISR_lock_Acquire(_lock, _context)
Acquires an ISR lock inside an ISR disabled section.
Definition: isrlock.h:284
static __inline__ void _Watchdog_Per_CPU_acquire_critical(Per_CPU_Control *cpu, ISR_lock_Context *lock_context)
Acquires the per cpu watchdog lock in a critical section.
Definition: watchdogimpl.h:561
#define _ISR_lock_Release(_lock, _context)
Releases an ISR lock inside an ISR disabled section.
Definition: isrlock.h:310
Watchdog_Interval rtems_interval
This type is used to represent clock tick intervals.
Definition: types.h:90
Objects_Id rtems_id
Values of this type identify an RTEMS object.
Definition: types.h:99
Classic Partition Manager Data Structures.
uint32_t Objects_Id
Definition: object.h:80
Objects_Control * _Objects_Get(Objects_Id id, ISR_lock_Context *lock_context, const Objects_Information *information)
Maps the specified object identifier to the associated local object control block.
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65
#define RTEMS_INLINE_ROUTINE
Gives a hint to the compiler in a function declaration to inline this function.
Definition: basedefs.h:683
rtems_timer_service_routine(* rtems_timer_service_routine_entry)(rtems_id, void *)
%
Definition: timer.h:158
Constants and Structures Related with the Thread Control Block.
static __inline__ void _Objects_Free(Objects_Information *information, Objects_Control *the_object)
Frees an object.
Definition: objectimpl.h:933