RTEMS 6.1-rc4
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#if ISR_LOCK_NEEDS_OBJECT
64 ISR_lock_Control Lock;
65#endif
66
67 Chain_Control Pending;
68
69 Objects_Id server_id;
71
77extern Timer_server_Control *volatile _Timer_server;
78
85static inline Timer_Control *_Timer_Allocate( void )
86{
88}
89
96static inline void _Timer_Free (
97 Timer_Control *the_timer
98)
99{
100 _Objects_Free( &_Timer_Information, &the_timer->Object );
101}
102
103static inline Timer_Control *_Timer_Get(
104 Objects_Id id,
105 ISR_lock_Context *lock_context
106)
107{
108 return (Timer_Control *) _Objects_Get(
109 id,
110 lock_context,
112 );
113}
114
115static inline Per_CPU_Control *_Timer_Acquire_critical(
116 Timer_Control *the_timer,
117 ISR_lock_Context *lock_context
118)
119{
120 Per_CPU_Control *cpu;
121
122 cpu = _Watchdog_Get_CPU( &the_timer->Ticker );
123 _Watchdog_Per_CPU_acquire_critical( cpu, lock_context );
124
125 return cpu;
126}
127
128static inline void _Timer_Release(
129 Per_CPU_Control *cpu,
130 ISR_lock_Context *lock_context
131)
132{
133 _Watchdog_Per_CPU_release_critical( cpu, lock_context );
134 _ISR_lock_ISR_enable( lock_context );
135}
136
137static inline bool _Timer_Is_interval_class(
138 Timer_Classes the_class
139)
140{
141 int mask;
142
144 return ( the_class & mask ) == TIMER_CLASS_BIT_NOT_DORMANT;
145}
146
147static inline bool _Timer_Is_on_task_class(
148 Timer_Classes the_class
149)
150{
151 int mask;
152
154 return ( the_class & mask ) == mask;
155}
156
157static inline Per_CPU_Watchdog_index _Timer_Watchdog_header_index(
158 Timer_Classes the_class
159)
160{
162}
163
164static inline Watchdog_Interval _Timer_Get_CPU_ticks(
165 const Per_CPU_Control *cpu
166)
167{
168 return (Watchdog_Interval) cpu->Watchdog.ticks;
169}
170
171rtems_status_code _Timer_Fire(
172 rtems_id id,
173 rtems_interval interval,
175 void *user_data,
176 Timer_Classes the_class,
178);
179
180rtems_status_code _Timer_Fire_after(
181 rtems_id id,
182 rtems_interval ticks,
184 void *user_data,
185 Timer_Classes the_class,
187);
188
189rtems_status_code _Timer_Fire_when(
190 rtems_id id,
191 const rtems_time_of_day *wall_time,
193 void *user_data,
194 Timer_Classes the_class,
196);
197
198void _Timer_Cancel( Per_CPU_Control *cpu, Timer_Control *the_timer );
199
200void _Timer_Routine_adaptor( Watchdog_Control *the_watchdog );
201
202void _Timer_server_Routine_adaptor( Watchdog_Control *the_watchdog );
203
204static inline void _Timer_server_Acquire_critical(
205 Timer_server_Control *timer_server,
206 ISR_lock_Context *lock_context
207)
208{
209 _ISR_lock_Acquire( &timer_server->Lock, lock_context );
210}
211
212static inline void _Timer_server_Release_critical(
213 Timer_server_Control *timer_server,
214 ISR_lock_Context *lock_context
215)
216{
217 _ISR_lock_Release( &timer_server->Lock, lock_context );
218}
219
222#ifdef __cplusplus
223}
224#endif
225
226#endif
227/* 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_ISR_enable(_context)
Restores the saved interrupt state of the ISR lock context.
Definition: isrlock.h:385
#define _ISR_lock_Release(_lock, _context)
Releases an ISR lock inside an ISR disabled section.
Definition: isrlock.h:282
#define _ISR_lock_Acquire(_lock, _context)
Acquires an ISR lock inside an ISR disabled section.
Definition: isrlock.h:259
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:94
Per CPU Core Structure.
Definition: percpu.h:384
uint64_t ticks
Watchdog ticks on this processor used for monotonic clock watchdogs.
Definition: percpu.h:506
struct Per_CPU_Control::@4403 Watchdog
Watchdog state for this processor.
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...