1 | /* |
---|
2 | * Watchdog Handler |
---|
3 | * |
---|
4 | * |
---|
5 | * COPYRIGHT (c) 1989-1999. |
---|
6 | * On-Line Applications Research Corporation (OAR). |
---|
7 | * |
---|
8 | * The license and distribution terms for this file may be |
---|
9 | * found in the file LICENSE in this distribution or at |
---|
10 | * http://www.OARcorp.com/rtems/license.html. |
---|
11 | * |
---|
12 | * $Id$ |
---|
13 | */ |
---|
14 | |
---|
15 | #include <rtems/system.h> |
---|
16 | #include <rtems/score/isr.h> |
---|
17 | #include <rtems/score/watchdog.h> |
---|
18 | |
---|
19 | /*PAGE |
---|
20 | * |
---|
21 | * _Watchdog_Adjust |
---|
22 | * |
---|
23 | * This routine adjusts the delta chain backward or forward in response |
---|
24 | * to a time change. |
---|
25 | * |
---|
26 | * Input parameters: |
---|
27 | * header - pointer to the delta chain to be adjusted |
---|
28 | * direction - forward or backward adjustment to delta chain |
---|
29 | * units - units to adjust |
---|
30 | * |
---|
31 | * Output parameters: |
---|
32 | */ |
---|
33 | |
---|
34 | void _Watchdog_Adjust( |
---|
35 | Chain_Control *header, |
---|
36 | Watchdog_Adjust_directions direction, |
---|
37 | Watchdog_Interval units |
---|
38 | ) |
---|
39 | { |
---|
40 | ISR_Level level; |
---|
41 | |
---|
42 | _ISR_Disable( level ); |
---|
43 | |
---|
44 | /* |
---|
45 | * NOTE: It is safe NOT to make 'header' a pointer |
---|
46 | * to volatile data (contrast this with watchdoginsert.c) |
---|
47 | * because we call _Watchdog_Tickle() below and |
---|
48 | * hence the compiler must not assume *header to remain |
---|
49 | * unmodified across that call. |
---|
50 | * |
---|
51 | * Till Straumann, 7/2003 |
---|
52 | */ |
---|
53 | if ( !_Chain_Is_empty( header ) ) { |
---|
54 | switch ( direction ) { |
---|
55 | case WATCHDOG_BACKWARD: |
---|
56 | _Watchdog_First( header )->delta_interval += units; |
---|
57 | break; |
---|
58 | case WATCHDOG_FORWARD: |
---|
59 | while ( units ) { |
---|
60 | if ( units < _Watchdog_First( header )->delta_interval ) { |
---|
61 | _Watchdog_First( header )->delta_interval -= units; |
---|
62 | break; |
---|
63 | } else { |
---|
64 | units -= _Watchdog_First( header )->delta_interval; |
---|
65 | _Watchdog_First( header )->delta_interval = 1; |
---|
66 | |
---|
67 | _ISR_Enable( level ); |
---|
68 | |
---|
69 | _Watchdog_Tickle( header ); |
---|
70 | |
---|
71 | _ISR_Disable( level ); |
---|
72 | |
---|
73 | if ( _Chain_Is_empty( header ) ) |
---|
74 | break; |
---|
75 | } |
---|
76 | } |
---|
77 | break; |
---|
78 | } |
---|
79 | } |
---|
80 | |
---|
81 | _ISR_Enable( level ); |
---|
82 | |
---|
83 | } |
---|
84 | |
---|