1 | /** |
---|
2 | * @file rtems/posix/timer.h |
---|
3 | * |
---|
4 | * This include files defines the internal support for implementation of |
---|
5 | * POSIX Timers. |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2011. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.com/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #ifndef _RTEMS_POSIX_TIMER_H |
---|
18 | #define _RTEMS_POSIX_TIMER_H |
---|
19 | |
---|
20 | #include <rtems/posix/config.h> |
---|
21 | #include <rtems/score/object.h> |
---|
22 | #include <rtems/score/watchdog.h> /* Watchdog_Control */ |
---|
23 | |
---|
24 | #ifdef __cplusplus |
---|
25 | extern "C" { |
---|
26 | #endif |
---|
27 | |
---|
28 | /* Timer is free */ |
---|
29 | #define POSIX_TIMER_STATE_FREE 0x01 |
---|
30 | |
---|
31 | /* Created timer but not running */ |
---|
32 | #define POSIX_TIMER_STATE_CREATE_NEW 0x02 |
---|
33 | |
---|
34 | /* Created timer and running */ |
---|
35 | #define POSIX_TIMER_STATE_CREATE_RUN 0x03 |
---|
36 | |
---|
37 | /* Created, ran and stopped timer */ |
---|
38 | #define POSIX_TIMER_STATE_CREATE_STOP 0x04 |
---|
39 | |
---|
40 | /* Indicates that the fire time is relative to the current one */ |
---|
41 | #define POSIX_TIMER_RELATIVE 0 |
---|
42 | |
---|
43 | /* |
---|
44 | * POSIX defines TIMER_ABSTIME but no constant for relative. So |
---|
45 | * we have one internally but we need to be careful it has a different |
---|
46 | * value. |
---|
47 | */ |
---|
48 | #if (POSIX_TIMER_RELATIVE == TIMER_ABSTIME) |
---|
49 | #error "POSIX_TIMER_RELATIVE == TIMER_ABSTIME" |
---|
50 | #endif |
---|
51 | |
---|
52 | |
---|
53 | /* |
---|
54 | * Data for a timer |
---|
55 | */ |
---|
56 | typedef struct { |
---|
57 | Objects_Control Object; |
---|
58 | Watchdog_Control Timer; /* Internal Timer */ |
---|
59 | pthread_t thread_id; /* Thread identifier */ |
---|
60 | char state; /* State of the timer */ |
---|
61 | struct sigevent inf; /* Information associated to the timer */ |
---|
62 | struct itimerspec timer_data; /* Timing data of the timer */ |
---|
63 | uint32_t ticks; /* Number of ticks of the initialization */ |
---|
64 | uint32_t overrun; /* Number of expirations of the timer */ |
---|
65 | struct timespec time; /* Time at which the timer was started */ |
---|
66 | } POSIX_Timer_Control; |
---|
67 | |
---|
68 | /* |
---|
69 | * _POSIX_Timers_Manager_initialization |
---|
70 | * |
---|
71 | * DESCRIPTION: |
---|
72 | * |
---|
73 | * This routine performs the initialization necessary for this manager. |
---|
74 | */ |
---|
75 | void _POSIX_Timer_Manager_initialization(void); |
---|
76 | |
---|
77 | /* |
---|
78 | * Timer TSR |
---|
79 | */ |
---|
80 | void _POSIX_Timer_TSR(Objects_Id timer, void *data); |
---|
81 | |
---|
82 | /* |
---|
83 | * Watchdog Insert helper |
---|
84 | */ |
---|
85 | bool _POSIX_Timer_Insert_helper( |
---|
86 | Watchdog_Control *timer, |
---|
87 | Watchdog_Interval ticks, |
---|
88 | Objects_Id id, |
---|
89 | Watchdog_Service_routine_entry TSR, |
---|
90 | void *arg |
---|
91 | ); |
---|
92 | |
---|
93 | /* |
---|
94 | * The following defines the information control block used to manage |
---|
95 | * this class of objects. |
---|
96 | */ |
---|
97 | POSIX_EXTERN Objects_Information _POSIX_Timer_Information; |
---|
98 | |
---|
99 | #ifndef __RTEMS_APPLICATION__ |
---|
100 | #include <rtems/posix/timer.inl> |
---|
101 | #endif |
---|
102 | |
---|
103 | #ifdef __cplusplus |
---|
104 | } |
---|
105 | #endif |
---|
106 | |
---|
107 | #endif |
---|
108 | /* end of include file */ |
---|