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