1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Watchdog Adjust to Chain |
---|
5 | * @ingroup ScoreWatchdog |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2009. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.org/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include <rtems/score/watchdogimpl.h> |
---|
22 | #include <rtems/score/isrlevel.h> |
---|
23 | |
---|
24 | void _Watchdog_Adjust_to_chain( |
---|
25 | Watchdog_Header *header, |
---|
26 | Watchdog_Interval units_arg, |
---|
27 | Chain_Control *to_fire |
---|
28 | |
---|
29 | ) |
---|
30 | { |
---|
31 | Watchdog_Interval units = units_arg; |
---|
32 | ISR_Level level; |
---|
33 | Watchdog_Control *first; |
---|
34 | |
---|
35 | _ISR_Disable( level ); |
---|
36 | |
---|
37 | while ( 1 ) { |
---|
38 | if ( _Watchdog_Is_empty( header ) ) { |
---|
39 | break; |
---|
40 | } |
---|
41 | first = _Watchdog_First( header ); |
---|
42 | |
---|
43 | /* |
---|
44 | * If it is longer than "units" until the first element on the chain |
---|
45 | * fires, then bump it and quit. |
---|
46 | */ |
---|
47 | if ( units < first->delta_interval ) { |
---|
48 | first->delta_interval -= units; |
---|
49 | break; |
---|
50 | } |
---|
51 | |
---|
52 | /* |
---|
53 | * The first set happens in less than units, so take all of them |
---|
54 | * off the chain and adjust units to reflect this. |
---|
55 | */ |
---|
56 | units -= first->delta_interval; |
---|
57 | first->delta_interval = 0; |
---|
58 | |
---|
59 | while ( 1 ) { |
---|
60 | _Chain_Extract_unprotected( &first->Node ); |
---|
61 | _Chain_Append_unprotected( to_fire, &first->Node ); |
---|
62 | |
---|
63 | _ISR_Flash( level ); |
---|
64 | |
---|
65 | if ( _Watchdog_Is_empty( header ) ) |
---|
66 | break; |
---|
67 | first = _Watchdog_First( header ); |
---|
68 | if ( first->delta_interval != 0 ) |
---|
69 | break; |
---|
70 | } |
---|
71 | } |
---|
72 | |
---|
73 | _ISR_Enable( level ); |
---|
74 | } |
---|
75 | |
---|