|
71 | 71 | # endif
|
72 | 72 | #endif
|
73 | 73 |
|
| 74 | +#if defined(CONFIG_WATCHDOG_AUTOMONITOR_BY_ONESHOT) |
| 75 | +# define WATCHDOG_NOTIFIER_ACTION WATCHDOG_KEEPALIVE_BY_ONESHOT |
| 76 | +#elif defined(CONFIG_WATCHDOG_AUTOMONITOR_BY_TIMER) |
| 77 | +# define WATCHDOG_NOTIFIER_ACTION WATCHDOG_KEEPALIVE_BY_TIMER |
| 78 | +#elif defined(CONFIG_WATCHDOG_AUTOMONITOR_BY_WDOG) |
| 79 | +# define WATCHDOG_NOTIFIER_ACTION WATCHDOG_KEEPALIVE_BY_WDOG |
| 80 | +#elif defined(CONFIG_WATCHDOG_AUTOMONITOR_BY_WORKER) |
| 81 | +# define WATCHDOG_NOTIFIER_ACTION WATCHDOG_KEEPALIVE_BY_WORKER |
| 82 | +#elif defined(CONFIG_WATCHDOG_AUTOMONITOR_BY_CAPTURE) |
| 83 | +# define WATCHDOG_NOTIFIER_ACTION WATCHDOG_KEEPALIVE_BY_CAPTURE |
| 84 | +#elif defined(CONFIG_WATCHDOG_AUTOMONITOR_BY_IDLE) |
| 85 | +# define WATCHDOG_NOTIFIER_ACTION WATCHDOG_KEEPALIVE_BY_IDLE |
| 86 | +#endif |
| 87 | + |
74 | 88 | /****************************************************************************
|
75 | 89 | * Private Type Definitions
|
76 | 90 | ****************************************************************************/
|
@@ -135,6 +149,10 @@ static const struct file_operations g_wdogops =
|
135 | 149 | wdog_ioctl, /* ioctl */
|
136 | 150 | };
|
137 | 151 |
|
| 152 | +#ifdef CONFIG_WATCHDOG_TIMEOUT_NOTIFIER |
| 153 | +static ATOMIC_NOTIFIER_HEAD(g_watchdog_notifier_list); |
| 154 | +#endif |
| 155 | + |
138 | 156 | /****************************************************************************
|
139 | 157 | * Private Functions
|
140 | 158 | ****************************************************************************/
|
@@ -699,6 +717,55 @@ static int wdog_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
699 | 717 | * Public Functions
|
700 | 718 | ****************************************************************************/
|
701 | 719 |
|
| 720 | +#ifdef CONFIG_WATCHDOG_TIMEOUT_NOTIFIER |
| 721 | +/**************************************************************************** |
| 722 | + * Name: watchdog_notifier_chain_register |
| 723 | + * |
| 724 | + * Description: |
| 725 | + * Add notifier to the watchdog notifier chain |
| 726 | + * |
| 727 | + * Input Parameters: |
| 728 | + * nb - New entry in notifier chain |
| 729 | + * |
| 730 | + ****************************************************************************/ |
| 731 | + |
| 732 | +void watchdog_notifier_chain_register(FAR struct notifier_block *nb) |
| 733 | +{ |
| 734 | + atomic_notifier_chain_register(&g_watchdog_notifier_list, nb); |
| 735 | +} |
| 736 | + |
| 737 | +/**************************************************************************** |
| 738 | + * Name: watchdog_notifier_chain_unregister |
| 739 | + * |
| 740 | + * Description: |
| 741 | + * Remove notifier from the watchdog notifier chain |
| 742 | + * |
| 743 | + * Input Parameters: |
| 744 | + * nb - Entry to remove from notifier chain |
| 745 | + * |
| 746 | + ****************************************************************************/ |
| 747 | + |
| 748 | +void watchdog_notifier_chain_unregister(FAR struct notifier_block *nb) |
| 749 | +{ |
| 750 | + atomic_notifier_chain_unregister(&g_watchdog_notifier_list, nb); |
| 751 | +} |
| 752 | + |
| 753 | +/**************************************************************************** |
| 754 | + * Name: watchdog_automonitor_timeout |
| 755 | + * |
| 756 | + * Description: |
| 757 | + * This function can be called in the watchdog timeout interrupt handler. |
| 758 | + * If so, callbacks on the watchdog timer notify chain are called when the |
| 759 | + * watchdog timer times out. |
| 760 | + * |
| 761 | + ****************************************************************************/ |
| 762 | + |
| 763 | +void watchdog_automonitor_timeout(void) |
| 764 | +{ |
| 765 | + atomic_notifier_call_chain(&g_watchdog_notifier_list, action, data); |
| 766 | +} |
| 767 | +#endif /* CONFIG_WATCHDOG_TIMEOUT_NOTIFIER */ |
| 768 | + |
702 | 769 | /****************************************************************************
|
703 | 770 | * Name: watchdog_register
|
704 | 771 | *
|
|
0 commit comments