1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup RTEMSScoreWatchdog |
---|
5 | * |
---|
6 | * @brief Constants and Structures Associated with Watchdog Timers |
---|
7 | * |
---|
8 | * This include file contains all the constants and structures associated |
---|
9 | * with watchdog timers. This Handler provides mechanisms which can be |
---|
10 | * used to initialize and manipulate watchdog timers. |
---|
11 | */ |
---|
12 | |
---|
13 | /* |
---|
14 | * COPYRIGHT (c) 1989-2009. |
---|
15 | * On-Line Applications Research Corporation (OAR). |
---|
16 | * |
---|
17 | * The license and distribution terms for this file may be |
---|
18 | * found in the file LICENSE in this distribution or at |
---|
19 | * http://www.rtems.org/license/LICENSE. |
---|
20 | */ |
---|
21 | |
---|
22 | #ifndef _RTEMS_SCORE_WATCHDOG_H |
---|
23 | #define _RTEMS_SCORE_WATCHDOG_H |
---|
24 | |
---|
25 | #include <rtems/score/basedefs.h> |
---|
26 | #include <rtems/score/chain.h> |
---|
27 | #include <rtems/score/rbtree.h> |
---|
28 | |
---|
29 | struct Per_CPU_Control; |
---|
30 | |
---|
31 | #ifdef __cplusplus |
---|
32 | extern "C" { |
---|
33 | #endif |
---|
34 | |
---|
35 | /** |
---|
36 | * @defgroup RTEMSScoreWatchdog Watchdog Handler |
---|
37 | * |
---|
38 | * @ingroup RTEMSScore |
---|
39 | * |
---|
40 | * This handler encapsulates functionality related to the scheduling of |
---|
41 | * watchdog functions to be called at specific times in the future. |
---|
42 | * |
---|
43 | * @note This handler does not have anything to do with hardware watchdog |
---|
44 | * timers. |
---|
45 | */ |
---|
46 | /**@{*/ |
---|
47 | |
---|
48 | typedef struct Watchdog_Control Watchdog_Control; |
---|
49 | |
---|
50 | /** |
---|
51 | * @brief Return type from a Watchdog Service Routine. |
---|
52 | * |
---|
53 | * This type defines the return type from a Watchdog Service Routine. |
---|
54 | */ |
---|
55 | typedef void Watchdog_Service_routine; |
---|
56 | |
---|
57 | /** |
---|
58 | * @brief Pointer to a watchdog service routine. |
---|
59 | * |
---|
60 | * This type define a pointer to a watchdog service routine. |
---|
61 | */ |
---|
62 | typedef Watchdog_Service_routine |
---|
63 | ( *Watchdog_Service_routine_entry )( Watchdog_Control * ); |
---|
64 | |
---|
65 | /** |
---|
66 | * @brief The watchdog header to manage scheduled watchdogs. |
---|
67 | */ |
---|
68 | typedef struct { |
---|
69 | /** |
---|
70 | * @brief Red-black tree of scheduled watchdogs sorted by expiration time. |
---|
71 | */ |
---|
72 | RBTree_Control Watchdogs; |
---|
73 | |
---|
74 | /** |
---|
75 | * @brief The scheduled watchdog with the earliest expiration time or NULL in |
---|
76 | * case no watchdog is scheduled. |
---|
77 | */ |
---|
78 | RBTree_Node *first; |
---|
79 | } Watchdog_Header; |
---|
80 | |
---|
81 | /** |
---|
82 | * @brief The control block used to manage each watchdog timer. |
---|
83 | * |
---|
84 | * The following record defines the control block used |
---|
85 | * to manage each watchdog timer. |
---|
86 | */ |
---|
87 | struct Watchdog_Control { |
---|
88 | /** |
---|
89 | * @brief Nodes for the watchdog. |
---|
90 | */ |
---|
91 | union { |
---|
92 | /** |
---|
93 | * @brief this field is a red-black tree node structure and allows this to |
---|
94 | * be placed on a red-black tree used to manage the scheduled watchdogs. |
---|
95 | */ |
---|
96 | RBTree_Node RBTree; |
---|
97 | |
---|
98 | /** |
---|
99 | * @brief this field is a chain node structure and allows this to be placed |
---|
100 | * on a chain used to manage pending watchdogs by the timer server. |
---|
101 | */ |
---|
102 | Chain_Node Chain; |
---|
103 | } Node; |
---|
104 | |
---|
105 | #if defined(RTEMS_SMP) |
---|
106 | /** @brief This field references the processor of this watchdog control. */ |
---|
107 | struct Per_CPU_Control *cpu; |
---|
108 | #endif |
---|
109 | |
---|
110 | /** @brief This field is the function to invoke. */ |
---|
111 | Watchdog_Service_routine_entry routine; |
---|
112 | |
---|
113 | /** @brief This field is the expiration time point. */ |
---|
114 | uint64_t expire; |
---|
115 | }; |
---|
116 | |
---|
117 | /**@}*/ |
---|
118 | |
---|
119 | #ifdef __cplusplus |
---|
120 | } |
---|
121 | #endif |
---|
122 | |
---|
123 | #endif |
---|
124 | /* end of include file */ |
---|