source: rtems/cpukit/score/src/watchdogadjust.c @ 54cf0e34

4.115
Last change on this file since 54cf0e34 was 54cf0e34, checked in by Sebastian Huber <sebastian.huber@…>, on Apr 10, 2015 at 2:19:48 PM

score: Add Watchdog_Header

This type is intended to encapsulate all state to manage a watchdog
chain.

Update #2307.

  • Property mode set to 100644
File size: 1.3 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/score/watchdogimpl.h>
22#include <rtems/score/chainimpl.h>
23#include <rtems/score/isrlevel.h>
24
25void _Watchdog_Adjust_backward(
26  Watchdog_Header   *header,
27  Watchdog_Interval  units
28)
29{
30  ISR_Level level;
31
32  _ISR_Disable( level );
33
34  if ( !_Watchdog_Is_empty( header ) ) {
35     _Watchdog_First( header )->delta_interval += units;
36  }
37
38  _ISR_Enable( level );
39}
40
41void _Watchdog_Adjust_forward(
42  Watchdog_Header   *header,
43  Watchdog_Interval  units
44)
45{
46  ISR_Level level;
47
48  _ISR_Disable( level );
49
50  while ( !_Watchdog_Is_empty( header ) && units > 0 ) {
51    Watchdog_Control *first = _Watchdog_First( header );
52
53    if ( units < first->delta_interval ) {
54      first->delta_interval -= units;
55      break;
56    } else {
57      units -= first->delta_interval;
58      first->delta_interval = 1;
59
60      _ISR_Enable( level );
61
62      _Watchdog_Tickle( header );
63
64      _ISR_Disable( level );
65    }
66  }
67
68  _ISR_Enable( level );
69}
Note: See TracBrowser for help on using the repository browser.