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

4.104.114.84.95
Last change on this file since 3127180 was 3127180, checked in by Ralf Corsepius <ralf.corsepius@…>, on 03/29/04 at 12:51:43

2004-04-29 Ralf Corsepius <ralf_corsepius@…>

  • score/src/Unlimited.txt, score/src/chain.c, score/src/coremsg.c, score/src/coremsgbroadcast.c, score/src/coremsgclose.c, score/src/coremsgflush.c, score/src/coremsgflushsupp.c, score/src/coremsgseize.c, score/src/coremsgsubmit.c, score/src/coremutex.c, score/src/coremutexflush.c, score/src/coresem.c, score/src/coresemflush.c, score/src/coretod.c, score/src/coretodtickle.c, score/src/coretodtoseconds.c, score/src/coretodvalidate.c, score/src/heap.c, score/src/heapallocate.c, score/src/heapextend.c, score/src/heapfree.c, score/src/heapsizeofuserarea.c, score/src/interr.c, score/src/iterateoverthreads.c, score/src/mpci.c, score/src/object.c, score/src/objectallocate.c, score/src/objectallocatebyindex.c, score/src/objectclearname.c, score/src/objectcomparenameraw.c, score/src/objectcomparenamestring.c, score/src/objectcopynameraw.c, score/src/objectcopynamestring.c, score/src/objectextendinformation.c, score/src/objectfree.c, score/src/objectget.c, score/src/objectgetbyindex.c, score/src/objectgetisr.c, score/src/objectgetnoprotection.c, score/src/objectidtoname.c, score/src/objectinitializeinformation.c, score/src/objectmp.c, score/src/objectnametoid.c, score/src/objectshrinkinformation.c, score/src/thread.c, score/src/threadcreateidle.c, score/src/threadget.c, score/src/threadidlebody.c, score/src/threadinitialize.c, score/src/threadmp.c, score/src/threadq.c, score/src/threadqdequeuepriority.c, score/src/threadqenqueuepriority.c, score/src/threadqfirstpriority.c, score/src/threadqflush.c, score/src/threadreset.c, score/src/threadrestart.c, score/src/threadsettransient.c, score/src/threadstackallocate.c, score/src/threadstart.c, score/src/userext.c, score/src/watchdoginsert.c, score/src/wkspace.c: Convert to using c99 fixed size types.
  • Property mode set to 100644
File size: 2.9 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#include <rtems/system.h>
16#include <rtems/score/isr.h>
17#include <rtems/score/watchdog.h>
18
19/*PAGE
20 *
21 *  _Watchdog_Insert
22 *
23 *  This routine inserts a watchdog timer on to the appropriate delta
24 *  chain while updating the delta interval counters.
25 */
26
27void _Watchdog_Insert(
28  Chain_Control         *header,
29  Watchdog_Control      *the_watchdog
30)
31{
32  ISR_Level          level;
33  Watchdog_Control  *after;
34  uint32_t           insert_isr_nest_level;
35  Watchdog_Interval  delta_interval;
36 
37
38  insert_isr_nest_level   = _ISR_Nest_level;
39  the_watchdog->state = WATCHDOG_BEING_INSERTED;
40
41  _ISR_Disable( level );
42
43  _Watchdog_Sync_count++;
44
45restart:
46  delta_interval = the_watchdog->initial;
47
48  /*
49   * We CANT use _Watchdog_First() here, because a TICK interrupt
50   * could modify the chain during the _ISR_Flash() below. Hence,
51   * the header is pointing to volatile data. The _Watchdog_First()
52   * INLINE routine (but not the macro - note the subtle difference)
53   * casts away the 'volatile'...
54   *
55   * Also, this is only necessary because we call no other routine
56   * from this piece of code, hence the compiler thinks it's safe to
57   * cache *header!!
58   *
59   *  Till Straumann, 7/2003 (gcc-3.2.2 -O4 on powerpc)
60   *
61   */
62  for ( after = (Watchdog_Control *) ((volatile Chain_Control *)header)->first ;
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     /*
77      *  If you experience problems comment out the _ISR_Flash line. 
78      *  3.2.0 was the first release with this critical section redesigned.
79      *  Under certain circumstances, the PREVIOUS critical section algorithm
80      *  used around this flash point allowed interrupts to execute
81      *  which violated the design assumptions.  The critical section
82      *  mechanism used here WAS redesigned to address this.
83      */
84
85     _ISR_Flash( level );
86
87     if ( the_watchdog->state != WATCHDOG_BEING_INSERTED ) {
88       goto exit_insert;
89     }
90
91     if ( _Watchdog_Sync_level > insert_isr_nest_level ) {
92       _Watchdog_Sync_level = insert_isr_nest_level;
93       goto restart;
94     }
95  }
96
97  _Watchdog_Activate( the_watchdog );
98
99  the_watchdog->delta_interval = delta_interval;
100
101  _Chain_Insert_unprotected( after->Node.previous, &the_watchdog->Node );
102
103  the_watchdog->start_time = _Watchdog_Ticks_since_boot;
104
105exit_insert:
106  _Watchdog_Sync_level = insert_isr_nest_level;
107  _Watchdog_Sync_count--;
108  _ISR_Enable( level );
109}
110
Note: See TracBrowser for help on using the repository browser.