[ac7d5ef0] | 1 | /* watchdog.h |
---|
| 2 | * |
---|
| 3 | * This include file contains all the constants and structures associated |
---|
| 4 | * with watchdog timers. This Handler provides mechanisms which can be |
---|
| 5 | * used to initialize and manipulate watchdog timers. |
---|
| 6 | * |
---|
| 7 | * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. |
---|
| 8 | * On-Line Applications Research Corporation (OAR). |
---|
| 9 | * All rights assigned to U.S. Government, 1994. |
---|
| 10 | * |
---|
| 11 | * This material may be reproduced by or for the U.S. Government pursuant |
---|
| 12 | * to the copyright license under the clause at DFARS 252.227-7013. This |
---|
| 13 | * notice must appear in all copies of this file and its derivatives. |
---|
| 14 | * |
---|
| 15 | * $Id$ |
---|
| 16 | */ |
---|
| 17 | |
---|
[3a4ae6c] | 18 | #ifndef __WATCHDOG_h |
---|
| 19 | #define __WATCHDOG_h |
---|
[ac7d5ef0] | 20 | |
---|
| 21 | #ifdef __cplusplus |
---|
| 22 | extern "C" { |
---|
| 23 | #endif |
---|
| 24 | |
---|
[5e9b32b] | 25 | #include <rtems/score/object.h> |
---|
[ac7d5ef0] | 26 | |
---|
| 27 | /* |
---|
| 28 | * The following type defines the control block used to manage |
---|
| 29 | * intervals. |
---|
| 30 | */ |
---|
| 31 | |
---|
[3a4ae6c] | 32 | typedef unsigned32 Watchdog_Interval; |
---|
[ac7d5ef0] | 33 | |
---|
| 34 | /* |
---|
[3a4ae6c] | 35 | * The following types define a pointer to a watchdog service routine. |
---|
[ac7d5ef0] | 36 | */ |
---|
| 37 | |
---|
[3a4ae6c] | 38 | typedef void Watchdog_Service_routine; |
---|
[ac7d5ef0] | 39 | |
---|
[3a4ae6c] | 40 | typedef Watchdog_Service_routine ( *Watchdog_Service_routine_entry )( |
---|
[ac7d5ef0] | 41 | Objects_Id, |
---|
| 42 | void * |
---|
| 43 | ); |
---|
| 44 | |
---|
| 45 | /* |
---|
| 46 | * Constant for indefinite wait. (actually an illegal interval) |
---|
| 47 | */ |
---|
| 48 | |
---|
[3a4ae6c] | 49 | #define WATCHDOG_NO_TIMEOUT 0 |
---|
[ac7d5ef0] | 50 | |
---|
| 51 | /* |
---|
| 52 | * The following enumerated type lists the states in which a |
---|
| 53 | * watchdog timer may be at any given time. |
---|
| 54 | */ |
---|
| 55 | |
---|
| 56 | typedef enum { |
---|
[eedbfd9] | 57 | WATCHDOG_INACTIVE, /* off all chains */ |
---|
| 58 | WATCHDOG_BEING_INSERTED, /* off all chains, searching for insertion point */ |
---|
| 59 | WATCHDOG_ACTIVE, /* on chain, allowed to fire */ |
---|
| 60 | WATCHDOG_REMOVE_IT /* on chain, remove without firing if expires */ |
---|
[ac7d5ef0] | 61 | } Watchdog_States; |
---|
| 62 | |
---|
| 63 | /* |
---|
| 64 | * The following enumerated type details the manner in which |
---|
| 65 | * a watchdog chain may be adjusted by the Watchdog_Adjust |
---|
| 66 | * routine. The direction indicates a movement FORWARD |
---|
| 67 | * or BACKWARD in time. |
---|
| 68 | */ |
---|
| 69 | |
---|
| 70 | typedef enum { |
---|
| 71 | WATCHDOG_FORWARD, /* adjust delta value forward */ |
---|
| 72 | WATCHDOG_BACKWARD /* adjust delta value backward */ |
---|
| 73 | } Watchdog_Adjust_directions; |
---|
| 74 | |
---|
| 75 | /* |
---|
| 76 | * The following record defines the control block used |
---|
| 77 | * to manage each watchdog timer. |
---|
| 78 | */ |
---|
| 79 | |
---|
| 80 | typedef struct { |
---|
| 81 | Chain_Node Node; |
---|
| 82 | Watchdog_States state; |
---|
[3a4ae6c] | 83 | Watchdog_Interval initial; |
---|
| 84 | Watchdog_Interval delta_interval; |
---|
[5e7b6272] | 85 | Watchdog_Interval start_time; |
---|
| 86 | Watchdog_Interval stop_time; |
---|
[3a4ae6c] | 87 | Watchdog_Service_routine_entry routine; |
---|
[ac7d5ef0] | 88 | Objects_Id id; |
---|
| 89 | void *user_data; |
---|
| 90 | } Watchdog_Control; |
---|
| 91 | |
---|
| 92 | /* |
---|
[88d594a] | 93 | * The following are used for synchronization purposes |
---|
[ac7d5ef0] | 94 | * during an insert on a watchdog delta chain. |
---|
| 95 | */ |
---|
| 96 | |
---|
[c627b2a3] | 97 | SCORE_EXTERN volatile unsigned32 _Watchdog_Sync_level; |
---|
| 98 | SCORE_EXTERN volatile unsigned32 _Watchdog_Sync_count; |
---|
[ac7d5ef0] | 99 | |
---|
[5e7b6272] | 100 | /* |
---|
| 101 | * The following contains the number of ticks since the |
---|
| 102 | * system was booted. |
---|
| 103 | */ |
---|
| 104 | |
---|
| 105 | SCORE_EXTERN Watchdog_Interval _Watchdog_Ticks_since_boot; |
---|
| 106 | |
---|
[ac7d5ef0] | 107 | /* |
---|
| 108 | * The following defines the watchdog chains which are managed |
---|
| 109 | * on ticks and second boundaries. |
---|
| 110 | */ |
---|
| 111 | |
---|
[c627b2a3] | 112 | SCORE_EXTERN Chain_Control _Watchdog_Ticks_chain; |
---|
| 113 | SCORE_EXTERN Chain_Control _Watchdog_Seconds_chain; |
---|
[ac7d5ef0] | 114 | |
---|
| 115 | /* |
---|
| 116 | * _Watchdog_Handler_initialization |
---|
| 117 | * |
---|
| 118 | * DESCRIPTION: |
---|
| 119 | * |
---|
| 120 | * This routine initializes the watchdog handler. The watchdog |
---|
| 121 | * synchronization flag is initialized and the watchdog chains are |
---|
| 122 | * initialized and emptied. |
---|
| 123 | */ |
---|
| 124 | |
---|
| 125 | void _Watchdog_Handler_initialization( void ); |
---|
| 126 | |
---|
| 127 | /* |
---|
| 128 | * _Watchdog_Remove |
---|
| 129 | * |
---|
| 130 | * DESCRIPTION: |
---|
| 131 | * |
---|
| 132 | * This routine removes THE_WATCHDOG from the watchdog chain on which |
---|
| 133 | * it resides and returns the state THE_WATCHDOG timer was in. |
---|
| 134 | */ |
---|
| 135 | |
---|
| 136 | Watchdog_States _Watchdog_Remove ( |
---|
| 137 | Watchdog_Control *the_watchdog |
---|
| 138 | ); |
---|
| 139 | |
---|
| 140 | /* |
---|
| 141 | * _Watchdog_Adjust |
---|
| 142 | * |
---|
| 143 | * DESCRIPTION: |
---|
| 144 | * |
---|
| 145 | * This routine adjusts the HEADER watchdog chain in the forward |
---|
| 146 | * or backward DIRECTION for UNITS ticks. |
---|
| 147 | */ |
---|
| 148 | |
---|
| 149 | void _Watchdog_Adjust ( |
---|
| 150 | Chain_Control *header, |
---|
| 151 | Watchdog_Adjust_directions direction, |
---|
[3a4ae6c] | 152 | Watchdog_Interval units |
---|
[ac7d5ef0] | 153 | ); |
---|
| 154 | |
---|
| 155 | /* |
---|
| 156 | * _Watchdog_Insert |
---|
| 157 | * |
---|
| 158 | * DESCRIPTION: |
---|
| 159 | * |
---|
| 160 | * This routine inserts THE_WATCHDOG into the HEADER watchdog chain |
---|
| 161 | * for a time of UNITS. The INSERT_MODE indicates whether |
---|
| 162 | * THE_WATCHDOG is to be activated automatically or later, explicitly |
---|
| 163 | * by the caller. |
---|
| 164 | * |
---|
| 165 | */ |
---|
| 166 | |
---|
| 167 | void _Watchdog_Insert ( |
---|
| 168 | Chain_Control *header, |
---|
[8d0b7d96] | 169 | Watchdog_Control *the_watchdog |
---|
[ac7d5ef0] | 170 | ); |
---|
| 171 | |
---|
| 172 | /* |
---|
| 173 | * _Watchdog_Tickle |
---|
| 174 | * |
---|
| 175 | * DESCRIPTION: |
---|
| 176 | * |
---|
| 177 | * This routine is invoked at appropriate intervals to update |
---|
| 178 | * the HEADER watchdog chain. |
---|
| 179 | */ |
---|
| 180 | |
---|
| 181 | void _Watchdog_Tickle ( |
---|
| 182 | Chain_Control *header |
---|
| 183 | ); |
---|
| 184 | |
---|
[1a8fde6c] | 185 | #ifndef __RTEMS_APPLICATION__ |
---|
[5e9b32b] | 186 | #include <rtems/score/watchdog.inl> |
---|
[1a8fde6c] | 187 | #endif |
---|
[ac7d5ef0] | 188 | |
---|
| 189 | #ifdef __cplusplus |
---|
| 190 | } |
---|
| 191 | #endif |
---|
| 192 | |
---|
| 193 | #endif |
---|
| 194 | /* end of include file */ |
---|