1 | /* |
---|
2 | * Watchdog Handler |
---|
3 | * |
---|
4 | * |
---|
5 | * COPYRIGHT (c) 1989-1998. |
---|
6 | * On-Line Applications Research Corporation (OAR). |
---|
7 | * Copyright assigned to U.S. Government, 1994. |
---|
8 | * |
---|
9 | * The license and distribution terms for this file may be |
---|
10 | * found in the file LICENSE in this distribution or at |
---|
11 | * http://www.OARcorp.com/rtems/license.html. |
---|
12 | * |
---|
13 | * $Id$ |
---|
14 | */ |
---|
15 | |
---|
16 | #include <rtems/system.h> |
---|
17 | #include <rtems/score/isr.h> |
---|
18 | #include <rtems/score/watchdog.h> |
---|
19 | |
---|
20 | /*PAGE |
---|
21 | * |
---|
22 | * _Watchdog_Remove |
---|
23 | * |
---|
24 | * The routine removes a watchdog from a delta chain and updates |
---|
25 | * the delta counters of the remaining watchdogs. |
---|
26 | */ |
---|
27 | |
---|
28 | Watchdog_States _Watchdog_Remove( |
---|
29 | Watchdog_Control *the_watchdog |
---|
30 | ) |
---|
31 | { |
---|
32 | ISR_Level level; |
---|
33 | Watchdog_States previous_state; |
---|
34 | Watchdog_Control *next_watchdog; |
---|
35 | |
---|
36 | _ISR_Disable( level ); |
---|
37 | previous_state = the_watchdog->state; |
---|
38 | switch ( previous_state ) { |
---|
39 | case WATCHDOG_INACTIVE: |
---|
40 | break; |
---|
41 | |
---|
42 | case WATCHDOG_BEING_INSERTED: |
---|
43 | |
---|
44 | /* |
---|
45 | * It is not actually on the chain so just change the state and |
---|
46 | * the Insert operation we interrupted will be aborted. |
---|
47 | */ |
---|
48 | the_watchdog->state = WATCHDOG_INACTIVE; |
---|
49 | break; |
---|
50 | |
---|
51 | case WATCHDOG_ACTIVE: |
---|
52 | case WATCHDOG_REMOVE_IT: |
---|
53 | |
---|
54 | the_watchdog->state = WATCHDOG_INACTIVE; |
---|
55 | next_watchdog = _Watchdog_Next( the_watchdog ); |
---|
56 | |
---|
57 | if ( _Watchdog_Next(next_watchdog) ) |
---|
58 | next_watchdog->delta_interval += the_watchdog->delta_interval; |
---|
59 | |
---|
60 | if ( _Watchdog_Sync_count ) |
---|
61 | _Watchdog_Sync_level = _ISR_Nest_level; |
---|
62 | |
---|
63 | _Chain_Extract_unprotected( &the_watchdog->Node ); |
---|
64 | break; |
---|
65 | } |
---|
66 | the_watchdog->stop_time = _Watchdog_Ticks_since_boot; |
---|
67 | |
---|
68 | _ISR_Enable( level ); |
---|
69 | return( previous_state ); |
---|
70 | } |
---|
71 | |
---|