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

5
Last change on this file since 21275b58 was 21275b58, checked in by Sebastian Huber <sebastian.huber@…>, on 11/22/18 at 18:14:51

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: 3.0 KB
Line 
1/**
2 * @file
3 *
4 * @brief Inlined Routines from the POSIX Timer Manager
5 *
6 * This file contains the static inline implementation of the inlined routines
7 * from the POSIX Timer Manager.
8 */
9
10/*
11 *  COPYRIGHT (c) 1989-2013.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.org/license/LICENSE.
17 */
18
19#ifndef _RTEMS_POSIX_TIMERIMPL_H
20#define _RTEMS_POSIX_TIMERIMPL_H
21
22#include <rtems/posix/timer.h>
23#include <rtems/score/objectimpl.h>
24#include <rtems/score/watchdogimpl.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30/** Timer is free */
31#define POSIX_TIMER_STATE_FREE        0x01
32
33/** Created timer but not running */
34#define POSIX_TIMER_STATE_CREATE_NEW  0x02
35
36/** Created timer and running */
37#define POSIX_TIMER_STATE_CREATE_RUN  0x03
38
39/** Created, ran and stopped timer */
40#define POSIX_TIMER_STATE_CREATE_STOP 0x04
41
42/** Indicates that the fire time is relative to the current one */
43#define POSIX_TIMER_RELATIVE       0
44
45/*
46 * POSIX defines TIMER_ABSTIME but no constant for relative.  So
47 * we have one internally but we need to be careful it has a different
48 * value.
49 */
50#if (POSIX_TIMER_RELATIVE == TIMER_ABSTIME)
51#error "POSIX_TIMER_RELATIVE == TIMER_ABSTIME"
52#endif
53
54/**
55 *  @brief POSIX Timer Allocate
56 *
57 *  This function allocates a timer control block from
58 *  the inactive chain of free timer control blocks.
59 */
60RTEMS_INLINE_ROUTINE POSIX_Timer_Control *_POSIX_Timer_Allocate( void )
61{
62  return (POSIX_Timer_Control *) _Objects_Allocate( &_POSIX_Timer_Information );
63}
64
65/**
66 *  @brief POSIX Timer Free
67 *
68 *  This routine frees a timer control block to the
69 *  inactive chain of free timer control blocks.
70 */
71RTEMS_INLINE_ROUTINE void _POSIX_Timer_Free (
72  POSIX_Timer_Control *the_timer
73)
74{
75  _Objects_Free( &_POSIX_Timer_Information, &the_timer->Object );
76}
77
78void _POSIX_Timer_TSR( Watchdog_Control *the_watchdog );
79
80/**
81 *  @brief POSIX Timer Get
82 *
83 *  This function maps timer IDs to timer control blocks.
84 *  If ID corresponds to a local timer, then it returns
85 *  the timer control pointer which maps to ID and location
86 *  is set to OBJECTS_LOCAL.  Otherwise, location is set
87 *  to OBJECTS_ERROR and the returned value is undefined.
88 */
89RTEMS_INLINE_ROUTINE POSIX_Timer_Control *_POSIX_Timer_Get (
90  timer_t            id,
91  ISR_lock_Context  *lock_context
92)
93{
94  return (POSIX_Timer_Control *) _Objects_Get(
95    (Objects_Id) id,
96    lock_context,
97    &_POSIX_Timer_Information
98  );
99}
100
101RTEMS_INLINE_ROUTINE Per_CPU_Control *_POSIX_Timer_Acquire_critical(
102  POSIX_Timer_Control *ptimer,
103  ISR_lock_Context    *lock_context
104)
105{
106  Per_CPU_Control *cpu;
107
108  cpu = _Watchdog_Get_CPU( &ptimer->Timer );
109  _Watchdog_Per_CPU_acquire_critical( cpu, lock_context );
110
111  return cpu;
112}
113
114RTEMS_INLINE_ROUTINE void _POSIX_Timer_Release(
115  Per_CPU_Control  *cpu,
116  ISR_lock_Context *lock_context
117)
118{
119  _Watchdog_Per_CPU_release_critical( cpu, lock_context );
120  _ISR_lock_ISR_enable( lock_context );
121}
122
123#ifdef __cplusplus
124}
125#endif
126
127#endif
128/* end of include file */
Note: See TracBrowser for help on using the repository browser.