source: rtems/cpukit/score/src/watchdoginsert.c @ 6d253941

4.115
Last change on this file since 6d253941 was 6d253941, checked in by Sebastian Huber <sebastian.huber@…>, on 04/15/15 at 14:28:42

score: Add _Watchdog_Acquire|Release|Flash()

Update #2307.

  • Property mode set to 100644
File size: 2.1 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/score/watchdogimpl.h>
22#include <rtems/score/isrlevel.h>
23#include <rtems/score/percpu.h>
24
25void _Watchdog_Insert(
26  Watchdog_Header       *header,
27  Watchdog_Control      *the_watchdog
28)
29{
30  ISR_lock_Context   lock_context;
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  _Watchdog_Acquire( header, &lock_context );
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    _Watchdog_Release( header, &lock_context );
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     _Watchdog_Flash( header, &lock_context );
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  _Watchdog_Release( header, &lock_context );
94}
Note: See TracBrowser for help on using the repository browser.