RTEMS: cpukit/include/rtems/rtems/timerimpl.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
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>
26#include <rtems/score/watchdogimpl.h>
27
28#ifdef __cplusplus
29extern "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;
46} Timer_server_Control;
47
53extern Timer_server_Control *volatile _Timer_server;
54
61 RTEMS_INLINE_ROUTINE Timer_Control *_Timer_Allocate( void )
62{
63 return (Timer_Control *) _Objects_Allocate( &_Timer_Information );
64}
65
72 RTEMS_INLINE_ROUTINE void _Timer_Free (
73 Timer_Control *the_timer
74)
75{
76 _Objects_Free( &_Timer_Information, &the_timer->Object );
77}
78
79 RTEMS_INLINE_ROUTINE Timer_Control *_Timer_Get(
80 Objects_Id id,
81 ISR_lock_Context *lock_context
82)
83{
84 return (Timer_Control *) _Objects_Get(
85 id,
86 lock_context,
87 &_Timer_Information
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 =
118 TIMER_CLASS_BIT_NOT_DORMANT | TIMER_CLASS_BIT_TIME_OF_DAY;
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 =
128 TIMER_CLASS_BIT_NOT_DORMANT | TIMER_CLASS_BIT_ON_TASK;
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,
150 rtems_timer_service_routine_entry routine,
151 void *user_data,
152 Timer_Classes the_class,
153 Watchdog_Service_routine_entry adaptor
154);
155
156 rtems_status_code _Timer_Fire_after(
157 rtems_id id,
158 rtems_interval ticks,
159 rtems_timer_service_routine_entry routine,
160 void *user_data,
161 Timer_Classes the_class,
162 Watchdog_Service_routine_entry adaptor
163);
164
165 rtems_status_code _Timer_Fire_when(
166 rtems_id id,
167 const rtems_time_of_day *wall_time,
168 rtems_timer_service_routine_entry routine,
169 void *user_data,
170 Timer_Classes the_class,
171 Watchdog_Service_routine_entry adaptor
172);
173
174void _Timer_Cancel( Per_CPU_Control *cpu, Timer_Control *the_timer );
175
176void _Timer_Routine_adaptor( Watchdog_Control *the_watchdog );
177
178void _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 */
rtems_status_code
rtems_status_code
Classic API Status.
Definition: status.h:43
rtems_id
Objects_Id rtems_id
Used to manage and manipulate RTEMS object identifiers.
Definition: types.h:83
rtems_interval
Watchdog_Interval rtems_interval
Used to manage and manipulate intervals specified by clock ticks.
Definition: types.h:127
_Timer_server
Timer_server_Control *volatile _Timer_server
Pointer to default timer server control block.
Definition: timercreate.c:37
_Timer_Allocate
RTEMS_INLINE_ROUTINE Timer_Control * _Timer_Allocate(void)
Timer_Allocate.
Definition: timerimpl.h:61
_Timer_Free
RTEMS_INLINE_ROUTINE void _Timer_Free(Timer_Control *the_timer)
Timer_Free.
Definition: timerimpl.h:72
_Timer_Information
Objects_Information _Timer_Information
The Classic Timer objects information.
rtems_timer_service_routine_entry
rtems_timer_service_routine(* rtems_timer_service_routine_entry)(rtems_id, void *)
Definition: timer.h:101
Timer_Classes
Timer_Classes
Definition: timer.h:56
Per_CPU_Watchdog_index
Per_CPU_Watchdog_index
Per-CPU watchdog header index.
Definition: percpu.h:308
RTEMS_INLINE_ROUTINE
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66
ISR_LOCK_MEMBER
#define ISR_LOCK_MEMBER(_designator)
Defines an ISR lock member.
Definition: isrlock.h:89
_ISR_lock_ISR_enable
#define _ISR_lock_ISR_enable(_context)
Restores the saved interrupt state of the ISR lock context.
Definition: isrlock.h:419
_ISR_lock_Release
#define _ISR_lock_Release(_lock, _context)
Releases an ISR lock inside an ISR disabled section.
Definition: isrlock.h:316
_ISR_lock_Acquire
#define _ISR_lock_Acquire(_lock, _context)
Acquires an ISR lock inside an ISR disabled section.
Definition: isrlock.h:293
_Objects_Free
RTEMS_INLINE_ROUTINE void _Objects_Free(Objects_Information *information, Objects_Control *the_object)
Frees an object.
Definition: objectimpl.h:930
_Objects_Allocate
Objects_Control * _Objects_Allocate(Objects_Information *information)
Allocates an object.
Definition: objectallocate.c:42
Objects_Id
uint32_t Objects_Id
Definition: object.h:80
_Objects_Get
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.
Definition: objectgetlocal.c:28
_Watchdog_Per_CPU_acquire_critical
RTEMS_INLINE_ROUTINE 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
_Watchdog_Per_CPU_release_critical
RTEMS_INLINE_ROUTINE 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
Watchdog_Interval
uint32_t Watchdog_Interval
Type is used to specify the length of intervals.
Definition: watchdogticks.h:38
_Watchdog_Get_CPU
RTEMS_INLINE_ROUTINE Per_CPU_Control * _Watchdog_Get_CPU(const Watchdog_Control *the_watchdog)
Gets the watchdog's cpu.
Definition: watchdogimpl.h:177
Watchdog_Service_routine_entry
Watchdog_Service_routine(* Watchdog_Service_routine_entry)(Watchdog_Control *)
Pointer to a watchdog service routine.
Definition: watchdog.h:66
objectimpl.h
Inlined Routines in the Object Handler.
thread.h
Constants and Structures Related with the Thread Control Block.
ISR_lock_Context
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65
Per_CPU_Control
Per CPU Core Structure.
Definition: percpu.h:347
Per_CPU_Control::ticks
uint64_t ticks
Protects all watchdog operations on this processor.
Definition: percpu.h:467
Per_CPU_Control::Watchdog
struct Per_CPU_Control::@3978 Watchdog
Watchdog state for this processor.
Timer_Control
Definition: timerdata.h:41
Timer_Control::Object
Objects_Control Object
Definition: timerdata.h:43
Timer_Control::Ticker
Watchdog_Control Ticker
Definition: timerdata.h:45
Timer_server_Control
Definition: timerimpl.h:40
Watchdog_Control
The control block used to manage each watchdog timer.
Definition: watchdog.h:90
rtems_time_of_day
Data structure to manage and manipulate calendar time.
Definition: types.h:141
timerdata.h
Classic Partition Manager Data Structures.
Chain_Control
Definition: chain.h:86
watchdogimpl.h
Inlined Routines in the Watchdog Handler.