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

Last change on this file since cfc257fc was cfc257fc, checked in by Joel Sherrill <joel.sherrill@…>, on 07/18/03 at 14:47:36

2003-07-18 Till Straumann <strauman@…>

PR 430/rtems

  • include/rtems/score/watchdog.h: _Watchdog_Ticks_since_boot should be a VOLATILE variable.
  • src/watchdoginsert.c: 'restart' algorithm needs to enforce reloading the list head in case a TICK interrupt during ISR_Flash() modified the list. This is achieved by a proper VOLATILE cast. Also _Watchdog_Sync_count++ should be protected by _ISR_Disable (prevent corruption in case ISR calls watchdoginsert)
  • src/watchdogadjust.c: ISR protection added.
  • src/watchdogtickle.c: ISR protection added. NOTE: PowerPC BSPs using the new exception processing MUST BE UPDATED to maintain _ISR_Nest_level. See also PR288 which provides fixes for the affected BSPs distributed with RTEMS.
  • 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.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
34void _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
Note: See TracBrowser for help on using the repository browser.