Changeset cfc257fc in rtems


Ignore:
Timestamp:
Jul 18, 2003, 2:47:36 PM (18 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Children:
367a0e2
Parents:
8f51fa52
Message:

2003-07-18 Till Straumann <strauman@…>

PR 430/rtems

  • include/rtems/score/watchdog.h: _Watchdog_Ticks_since_boot should be a VOLATILE variable.
  • src/watchdoginsert.c: 'restart' algorithm needs to enforce reloading the list head in case a TICK interrupt during ISR_Flash() modified the list. This is achieved by a proper VOLATILE cast. Also _Watchdog_Sync_count++ should be protected by _ISR_Disable (prevent corruption in case ISR calls watchdoginsert)
  • src/watchdogadjust.c: ISR protection added.
  • src/watchdogtickle.c: ISR protection added. NOTE: PowerPC BSPs using the new exception processing MUST BE UPDATED to maintain _ISR_Nest_level. See also PR288 which provides fixes for the affected BSPs distributed with RTEMS.
Location:
cpukit/score
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/ChangeLog

    r8f51fa52 rcfc257fc  
     12003-07-18      Till Straumann <strauman@slac.stanford.edu>
     2
     3        PR 430/rtems
     4        * include/rtems/score/watchdog.h: _Watchdog_Ticks_since_boot should
     5        be a VOLATILE variable.
     6        * src/watchdoginsert.c: 'restart' algorithm needs to enforce
     7        reloading the list head in case a TICK interrupt during ISR_Flash()
     8        modified the list.  This is achieved by a proper VOLATILE cast.
     9        Also _Watchdog_Sync_count++ should be protected by _ISR_Disable
     10        (prevent corruption in case ISR calls watchdoginsert)
     11        * src/watchdogadjust.c: ISR protection added.
     12        * src/watchdogtickle.c: ISR protection added.
     13        NOTE: PowerPC BSPs using the new exception processing MUST BE UPDATED
     14        to maintain _ISR_Nest_level. See also PR288 which provides fixes
     15        for the affected BSPs distributed with RTEMS.
     16
    1172003-07-07      Joel Sherrill <joel@OARcorp.com>
    218
  • cpukit/score/include/rtems/score/watchdog.h

    r8f51fa52 rcfc257fc  
    104104 */
    105105
    106 SCORE_EXTERN Watchdog_Interval _Watchdog_Ticks_since_boot;
     106SCORE_EXTERN volatile Watchdog_Interval _Watchdog_Ticks_since_boot;
    107107
    108108/*
  • cpukit/score/src/watchdogadjust.c

    r8f51fa52 rcfc257fc  
    3838)
    3939{
     40  ISR_Level level;
     41
     42  _ISR_Disable( level );
     43
     44  /*
     45   * NOTE: It is safe NOT to make 'header' a pointer
     46   *       to volatile data (contrast this with watchdoginsert.c)
     47   *       because we call _Watchdog_Tickle() below and
     48   *       hence the compiler must not assume *header to remain
     49   *       unmodified across that call.
     50   *
     51   *       Till Straumann, 7/2003
     52   */
    4053  if ( !_Chain_Is_empty( header ) ) {
    4154    switch ( direction ) {
     
    5164            units -= _Watchdog_First( header )->delta_interval;
    5265            _Watchdog_First( header )->delta_interval = 1;
     66
     67                        _ISR_Enable( level );
     68
    5369            _Watchdog_Tickle( header );
     70
     71                        _ISR_Disable( level );
     72
    5473            if ( _Chain_Is_empty( header ) )
    5574              break;
     
    5978    }
    6079  }
     80
     81  _ISR_Enable( level );
     82
    6183}
    6284
  • cpukit/score/src/watchdoginsert.c

    r8f51fa52 rcfc257fc  
    3939  the_watchdog->state = WATCHDOG_BEING_INSERTED;
    4040
     41  _ISR_Disable( level );
     42
    4143  _Watchdog_Sync_count++;
     44
    4245restart:
    4346  delta_interval = the_watchdog->initial;
    4447
    45   _ISR_Disable( level );
    46 
    47   for ( after = _Watchdog_First( header ) ;
     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 ;
    4863        ;
    4964        after = _Watchdog_Next( after ) ) {
     
    7691     if ( _Watchdog_Sync_level > insert_isr_nest_level ) {
    7792       _Watchdog_Sync_level = insert_isr_nest_level;
    78        _ISR_Enable( level );
    7993       goto restart;
    8094     }
  • cpukit/score/src/watchdogtickle.c

    r8f51fa52 rcfc257fc  
    3434)
    3535{
     36  ISR_Level level;
    3637  Watchdog_Control *the_watchdog;
     38  Watchdog_States  watchdog_state;
     39
     40  /*
     41   * See the comment in watchdoginsert.c and watchdogadjust.c
     42   * about why it's safe not to declare header a pointer to
     43   * volatile data - till, 2003/7
     44   */
     45
     46  _ISR_Disable( level );
    3747
    3848  if ( _Chain_Is_empty( header ) )
    39     return;
     49    goto leave;
    4050
    4151  the_watchdog = _Watchdog_First( header );
    4252  the_watchdog->delta_interval--;
    4353  if ( the_watchdog->delta_interval != 0 )
    44     return;
     54    goto leave;
    4555
    4656  do {
    47      switch( _Watchdog_Remove( the_watchdog ) ) {
     57         watchdog_state = _Watchdog_Remove( the_watchdog );
     58
     59         _ISR_Enable( level );
     60
     61     switch( watchdog_state ) {
    4862       case WATCHDOG_ACTIVE:
    4963         (*the_watchdog->routine)(
     
    7286         break;
    7387     }
     88
     89         _ISR_Disable( level );
     90
    7491     the_watchdog = _Watchdog_First( header );
    7592   } while ( !_Chain_Is_empty( header ) &&
    7693             (the_watchdog->delta_interval == 0) );
     94
     95leave:
     96   _ISR_Enable(level);
    7797}
Note: See TracChangeset for help on using the changeset viewer.