source: rtems/cpukit/include/rtems/rtems/timerimpl.h @ 21275b58

Last change on this file since 21275b58 was 21275b58, checked in by Sebastian Huber <sebastian.huber@…>, on Nov 22, 2018 at 6:14:51 PM

score: Static Objects_Information initialization

Statically allocate the objects information together with the initial
set of objects either via <rtems/confdefs.h>. Provide default object
informations with zero objects via librtemscpu.a. This greatly
simplifies the workspace size estimate. RTEMS applications which do not
use the unlimited objects option are easier to debug since all objects
reside now in statically allocated objects of the right types.

Close #3621.

  • Property mode set to 100644
File size: 4.6 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup ClassicTimerImpl
5 *
6 * @brief Classic Timer Implementation
7 */
8
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
32/**
33 * @defgroup ClassicTimerImpl Classic Timer Implementation
34 *
35 * @ingroup ClassicTimer
36 *
37 * @{
38 */
39
40typedef 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
48/**
49 * @brief Pointer to default timer server control block.
50 *
51 * This value is @c NULL when the default timer server is not initialized.
52 */
53extern Timer_server_Control *volatile _Timer_server;
54
55/**
56 *  @brief Timer_Allocate
57 *
58 *  This function allocates a timer control block from
59 *  the inactive chain of free timer control blocks.
60 */
61RTEMS_INLINE_ROUTINE Timer_Control *_Timer_Allocate( void )
62{
63  return (Timer_Control *) _Objects_Allocate( &_Timer_Information );
64}
65
66/**
67 *  @brief Timer_Free
68 *
69 *  This routine frees a timer control block to the
70 *  inactive chain of free timer control blocks.
71 */
72RTEMS_INLINE_ROUTINE void _Timer_Free (
73  Timer_Control *the_timer
74)
75{
76  _Objects_Free( &_Timer_Information, &the_timer->Object );
77}
78
79RTEMS_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
91RTEMS_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
104RTEMS_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
113RTEMS_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
123RTEMS_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
133RTEMS_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
140RTEMS_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
147rtems_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
156rtems_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
165rtems_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
180RTEMS_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
188RTEMS_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
196/**@}*/
197
198#ifdef __cplusplus
199}
200#endif
201
202#endif
203/* end of include file */
Note: See TracBrowser for help on using the repository browser.