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
77
78
79
80
|
/**
* @file
*
* @brief Watchdog Adjust
* @ingroup ScoreWatchdog
*/
/*
* COPYRIGHT (c) 1989-1999.
* 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/score/watchdogimpl.h>
void _Watchdog_Adjust_backward_locked(
Watchdog_Header *header,
Watchdog_Interval units
)
{
if ( !_Watchdog_Is_empty( header ) ) {
_Watchdog_First( header )->delta_interval += units;
}
}
void _Watchdog_Adjust_backward(
Watchdog_Header *header,
Watchdog_Interval units
)
{
ISR_lock_Context lock_context;
_Watchdog_Acquire( header, &lock_context );
_Watchdog_Adjust_backward_locked( header, units );
_Watchdog_Release( header, &lock_context );
}
void _Watchdog_Adjust_forward_locked(
Watchdog_Header *header,
Watchdog_Interval units,
ISR_lock_Context *lock_context
)
{
while ( !_Watchdog_Is_empty( header ) && units > 0 ) {
Watchdog_Control *first = _Watchdog_First( header );
if ( units < first->delta_interval ) {
first->delta_interval -= units;
break;
} else {
units -= first->delta_interval;
first->delta_interval = 1;
_Watchdog_Release( header, lock_context );
_Watchdog_Tickle( header );
_Watchdog_Acquire( header, lock_context );
}
}
}
void _Watchdog_Adjust_forward(
Watchdog_Header *header,
Watchdog_Interval units
)
{
ISR_lock_Context lock_context;
_Watchdog_Acquire( header, &lock_context );
_Watchdog_Adjust_forward_locked( header, units, &lock_context );
_Watchdog_Release( header, &lock_context );
}
|