Changeset 80fca28 in rtems


Ignore:
Timestamp:
Jun 13, 2015, 1:29:04 PM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
e6b31b27
Parents:
258d580c
git-author:
Sebastian Huber <sebastian.huber@…> (06/13/15 13:29:04)
git-committer:
Sebastian Huber <sebastian.huber@…> (06/13/15 13:51:21)
Message:

score: Add _Watchdog_Preinitialize()

Add an assert to ensure that the watchdog is the proper state for a
_Watchdog_Initialize(). This helps to detect invalid initializations
which may lead to a corrupt watchdog chain.

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • cpukit/posix/src/pthread.c

    r258d580c r80fca28  
    242242  _Thread_queue_Initialize( &api->Join_List, THREAD_QUEUE_DISCIPLINE_FIFO );
    243243
     244  _Watchdog_Preinitialize( &api->Sporadic_timer );
    244245  _Watchdog_Initialize(
    245246    &api->Sporadic_timer,
  • cpukit/posix/src/timercreate.c

    r258d580c r80fca28  
    9393  ptimer->timer_data.it_interval.tv_nsec = 0;
    9494
    95   _Watchdog_Initialize( &ptimer->Timer, NULL, 0, NULL );
     95  _Watchdog_Preinitialize( &ptimer->Timer );
    9696  _Objects_Open_u32(&_POSIX_Timer_Information, &ptimer->Object, 0);
    9797
  • cpukit/rtems/src/ratemoncreate.c

    r258d580c r80fca28  
    6666  the_period->state = RATE_MONOTONIC_INACTIVE;
    6767
    68   _Watchdog_Initialize( &the_period->Timer, NULL, 0, NULL );
     68  _Watchdog_Preinitialize( &the_period->Timer );
    6969
    7070  _Rate_monotonic_Reset_statistics( the_period );
  • cpukit/rtems/src/timercreate.c

    r258d580c r80fca28  
    7676
    7777  the_timer->the_class = TIMER_DORMANT;
    78   _Watchdog_Initialize( &the_timer->Ticker, NULL, 0, NULL );
     78  _Watchdog_Preinitialize( &the_timer->Ticker );
    7979
    8080  _Objects_Open(
  • cpukit/rtems/src/timerserver.c

    r258d580c r80fca28  
    299299
    300300  _Watchdog_Header_initialize( &watchdogs->Header );
     301  _Watchdog_Preinitialize( &watchdogs->System_watchdog );
    301302  _Watchdog_Initialize(
    302303    &watchdogs->System_watchdog,
  • cpukit/score/include/rtems/score/watchdogimpl.h

    r258d580c r80fca28  
    2121
    2222#include <rtems/score/watchdog.h>
     23#include <rtems/score/assert.h>
    2324#include <rtems/score/chainimpl.h>
    2425#include <rtems/score/isrlock.h>
     
    271272
    272273/**
     274 * @brief Pre-initializes a watchdog.
     275 *
     276 * This routine must be called before a watchdog is used in any way.  The
     277 * exception are statically initialized watchdogs via WATCHDOG_INITIALIZER().
     278 *
     279 * @param[in] the_watchdog The uninitialized watchdog.
     280 */
     281RTEMS_INLINE_ROUTINE void _Watchdog_Preinitialize(
     282  Watchdog_Control *the_watchdog
     283)
     284{
     285  the_watchdog->state = WATCHDOG_INACTIVE;
     286#if defined(RTEMS_DEBUG)
     287  the_watchdog->routine = NULL;
     288  the_watchdog->id = 0;
     289  the_watchdog->user_data = NULL;
     290#endif
     291}
     292
     293/**
    273294 * This routine initializes the specified watchdog.  The watchdog is
    274295 * made inactive, the watchdog id and handler routine are set to the
     
    283304)
    284305{
    285   the_watchdog->state     = WATCHDOG_INACTIVE;
     306  _Assert( the_watchdog->state == WATCHDOG_INACTIVE );
    286307  the_watchdog->routine   = routine;
    287308  the_watchdog->id        = id;
  • cpukit/score/src/threadinitialize.c

    r258d580c r80fca28  
    138138   *  Initialize the thread timer
    139139   */
    140   _Watchdog_Initialize( &the_thread->Timer, NULL, 0, NULL );
     140  _Watchdog_Preinitialize( &the_thread->Timer );
    141141
    142142  #ifdef __RTEMS_STRICT_ORDER_MUTEX__
  • testsuites/sptests/spwatchdog/init.c

    r258d580c r80fca28  
    4949  rtems_test_assert( _Chain_Is_empty( &header->Iterators ) );
    5050
    51   _Watchdog_Initialize( c, NULL, 0, NULL );
     51  _Watchdog_Preinitialize( c );
    5252  c->initial = 6;
    5353  _Watchdog_Insert( header, c );
     
    5757  rtems_test_assert( _Chain_Is_empty( &header->Iterators ) );
    5858
    59   _Watchdog_Initialize( a, NULL, 0, NULL );
     59  _Watchdog_Preinitialize( a );
    6060  a->initial = 2;
    6161  _Watchdog_Insert( header, a );
     
    6363  rtems_test_assert( c->delta_interval == 4 );
    6464
    65   _Watchdog_Initialize( b, NULL, 0, NULL );
     65  _Watchdog_Preinitialize( b );
    6666  b->initial = 4;
    6767  _Watchdog_Insert( header, b );
     
    7070  rtems_test_assert( c->delta_interval == 2 );
    7171
    72   _Watchdog_Initialize( d, NULL, 0, NULL );
     72  _Watchdog_Preinitialize( d );
    7373}
    7474
Note: See TracChangeset for help on using the changeset viewer.