OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [score/] [src/] [watchdoginsert.c] - Blame information for rev 778

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
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: watchdoginsert.c,v 1.2 2001-09-27 11:59:34 chris Exp $
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
 
27
void _Watchdog_Insert(
28
  Chain_Control         *header,
29
  Watchdog_Control      *the_watchdog
30
)
31
{
32
  ISR_Level          level;
33
  Watchdog_Control  *after;
34
  unsigned32         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
  _Watchdog_Sync_count++;
42
restart:
43
  delta_interval = the_watchdog->initial;
44
 
45
  _ISR_Disable( level );
46
 
47
  for ( after = _Watchdog_First( header ) ;
48
        ;
49
        after = _Watchdog_Next( after ) ) {
50
 
51
     if ( delta_interval == 0 || !_Watchdog_Next( after ) )
52
       break;
53
 
54
     if ( delta_interval < after->delta_interval ) {
55
       after->delta_interval -= delta_interval;
56
       break;
57
     }
58
 
59
     delta_interval -= after->delta_interval;
60
 
61
     /*
62
      *  If you experience problems comment out the _ISR_Flash line.
63
      *  3.2.0 was the first release with this critical section redesigned.
64
      *  Under certain circumstances, the PREVIOUS critical section algorithm
65
      *  used around this flash point allowed interrupts to execute
66
      *  which violated the design assumptions.  The critical section
67
      *  mechanism used here WAS redesigned to address this.
68
      */
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
       _ISR_Enable( level );
79
       goto restart;
80
     }
81
  }
82
 
83
  _Watchdog_Activate( the_watchdog );
84
 
85
  the_watchdog->delta_interval = delta_interval;
86
 
87
  _Chain_Insert_unprotected( after->Node.previous, &the_watchdog->Node );
88
 
89
  the_watchdog->start_time = _Watchdog_Ticks_since_boot;
90
 
91
exit_insert:
92
  _Watchdog_Sync_level = insert_isr_nest_level;
93
  _Watchdog_Sync_count--;
94
  _ISR_Enable( level );
95
}
96
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.