1 | /* |
---|
2 | * Watchdog Handler |
---|
3 | * |
---|
4 | * |
---|
5 | * COPYRIGHT (c) 1989-1999. |
---|
6 | * On-Line Applications Research Corporation (OAR). |
---|
7 | * |
---|
8 | * The license and distribution terms for this file may be |
---|
9 | * found in the file LICENSE in this distribution or at |
---|
10 | * http://www.rtems.com/license/LICENSE. |
---|
11 | * |
---|
12 | * $Id$ |
---|
13 | */ |
---|
14 | |
---|
15 | #if HAVE_CONFIG_H |
---|
16 | #include "config.h" |
---|
17 | #endif |
---|
18 | |
---|
19 | #include <rtems/system.h> |
---|
20 | #include <rtems/score/isr.h> |
---|
21 | #include <rtems/score/watchdog.h> |
---|
22 | |
---|
23 | /*PAGE |
---|
24 | * |
---|
25 | * _Watchdog_Tickle |
---|
26 | * |
---|
27 | * This routine decrements the delta counter in response to a tick. The |
---|
28 | * delta chain is updated accordingly. |
---|
29 | * |
---|
30 | * Input parameters: |
---|
31 | * header - pointer to the delta chain to be tickled |
---|
32 | * |
---|
33 | * Output parameters: NONE |
---|
34 | */ |
---|
35 | |
---|
36 | void _Watchdog_Tickle( |
---|
37 | Chain_Control *header |
---|
38 | ) |
---|
39 | { |
---|
40 | ISR_Level level; |
---|
41 | Watchdog_Control *the_watchdog; |
---|
42 | Watchdog_States watchdog_state; |
---|
43 | |
---|
44 | /* |
---|
45 | * See the comment in watchdoginsert.c and watchdogadjust.c |
---|
46 | * about why it's safe not to declare header a pointer to |
---|
47 | * volatile data - till, 2003/7 |
---|
48 | */ |
---|
49 | |
---|
50 | _ISR_Disable( level ); |
---|
51 | |
---|
52 | if ( _Chain_Is_empty( header ) ) |
---|
53 | goto leave; |
---|
54 | |
---|
55 | the_watchdog = _Watchdog_First( header ); |
---|
56 | the_watchdog->delta_interval--; |
---|
57 | if ( the_watchdog->delta_interval != 0 ) |
---|
58 | goto leave; |
---|
59 | |
---|
60 | do { |
---|
61 | watchdog_state = _Watchdog_Remove( the_watchdog ); |
---|
62 | |
---|
63 | _ISR_Enable( level ); |
---|
64 | |
---|
65 | switch( watchdog_state ) { |
---|
66 | case WATCHDOG_ACTIVE: |
---|
67 | (*the_watchdog->routine)( |
---|
68 | the_watchdog->id, |
---|
69 | the_watchdog->user_data |
---|
70 | ); |
---|
71 | break; |
---|
72 | |
---|
73 | case WATCHDOG_INACTIVE: |
---|
74 | /* |
---|
75 | * This state indicates that the watchdog is not on any chain. |
---|
76 | * Thus, it is NOT on a chain being tickled. This case should |
---|
77 | * never occur. |
---|
78 | */ |
---|
79 | break; |
---|
80 | |
---|
81 | case WATCHDOG_BEING_INSERTED: |
---|
82 | /* |
---|
83 | * This state indicates that the watchdog is in the process of |
---|
84 | * BEING inserted on the chain. Thus, it can NOT be on a chain |
---|
85 | * being tickled. This case should never occur. |
---|
86 | */ |
---|
87 | break; |
---|
88 | |
---|
89 | case WATCHDOG_REMOVE_IT: |
---|
90 | break; |
---|
91 | } |
---|
92 | |
---|
93 | _ISR_Disable( level ); |
---|
94 | |
---|
95 | the_watchdog = _Watchdog_First( header ); |
---|
96 | } while ( !_Chain_Is_empty( header ) && |
---|
97 | (the_watchdog->delta_interval == 0) ); |
---|
98 | |
---|
99 | leave: |
---|
100 | _ISR_Enable(level); |
---|
101 | } |
---|