[6c2675d] | 1 | /** |
---|
[436f86e] | 2 | * @file |
---|
[21242c2] | 3 | * |
---|
[436f86e] | 4 | * @brief Inlined Routines from the POSIX Timer Manager |
---|
| 5 | * |
---|
[21242c2] | 6 | * This file contains the static inline implementation of the inlined routines |
---|
| 7 | * from the POSIX Timer Manager. |
---|
[6c2675d] | 8 | */ |
---|
| 9 | |
---|
[21242c2] | 10 | /* |
---|
[16b1c350] | 11 | * COPYRIGHT (c) 1989-2013. |
---|
[b602c298] | 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 |
---|
[c499856] | 16 | * http://www.rtems.org/license/LICENSE. |
---|
[b602c298] | 17 | */ |
---|
| 18 | |
---|
[f17c779] | 19 | #ifndef _RTEMS_POSIX_TIMERIMPL_H |
---|
| 20 | #define _RTEMS_POSIX_TIMERIMPL_H |
---|
| 21 | |
---|
| 22 | #include <rtems/posix/timer.h> |
---|
[a2e3f33] | 23 | #include <rtems/score/objectimpl.h> |
---|
[03b900d] | 24 | #include <rtems/score/watchdogimpl.h> |
---|
[f17c779] | 25 | |
---|
| 26 | #ifdef __cplusplus |
---|
| 27 | extern "C" { |
---|
[ef49476] | 28 | #endif |
---|
| 29 | |
---|
[16b1c350] | 30 | /** Timer is free */ |
---|
[f17c779] | 31 | #define POSIX_TIMER_STATE_FREE 0x01 |
---|
| 32 | |
---|
[16b1c350] | 33 | /** Created timer but not running */ |
---|
[f17c779] | 34 | #define POSIX_TIMER_STATE_CREATE_NEW 0x02 |
---|
| 35 | |
---|
[16b1c350] | 36 | /** Created timer and running */ |
---|
[f17c779] | 37 | #define POSIX_TIMER_STATE_CREATE_RUN 0x03 |
---|
| 38 | |
---|
[16b1c350] | 39 | /** Created, ran and stopped timer */ |
---|
[f17c779] | 40 | #define POSIX_TIMER_STATE_CREATE_STOP 0x04 |
---|
| 41 | |
---|
[16b1c350] | 42 | /** Indicates that the fire time is relative to the current one */ |
---|
[f17c779] | 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 | |
---|
[16b1c350] | 54 | /** |
---|
| 55 | * @brief POSIX Timer Allocate |
---|
[b602c298] | 56 | * |
---|
| 57 | * This function allocates a timer control block from |
---|
| 58 | * the inactive chain of free timer control blocks. |
---|
| 59 | */ |
---|
| 60 | RTEMS_INLINE_ROUTINE POSIX_Timer_Control *_POSIX_Timer_Allocate( void ) |
---|
| 61 | { |
---|
| 62 | return (POSIX_Timer_Control *) _Objects_Allocate( &_POSIX_Timer_Information ); |
---|
| 63 | } |
---|
| 64 | |
---|
[16b1c350] | 65 | /** |
---|
| 66 | * @brief POSIX Timer Free |
---|
[b602c298] | 67 | * |
---|
| 68 | * This routine frees a timer control block to the |
---|
| 69 | * inactive chain of free timer control blocks. |
---|
| 70 | */ |
---|
| 71 | RTEMS_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 | |
---|
[03b900d] | 78 | void _POSIX_Timer_TSR( Watchdog_Control *the_watchdog ); |
---|
| 79 | |
---|
[16b1c350] | 80 | /** |
---|
| 81 | * @brief POSIX Timer Get |
---|
[b602c298] | 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 | */ |
---|
| 89 | RTEMS_INLINE_ROUTINE POSIX_Timer_Control *_POSIX_Timer_Get ( |
---|
[3507c6df] | 90 | timer_t id, |
---|
[03b900d] | 91 | ISR_lock_Context *lock_context |
---|
| 92 | ) |
---|
| 93 | { |
---|
[582bb23c] | 94 | return (POSIX_Timer_Control *) _Objects_Get( |
---|
[03b900d] | 95 | (Objects_Id) id, |
---|
[0a68d8e] | 96 | lock_context, |
---|
| 97 | &_POSIX_Timer_Information |
---|
[03b900d] | 98 | ); |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | RTEMS_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 | |
---|
| 114 | RTEMS_INLINE_ROUTINE void _POSIX_Timer_Release( |
---|
| 115 | Per_CPU_Control *cpu, |
---|
| 116 | ISR_lock_Context *lock_context |
---|
[b602c298] | 117 | ) |
---|
| 118 | { |
---|
[03b900d] | 119 | _Watchdog_Per_CPU_release_critical( cpu, lock_context ); |
---|
| 120 | _ISR_lock_ISR_enable( lock_context ); |
---|
[b602c298] | 121 | } |
---|
| 122 | |
---|
[f17c779] | 123 | #ifdef __cplusplus |
---|
| 124 | } |
---|
| 125 | #endif |
---|
| 126 | |
---|
[b602c298] | 127 | #endif |
---|
| 128 | /* end of include file */ |
---|