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