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.com/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include <rtems/system.h> |
---|
22 | #include <rtems/score/isr.h> |
---|
23 | #include <rtems/score/watchdogimpl.h> |
---|
24 | |
---|
25 | void _Watchdog_Adjust_to_chain( |
---|
26 | Chain_Control *header, |
---|
27 | Watchdog_Interval units_arg, |
---|
28 | Chain_Control *to_fire |
---|
29 | |
---|
30 | ) |
---|
31 | { |
---|
32 | Watchdog_Interval units = units_arg; |
---|
33 | ISR_Level level; |
---|
34 | Watchdog_Control *first; |
---|
35 | |
---|
36 | _ISR_Disable( level ); |
---|
37 | |
---|
38 | while ( 1 ) { |
---|
39 | if ( _Chain_Is_empty( header ) ) { |
---|
40 | break; |
---|
41 | } |
---|
42 | first = _Watchdog_First( header ); |
---|
43 | |
---|
44 | /* |
---|
45 | * If it is longer than "units" until the first element on the chain |
---|
46 | * fires, then bump it and quit. |
---|
47 | */ |
---|
48 | if ( units < first->delta_interval ) { |
---|
49 | first->delta_interval -= units; |
---|
50 | break; |
---|
51 | } |
---|
52 | |
---|
53 | /* |
---|
54 | * The first set happens in less than units, so take all of them |
---|
55 | * off the chain and adjust units to reflect this. |
---|
56 | */ |
---|
57 | units -= first->delta_interval; |
---|
58 | first->delta_interval = 0; |
---|
59 | |
---|
60 | while ( 1 ) { |
---|
61 | _Chain_Extract_unprotected( &first->Node ); |
---|
62 | _Chain_Append_unprotected( to_fire, &first->Node ); |
---|
63 | |
---|
64 | _ISR_Flash( level ); |
---|
65 | |
---|
66 | if ( _Chain_Is_empty( header ) ) |
---|
67 | break; |
---|
68 | first = _Watchdog_First( header ); |
---|
69 | if ( first->delta_interval != 0 ) |
---|
70 | break; |
---|
71 | } |
---|
72 | } |
---|
73 | |
---|
74 | _ISR_Enable( level ); |
---|
75 | } |
---|
76 | |
---|