Changeset bcf536a in rtems


Ignore:
Timestamp:
Apr 10, 2015, 1:51:50 PM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
54cf0e34
Parents:
a1d6f7a
git-author:
Sebastian Huber <sebastian.huber@…> (04/10/15 13:51:50)
git-committer:
Sebastian Huber <sebastian.huber@…> (04/13/15 11:08:55)
Message:

score: Split _Watchdog_Adjust()

Split _Watchdog_Adjust() into _Watchdog_Adjust_backward() and
_Watchdog_Adjust_forward(). Remove Watchdog_Adjust_directions,
_Watchdog_Adjust_seconds() and _Watchdog_Adjust_ticks(). This avoids to
check the same condition again.

Update #2307.

Location:
cpukit
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • cpukit/rtems/src/timerserver.c

    ra1d6f7a rbcf536a  
    276276      */
    277277     delta = last_snapshot - snapshot;
    278      _Watchdog_Adjust( &watchdogs->Chain, WATCHDOG_BACKWARD, delta );
     278     _Watchdog_Adjust_backward( &watchdogs->Chain, delta );
    279279  }
    280280
  • cpukit/score/include/rtems/score/watchdogimpl.h

    ra1d6f7a rbcf536a  
    5454
    5555/**
    56  *  @brief the manner in which a watchdog chain may
    57  *  be adjusted by the @ref _Watchdog_Adjust routine.
    58  *
    59  *  The following enumerated type details the manner in which
    60  *  a watchdog chain may be adjusted by the @ref _Watchdog_Adjust
    61  *  routine.  The direction indicates a movement FORWARD
    62  *  or BACKWARD in time.
    63  */
    64 typedef enum {
    65   /** adjust delta value forward */
    66   WATCHDOG_FORWARD,
    67   /** adjust delta value backward */
    68   WATCHDOG_BACKWARD
    69 } Watchdog_Adjust_directions;
    70 
    71 /**
    7256 *  @brief Watchdog synchronization level.
    7357 *
     
    122106
    123107/**
    124  *  @brief Adjusts the @a header watchdog chain in the forward
    125  *  or backward @a direction for @a units ticks.
    126  *
    127  *  This routine adjusts the @a header watchdog chain in the forward
    128  *  or backward @a direction for @a units ticks.
    129  *
    130  *  @param[in] header is the watchdog chain to adjust
    131  *  @param[in] direction is the direction to adjust @a header
    132  *  @param[in] units is the number of units to adjust @a header
    133  */
    134 void _Watchdog_Adjust (
    135   Chain_Control              *header,
    136   Watchdog_Adjust_directions  direction,
    137   Watchdog_Interval           units
     108 *  @brief Adjusts the header watchdog chain in the backward direction for
     109 *  units ticks.
     110 *
     111 *  @param[in] header The watchdog chain.
     112 *  @param[in] units The units of ticks to adjust.
     113 */
     114void _Watchdog_Adjust_backward(
     115  Chain_Control     *header,
     116  Watchdog_Interval  units
     117);
     118
     119/**
     120 *  @brief Adjusts the header watchdog chain in the forward direction for units
     121 *  ticks.
     122 *
     123 *  This may lead to several _Watchdog_Tickle() invocations.
     124 *
     125 *  @param[in] header The watchdog chain.
     126 *  @param[in] units The units of ticks to adjust.
     127 */
     128void _Watchdog_Adjust_forward(
     129  Chain_Control     *header,
     130  Watchdog_Interval  units
    138131);
    139132
     
    313306
    314307/**
    315  * This routine adjusts the seconds watchdog chain in the forward
    316  * or backward DIRECTION for UNITS seconds.  This is invoked when the
    317  * current time of day is changed.
    318  */
    319 
    320 RTEMS_INLINE_ROUTINE void _Watchdog_Adjust_seconds(
    321   Watchdog_Adjust_directions direction,
    322   Watchdog_Interval          units
    323 )
    324 {
    325 
    326   _Watchdog_Adjust( &_Watchdog_Seconds_chain, direction, units );
    327 
    328 }
    329 
    330 /**
    331  * This routine adjusts the ticks watchdog chain in the forward
    332  * or backward DIRECTION for UNITS ticks.
    333  */
    334 
    335 RTEMS_INLINE_ROUTINE void _Watchdog_Adjust_ticks(
    336   Watchdog_Adjust_directions direction,
    337   Watchdog_Interval          units
    338 )
    339 {
    340 
    341   _Watchdog_Adjust( &_Watchdog_Ticks_chain, direction, units );
    342 
    343 }
    344 
    345 /**
    346308 * This routine resets THE_WATCHDOG timer to its state at INSERT
    347309 * time.  This routine is valid only on interval watchdog timers
  • cpukit/score/src/coretodset.c

    ra1d6f7a rbcf536a  
    3232  Watchdog_Interval seconds_now;
    3333  ISR_lock_Context lock_context;
     34  Chain_Control *header;
    3435
    3536  _Thread_Disable_dispatch();
    3637
    3738  seconds_now = _TOD_Seconds_since_epoch();
     39  header = &_Watchdog_Seconds_chain;
    3840
    3941  if ( seconds_next < seconds_now )
    40     _Watchdog_Adjust_seconds( WATCHDOG_BACKWARD, seconds_now - seconds_next );
     42    _Watchdog_Adjust_backward( header, seconds_now - seconds_next );
    4143  else
    42     _Watchdog_Adjust_seconds( WATCHDOG_FORWARD, seconds_next - seconds_now );
     44    _Watchdog_Adjust_forward( header, seconds_next - seconds_now );
    4345
    4446  _TOD_Acquire( tod, &lock_context );
  • cpukit/score/src/watchdogadjust.c

    ra1d6f7a rbcf536a  
    1919#endif
    2020
    21 #include <rtems/system.h>
    22 #include <rtems/score/isr.h>
    2321#include <rtems/score/watchdogimpl.h>
     22#include <rtems/score/chainimpl.h>
     23#include <rtems/score/isrlevel.h>
    2424
    25 void _Watchdog_Adjust(
    26   Chain_Control               *header,
    27   Watchdog_Adjust_directions   direction,
    28   Watchdog_Interval            units
     25void _Watchdog_Adjust_backward(
     26  Chain_Control     *header,
     27  Watchdog_Interval  units
    2928)
    3029{
     
    3332  _ISR_Disable( level );
    3433
    35   /*
    36    * NOTE: It is safe NOT to make 'header' a pointer
    37    *       to volatile data (contrast this with watchdoginsert.c)
    38    *       because we call _Watchdog_Tickle() below and
    39    *       hence the compiler must not assume *header to remain
    40    *       unmodified across that call.
    41    *
    42    *       Till Straumann, 7/2003
    43    */
    4434  if ( !_Chain_Is_empty( header ) ) {
    45     switch ( direction ) {
    46       case WATCHDOG_BACKWARD:
    47         _Watchdog_First( header )->delta_interval += units;
    48         break;
    49       case WATCHDOG_FORWARD:
    50         while ( units ) {
    51           if ( units < _Watchdog_First( header )->delta_interval ) {
    52             _Watchdog_First( header )->delta_interval -= units;
    53             break;
    54           } else {
    55             units -= _Watchdog_First( header )->delta_interval;
    56             _Watchdog_First( header )->delta_interval = 1;
     35     _Watchdog_First( header )->delta_interval += units;
     36  }
    5737
    58             _ISR_Enable( level );
     38  _ISR_Enable( level );
     39}
    5940
    60             _Watchdog_Tickle( header );
     41void _Watchdog_Adjust_forward(
     42  Chain_Control     *header,
     43  Watchdog_Interval  units
     44)
     45{
     46  ISR_Level level;
    6147
    62             _ISR_Disable( level );
     48  _ISR_Disable( level );
    6349
    64             if ( _Chain_Is_empty( header ) )
    65               break;
    66           }
    67         }
    68         break;
     50  while ( !_Chain_Is_empty( header ) && units > 0 ) {
     51    Watchdog_Control *first = _Watchdog_First( header );
     52
     53    if ( units < first->delta_interval ) {
     54      first->delta_interval -= units;
     55      break;
     56    } else {
     57      units -= first->delta_interval;
     58      first->delta_interval = 1;
     59
     60      _ISR_Enable( level );
     61
     62      _Watchdog_Tickle( header );
     63
     64      _ISR_Disable( level );
    6965    }
    7066  }
    7167
    7268  _ISR_Enable( level );
    73 
    7469}
Note: See TracChangeset for help on using the changeset viewer.