1 | /** |
---|
2 | * @file rtems/score/watchdog.h |
---|
3 | * |
---|
4 | * @brief Constants and Structures Associated with Watchdog Timers |
---|
5 | * |
---|
6 | * This include file contains all the constants and structures associated |
---|
7 | * with watchdog timers. This Handler provides mechanisms which can be |
---|
8 | * used to initialize and manipulate watchdog timers. |
---|
9 | */ |
---|
10 | |
---|
11 | /* |
---|
12 | * COPYRIGHT (c) 1989-2009. |
---|
13 | * On-Line Applications Research Corporation (OAR). |
---|
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_SCORE_WATCHDOG_H |
---|
21 | #define _RTEMS_SCORE_WATCHDOG_H |
---|
22 | |
---|
23 | #include <rtems/score/basedefs.h> |
---|
24 | #include <rtems/score/chain.h> |
---|
25 | #include <rtems/score/rbtree.h> |
---|
26 | |
---|
27 | struct Per_CPU_Control; |
---|
28 | |
---|
29 | #ifdef __cplusplus |
---|
30 | extern "C" { |
---|
31 | #endif |
---|
32 | |
---|
33 | /** |
---|
34 | * @defgroup ScoreWatchdog Watchdog Handler |
---|
35 | * |
---|
36 | * @ingroup Score |
---|
37 | * |
---|
38 | * This handler encapsulates functionality related to the scheduling of |
---|
39 | * watchdog functions to be called at specific times in the future. |
---|
40 | * |
---|
41 | * @note This handler does not have anything to do with hardware watchdog |
---|
42 | * timers. |
---|
43 | */ |
---|
44 | /**@{*/ |
---|
45 | |
---|
46 | typedef struct Watchdog_Control Watchdog_Control; |
---|
47 | |
---|
48 | /** |
---|
49 | * @brief Type is used to specify the length of intervals. |
---|
50 | * |
---|
51 | * This type is used to specify the length of intervals. |
---|
52 | */ |
---|
53 | typedef uint32_t Watchdog_Interval; |
---|
54 | |
---|
55 | /** |
---|
56 | * @brief Return type from a Watchdog Service Routine. |
---|
57 | * |
---|
58 | * This type defines the return type from a Watchdog Service Routine. |
---|
59 | */ |
---|
60 | typedef void Watchdog_Service_routine; |
---|
61 | |
---|
62 | /** |
---|
63 | * @brief Pointer to a watchdog service routine. |
---|
64 | * |
---|
65 | * This type define a pointer to a watchdog service routine. |
---|
66 | */ |
---|
67 | typedef Watchdog_Service_routine |
---|
68 | ( *Watchdog_Service_routine_entry )( Watchdog_Control * ); |
---|
69 | |
---|
70 | /** |
---|
71 | * @brief The constant for indefinite wait. |
---|
72 | * |
---|
73 | * This is the constant for indefinite wait. It is actually an |
---|
74 | * illegal interval. |
---|
75 | */ |
---|
76 | #define WATCHDOG_NO_TIMEOUT 0 |
---|
77 | |
---|
78 | /** |
---|
79 | * @brief The watchdog header to manage scheduled watchdogs. |
---|
80 | */ |
---|
81 | typedef struct { |
---|
82 | /** |
---|
83 | * @brief Red-black tree of scheduled watchdogs sorted by expiration time. |
---|
84 | */ |
---|
85 | RBTree_Control Watchdogs; |
---|
86 | |
---|
87 | /** |
---|
88 | * @brief The scheduled watchdog with the earliest expiration time or NULL in |
---|
89 | * case no watchdog is scheduled. |
---|
90 | */ |
---|
91 | RBTree_Node *first; |
---|
92 | } Watchdog_Header; |
---|
93 | |
---|
94 | /** |
---|
95 | * @brief The control block used to manage each watchdog timer. |
---|
96 | * |
---|
97 | * The following record defines the control block used |
---|
98 | * to manage each watchdog timer. |
---|
99 | */ |
---|
100 | struct Watchdog_Control { |
---|
101 | /** |
---|
102 | * @brief Nodes for the watchdog. |
---|
103 | */ |
---|
104 | union { |
---|
105 | /** |
---|
106 | * @brief this field is a red-black tree node structure and allows this to |
---|
107 | * be placed on a red-black tree used to manage the scheduled watchdogs. |
---|
108 | */ |
---|
109 | RBTree_Node RBTree; |
---|
110 | |
---|
111 | /** |
---|
112 | * @brief this field is a chain node structure and allows this to be placed |
---|
113 | * on a chain used to manage pending watchdogs by the timer server. |
---|
114 | */ |
---|
115 | Chain_Node Chain; |
---|
116 | } Node; |
---|
117 | |
---|
118 | #if defined(RTEMS_SMP) |
---|
119 | /** @brief This field references the processor of this watchdog control. */ |
---|
120 | struct Per_CPU_Control *cpu; |
---|
121 | #endif |
---|
122 | |
---|
123 | /** @brief This field is the function to invoke. */ |
---|
124 | Watchdog_Service_routine_entry routine; |
---|
125 | |
---|
126 | /** @brief This field is the expiration time point. */ |
---|
127 | uint64_t expire; |
---|
128 | }; |
---|
129 | |
---|
130 | /** |
---|
131 | * @brief The watchdog ticks counter. |
---|
132 | * |
---|
133 | * With a 1ms watchdog tick, this counter overflows after 50 days since boot. |
---|
134 | */ |
---|
135 | extern volatile Watchdog_Interval _Watchdog_Ticks_since_boot; |
---|
136 | |
---|
137 | /**@}*/ |
---|
138 | |
---|
139 | #ifdef __cplusplus |
---|
140 | } |
---|
141 | #endif |
---|
142 | |
---|
143 | #endif |
---|
144 | /* end of include file */ |
---|