RTEMS 6.1-rc2
Loading...
Searching...
No Matches
timerimpl.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
12/*
13 * COPYRIGHT (c) 1989-2011.
14 * On-Line Applications Research Corporation (OAR).
15 *
16 * Copyright (c) 2016 embedded brains GmbH & Co. KG
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
20 * are met:
21 * 1. Redistributions of source code must retain the above copyright
22 * notice, this list of conditions and the following disclaimer.
23 * 2. Redistributions in binary form must reproduce the above copyright
24 * notice, this list of conditions and the following disclaimer in the
25 * documentation and/or other materials provided with the distribution.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
31 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
38 */
39
40#ifndef _RTEMS_RTEMS_TIMER_INL
41#define _RTEMS_RTEMS_TIMER_INL
42
45#include <rtems/score/thread.h>
47
48#ifdef __cplusplus
49extern "C" {
50#endif
51
62typedef struct Timer_server_Control {
63 ISR_LOCK_MEMBER( Lock )
64
65 Chain_Control Pending;
66
67 Objects_Id server_id;
69
75extern Timer_server_Control *volatile _Timer_server;
76
83static inline Timer_Control *_Timer_Allocate( void )
84{
86}
87
94static inline void _Timer_Free (
95 Timer_Control *the_timer
96)
97{
98 _Objects_Free( &_Timer_Information, &the_timer->Object );
99}
100
101static inline Timer_Control *_Timer_Get(
102 Objects_Id id,
103 ISR_lock_Context *lock_context
104)
105{
106 return (Timer_Control *) _Objects_Get(
107 id,
108 lock_context,
110 );
111}
112
113static inline Per_CPU_Control *_Timer_Acquire_critical(
114 Timer_Control *the_timer,
115 ISR_lock_Context *lock_context
116)
117{
118 Per_CPU_Control *cpu;
119
120 cpu = _Watchdog_Get_CPU( &the_timer->Ticker );
121 _Watchdog_Per_CPU_acquire_critical( cpu, lock_context );
122
123 return cpu;
124}
125
126static inline void _Timer_Release(
127 Per_CPU_Control *cpu,
128 ISR_lock_Context *lock_context
129)
130{
131 _Watchdog_Per_CPU_release_critical( cpu, lock_context );
132 _ISR_lock_ISR_enable( lock_context );
133}
134
135static inline bool _Timer_Is_interval_class(
136 Timer_Classes the_class
137)
138{
139 int mask;
140
142 return ( the_class & mask ) == TIMER_CLASS_BIT_NOT_DORMANT;
143}
144
145static inline bool _Timer_Is_on_task_class(
146 Timer_Classes the_class
147)
148{
149 int mask;
150
152 return ( the_class & mask ) == mask;
153}
154
155static inline Per_CPU_Watchdog_index _Timer_Watchdog_header_index(
156 Timer_Classes the_class
157)
158{
160}
161
162static inline Watchdog_Interval _Timer_Get_CPU_ticks(
163 const Per_CPU_Control *cpu
164)
165{
166 return (Watchdog_Interval) cpu->Watchdog.ticks;
167}
168
169rtems_status_code _Timer_Fire(
170 rtems_id id,
171 rtems_interval interval,
173 void *user_data,
174 Timer_Classes the_class,
176);
177
178rtems_status_code _Timer_Fire_after(
179 rtems_id id,
180 rtems_interval ticks,
182 void *user_data,
183 Timer_Classes the_class,
185);
186
187rtems_status_code _Timer_Fire_when(
188 rtems_id id,
189 const rtems_time_of_day *wall_time,
191 void *user_data,
192 Timer_Classes the_class,
194);
195
196void _Timer_Cancel( Per_CPU_Control *cpu, Timer_Control *the_timer );
197
198void _Timer_Routine_adaptor( Watchdog_Control *the_watchdog );
199
200void _Timer_server_Routine_adaptor( Watchdog_Control *the_watchdog );
201
202static inline void _Timer_server_Acquire_critical(
203 Timer_server_Control *timer_server,
204 ISR_lock_Context *lock_context
205)
206{
207 _ISR_lock_Acquire( &timer_server->Lock, lock_context );
208}
209
210static inline void _Timer_server_Release_critical(
211 Timer_server_Control *timer_server,
212 ISR_lock_Context *lock_context
213)
214{
215 _ISR_lock_Release( &timer_server->Lock, lock_context );
216}
217
220#ifdef __cplusplus
221}
222#endif
223
224#endif
225/* end of include file */
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:85
rtems_timer_service_routine(* rtems_timer_service_routine_entry)(rtems_id, void *)
This type defines the prototype of routines which can be fired by directives of the Timer Manager.
Definition: timer.h:259
#define TIMER_CLASS_BIT_NOT_DORMANT
This timer class bit indicates that the timer is not dormant.
Definition: timer.h:86
Timer_Classes
The timer class indicates how the timer was most recently fired.
Definition: timer.h:114
#define TIMER_CLASS_BIT_TIME_OF_DAY
This timer class bit indicates that the timer uses a time of day.
Definition: timer.h:105
#define TIMER_CLASS_BIT_ON_TASK
This timer class bit indicates that the timer routine executes in a task context.
Definition: timer.h:96
Objects_Id rtems_id
This type represents RTEMS object identifiers.
Definition: types.h:94
Watchdog_Interval rtems_interval
This type represents clock tick intervals.
Definition: types.h:114
Timer_server_Control *volatile _Timer_server
Pointer to default timer server control block.
Definition: timercreate.c:60
Objects_Information _Timer_Information
The Classic Timer objects information.
#define ISR_LOCK_MEMBER(_designator)
Defines an ISR lock member.
Definition: isrlock.h:105
#define _ISR_lock_ISR_enable(_context)
Restores the saved interrupt state of the ISR lock context.
Definition: isrlock.h:435
#define _ISR_lock_Release(_lock, _context)
Releases an ISR lock inside an ISR disabled section.
Definition: isrlock.h:332
#define _ISR_lock_Acquire(_lock, _context)
Acquires an ISR lock inside an ISR disabled section.
Definition: isrlock.h:309
Objects_Control * _Objects_Allocate(Objects_Information *information)
Allocates an object.
Definition: objectallocate.c:43
uint32_t Objects_Id
Definition: object.h:101
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:43
Per_CPU_Watchdog_index
Per-CPU watchdog header index.
Definition: percpu.h:345
uint32_t Watchdog_Interval
Type is used to specify the length of intervals.
Definition: watchdogticks.h:59
Watchdog_Service_routine(* Watchdog_Service_routine_entry)(Watchdog_Control *)
Pointer to a watchdog service routine.
Definition: watchdog.h:85
This header file provides interfaces of the Object Handler which are only used by the implementation.
This header file provides interfaces of the Thread Handler which are used by the implementation and t...
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:81
Per CPU Core Structure.
Definition: percpu.h:384
struct Per_CPU_Control::@4380 Watchdog
Watchdog state for this processor.
uint64_t ticks
Watchdog ticks on this processor used for monotonic clock watchdogs.
Definition: percpu.h:506
Definition: timerdata.h:61
Objects_Control Object
Definition: timerdata.h:63
Watchdog_Control Ticker
Definition: timerdata.h:65
Definition: timerimpl.h:62
The control block used to manage each watchdog timer.
Definition: watchdog.h:109
This type represents Classic API calendar times.
Definition: types.h:266
This header file provides data structures used by the implementation and the Application Configuratio...
This union represents a chain control block.
Definition: chain.h:96
This header file provides interfaces of the Watchdog Handler which are only used by the implementatio...