source: rtems/cpukit/score/src/watchdogadjust.c @ c499856

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Watchdog Adjust
5 *  @ingroup ScoreWatchdog
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-1999.
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.org/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
25void _Watchdog_Adjust(
26  Chain_Control               *header,
27  Watchdog_Adjust_directions   direction,
28  Watchdog_Interval            units
29)
30{
31  ISR_Level level;
32
33  _ISR_Disable( level );
34
35  /*
36   * NOTE: It is safe NOT to make 'header' a pointer
37   *       to volatile data (contrast this with watchdoginsert.c)
38   *       because we call _Watchdog_Tickle() below and
39   *       hence the compiler must not assume *header to remain
40   *       unmodified across that call.
41   *
42   *       Till Straumann, 7/2003
43   */
44  if ( !_Chain_Is_empty( header ) ) {
45    switch ( direction ) {
46      case WATCHDOG_BACKWARD:
47        _Watchdog_First( header )->delta_interval += units;
48        break;
49      case WATCHDOG_FORWARD:
50        while ( units ) {
51          if ( units < _Watchdog_First( header )->delta_interval ) {
52            _Watchdog_First( header )->delta_interval -= units;
53            break;
54          } else {
55            units -= _Watchdog_First( header )->delta_interval;
56            _Watchdog_First( header )->delta_interval = 1;
57
58            _ISR_Enable( level );
59
60            _Watchdog_Tickle( header );
61
62            _ISR_Disable( level );
63
64            if ( _Chain_Is_empty( header ) )
65              break;
66          }
67        }
68        break;
69    }
70  }
71
72  _ISR_Enable( level );
73
74}
Note: See TracBrowser for help on using the repository browser.