source: rtems/cpukit/score/src/watchdoginsert.c @ 8ae37323

4.115
Last change on this file since 8ae37323 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: 2.0 KB
Line 
1/**
2 * @file
3 *
4 * @brief Watchdog Insert
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_Insert(
26  Chain_Control         *header,
27  Watchdog_Control      *the_watchdog
28)
29{
30  ISR_Level          level;
31  Watchdog_Control  *after;
32  uint32_t           insert_isr_nest_level;
33  Watchdog_Interval  delta_interval;
34
35
36  insert_isr_nest_level   = _ISR_Nest_level;
37
38  _ISR_Disable( level );
39
40  /*
41   *  Check to see if the watchdog has just been inserted by a
42   *  higher priority interrupt.  If so, abandon this insert.
43   */
44
45  if ( the_watchdog->state != WATCHDOG_INACTIVE ) {
46    _ISR_Enable( level );
47    return;
48  }
49
50  the_watchdog->state = WATCHDOG_BEING_INSERTED;
51  _Watchdog_Sync_count++;
52
53restart:
54  delta_interval = the_watchdog->initial;
55
56  for ( after = _Watchdog_First( header ) ;
57        ;
58        after = _Watchdog_Next( after ) ) {
59
60     if ( delta_interval == 0 || !_Watchdog_Next( after ) )
61       break;
62
63     if ( delta_interval < after->delta_interval ) {
64       after->delta_interval -= delta_interval;
65       break;
66     }
67
68     delta_interval -= after->delta_interval;
69
70     _ISR_Flash( level );
71
72     if ( the_watchdog->state != WATCHDOG_BEING_INSERTED ) {
73       goto exit_insert;
74     }
75
76     if ( _Watchdog_Sync_level > insert_isr_nest_level ) {
77       _Watchdog_Sync_level = insert_isr_nest_level;
78       goto restart;
79     }
80  }
81
82  _Watchdog_Activate( the_watchdog );
83
84  the_watchdog->delta_interval = delta_interval;
85
86  _Chain_Insert_unprotected( after->Node.previous, &the_watchdog->Node );
87
88  the_watchdog->start_time = _Watchdog_Ticks_since_boot;
89
90exit_insert:
91  _Watchdog_Sync_level = insert_isr_nest_level;
92  _Watchdog_Sync_count--;
93  _ISR_Enable( level );
94}
Note: See TracBrowser for help on using the repository browser.