source: rtems/cpukit/score/src/watchdogadjust.c @ 632e4306

4.104.115
Last change on this file since 632e4306 was b2d67fd, checked in by Joel Sherrill <joel.sherrill@…>, on 11/25/08 at 22:29:58

2008-11-25 Joel Sherrill <joel.sherrill@…>

  • score/src/watchdogadjust.c, score/src/watchdogtickle.c: Spacing.
  • Property mode set to 100644
File size: 2.0 KB
Line 
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.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <rtems/system.h>
20#include <rtems/score/isr.h>
21#include <rtems/score/watchdog.h>
22
23/*PAGE
24 *
25 *  _Watchdog_Adjust
26 *
27 *  This routine adjusts the delta chain backward or forward in response
28 *  to a time change.
29 *
30 *  Input parameters:
31 *    header    - pointer to the delta chain to be adjusted
32 *    direction - forward or backward adjustment to delta chain
33 *    units     - units to adjust
34 *
35 *  Output parameters:
36 */
37
38void _Watchdog_Adjust(
39  Chain_Control               *header,
40  Watchdog_Adjust_directions   direction,
41  Watchdog_Interval            units
42)
43{
44  ISR_Level level;
45
46  _ISR_Disable( level );
47
48  /*
49   * NOTE: It is safe NOT to make 'header' a pointer
50   *       to volatile data (contrast this with watchdoginsert.c)
51   *       because we call _Watchdog_Tickle() below and
52   *       hence the compiler must not assume *header to remain
53   *       unmodified across that call.
54   *
55   *       Till Straumann, 7/2003
56   */
57  if ( !_Chain_Is_empty( header ) ) {
58    switch ( direction ) {
59      case WATCHDOG_BACKWARD:
60        _Watchdog_First( header )->delta_interval += units;
61        break;
62      case WATCHDOG_FORWARD:
63        while ( units ) {
64          if ( units < _Watchdog_First( header )->delta_interval ) {
65            _Watchdog_First( header )->delta_interval -= units;
66            break;
67          } else {
68            units -= _Watchdog_First( header )->delta_interval;
69            _Watchdog_First( header )->delta_interval = 1;
70
71            _ISR_Enable( level );
72
73            _Watchdog_Tickle( header );
74
75            _ISR_Disable( level );
76
77            if ( _Chain_Is_empty( header ) )
78              break;
79          }
80        }
81        break;
82    }
83  }
84
85  _ISR_Enable( level );
86
87}
Note: See TracBrowser for help on using the repository browser.