|
31 | 31 | #include <nuttx/compiler.h>
|
32 | 32 | #include <nuttx/irq.h>
|
33 | 33 | #include <nuttx/fs/ioctl.h>
|
| 34 | +#include <nuttx/notifier.h> |
| 35 | +#include <nuttx/sched.h> |
34 | 36 |
|
35 | 37 | #ifdef CONFIG_WATCHDOG
|
36 | 38 |
|
|
88 | 90 | #define WDFLAGS_CAPTURE (1 << 2) /* 1=Call the user function when the
|
89 | 91 | * watchdog timer expires */
|
90 | 92 |
|
| 93 | +/* Keepalive Actions ********************************************************/ |
| 94 | + |
| 95 | +/* According to the keepalive action specified by the Auto-monitor, callback |
| 96 | + * functions registered on the watchdog notifier chain may take corresponding |
| 97 | + * actions. |
| 98 | + * |
| 99 | + * These are detected and handled by the "upper half" watchdog timer driver. |
| 100 | + * |
| 101 | + * WATCHDOG_KEEPALIVE_BY_ONESHOT - The watchdog timer is keepalive by |
| 102 | + * oneshot timer. |
| 103 | + * WATCHDOG_KEEPALIVE_BY_TIMER - The watchdog timer is keepalive by |
| 104 | + * timer. |
| 105 | + * WATCHDOG_KEEPALIVE_BY_WDOG - The watchdog timer is keepalive by |
| 106 | + * wdog. |
| 107 | + * WATCHDOG_KEEPALIVE_BY_WORKER - The watchdog timer is keepalive by |
| 108 | + * worker queue. |
| 109 | + * WATCHDOG_KEEPALIVE_BY_CAPTURE - The watchdog timer is keepalive by |
| 110 | + * capture. |
| 111 | + * WATCHDOG_KEEPALIVE_BY_IDLE - The watchdog timer is keepalive by |
| 112 | + * idle task. |
| 113 | + */ |
| 114 | + |
| 115 | +#define WATCHDOG_KEEPALIVE_BY_ONESHOT 0 |
| 116 | +#define WATCHDOG_KEEPALIVE_BY_TIMER 1 |
| 117 | +#define WATCHDOG_KEEPALIVE_BY_WDOG 2 |
| 118 | +#define WATCHDOG_KEEPALIVE_BY_WORKER 3 |
| 119 | +#define WATCHDOG_KEEPALIVE_BY_CAPTURE 4 |
| 120 | +#define WATCHDOG_KEEPALIVE_BY_IDLE 5 |
| 121 | + |
91 | 122 | /****************************************************************************
|
92 | 123 | * Public Types
|
93 | 124 | ****************************************************************************/
|
@@ -197,6 +228,61 @@ extern "C"
|
197 | 228 | #define EXTERN extern
|
198 | 229 | #endif
|
199 | 230 |
|
| 231 | +#ifdef CONFIG_WATCHDOG_TIMEOUT_NOTIFIER |
| 232 | +/**************************************************************************** |
| 233 | + * Name: watchdog_notifier_chain_register |
| 234 | + * |
| 235 | + * Description: |
| 236 | + * Add notifier to the watchdog notifier chain |
| 237 | + * |
| 238 | + * Input Parameters: |
| 239 | + * nb - New entry in notifier chain |
| 240 | + * |
| 241 | + ****************************************************************************/ |
| 242 | + |
| 243 | +void watchdog_notifier_chain_register(FAR struct notifier_block *nb); |
| 244 | + |
| 245 | +/**************************************************************************** |
| 246 | + * Name: watchdog_notifier_chain_unregister |
| 247 | + * |
| 248 | + * Description: |
| 249 | + * Remove notifier from the watchdog notifier chain |
| 250 | + * |
| 251 | + * Input Parameters: |
| 252 | + * nb - Entry to remove from notifier chain |
| 253 | + * |
| 254 | + ****************************************************************************/ |
| 255 | + |
| 256 | +void watchdog_notifier_chain_unregister(FAR struct notifier_block *nb); |
| 257 | + |
| 258 | +/**************************************************************************** |
| 259 | + * Name: watchdog_notifier_call_chain |
| 260 | + * |
| 261 | + * Description: |
| 262 | + * Call functions in the watchdog notifier chain. |
| 263 | + * |
| 264 | + * Input Parameters: |
| 265 | + * action - Value passed unmodified to notifier function |
| 266 | + * data - Pointer passed unmodified to notifier function |
| 267 | + * |
| 268 | + ****************************************************************************/ |
| 269 | + |
| 270 | +void watchdog_notifier_call_chain(unsigned long action, FAR void *data); |
| 271 | + |
| 272 | +/**************************************************************************** |
| 273 | + * Name: watchdog_automonitor_timeout |
| 274 | + * |
| 275 | + * Description: |
| 276 | + * This function can be called in the watchdog timeout interrupt handler. |
| 277 | + * If so, callbacks on the watchdog timer notify chain are called when the |
| 278 | + * watchdog timer times out. |
| 279 | + * |
| 280 | + ****************************************************************************/ |
| 281 | + |
| 282 | +void watchdog_automonitor_timeout(void); |
| 283 | + |
| 284 | +#endif /* CONFIG_WATCHDOG_TIMEOUT_NOTIFIER */ |
| 285 | + |
200 | 286 | /****************************************************************************
|
201 | 287 | * Name: watchdog_register
|
202 | 288 | *
|
|
0 commit comments