source: rtems/cpukit/score/src/watchdoginsert.c @ d7c3883

4.115
Last change on this file since d7c3883 was 42d6ed8, checked in by Sebastian Huber <sebastian.huber@…>, on 11/09/10 at 09:14:10

2010-11-09 Sebastian Huber <sebastian.huber@…>

  • score/src/watchdoginsert.c: Removed superfluous cast and use appropriate API function. This special case handling is obsolete since 2006 with the introduction of compiler memory barriers in the interrupt routines. Removed obsolete comments.
  • Property mode set to 100644
File size: 2.2 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_Insert
26 *
27 *  This routine inserts a watchdog timer on to the appropriate delta
28 *  chain while updating the delta interval counters.
29 */
30
31void _Watchdog_Insert(
32  Chain_Control         *header,
33  Watchdog_Control      *the_watchdog
34)
35{
36  ISR_Level          level;
37  Watchdog_Control  *after;
38  uint32_t           insert_isr_nest_level;
39  Watchdog_Interval  delta_interval;
40
41
42  insert_isr_nest_level   = _ISR_Nest_level;
43
44  _ISR_Disable( level );
45
46  /*
47   *  Check to see if the watchdog has just been inserted by a
48   *  higher priority interrupt.  If so, abandon this insert.
49   */
50
51  if ( the_watchdog->state != WATCHDOG_INACTIVE ) {
52    _ISR_Enable( level );
53    return;
54  }
55
56  the_watchdog->state = WATCHDOG_BEING_INSERTED;
57  _Watchdog_Sync_count++;
58
59restart:
60  delta_interval = the_watchdog->initial;
61
62  for ( after = _Watchdog_First( header ) ;
63        ;
64        after = _Watchdog_Next( after ) ) {
65
66     if ( delta_interval == 0 || !_Watchdog_Next( after ) )
67       break;
68
69     if ( delta_interval < after->delta_interval ) {
70       after->delta_interval -= delta_interval;
71       break;
72     }
73
74     delta_interval -= after->delta_interval;
75
76     _ISR_Flash( level );
77
78     if ( the_watchdog->state != WATCHDOG_BEING_INSERTED ) {
79       goto exit_insert;
80     }
81
82     if ( _Watchdog_Sync_level > insert_isr_nest_level ) {
83       _Watchdog_Sync_level = insert_isr_nest_level;
84       goto restart;
85     }
86  }
87
88  _Watchdog_Activate( the_watchdog );
89
90  the_watchdog->delta_interval = delta_interval;
91
92  _Chain_Insert_unprotected( after->Node.previous, &the_watchdog->Node );
93
94  the_watchdog->start_time = _Watchdog_Ticks_since_boot;
95
96exit_insert:
97  _Watchdog_Sync_level = insert_isr_nest_level;
98  _Watchdog_Sync_count--;
99  _ISR_Enable( level );
100}
Note: See TracBrowser for help on using the repository browser.