[PATCH] score: Add and use _Objects_Get_local()

Gedare Bloom gedare at rtems.org
Thu Mar 10 17:16:15 UTC 2016


looks ok

On Mon, Mar 7, 2016 at 10:03 AM, Sebastian Huber
<sebastian.huber at embedded-brains.de> wrote:
> This simplifies the handling with local-only objects.
>
> Update #2555.
> ---
>  cpukit/posix/include/rtems/posix/timerimpl.h  |  4 +-
>  cpukit/posix/src/timerdelete.c                | 36 +++++--------
>  cpukit/posix/src/timergetoverrun.c            | 26 ++++-----
>  cpukit/posix/src/timergettime.c               | 37 +++++--------
>  cpukit/posix/src/timersettime.c               | 78 ++++++++++++---------------
>  cpukit/rtems/include/rtems/rtems/timerimpl.h  |  4 +-
>  cpukit/rtems/src/timercancel.c                | 26 ++++-----
>  cpukit/rtems/src/timercreate.c                | 72 +++++++++++--------------
>  cpukit/rtems/src/timerdelete.c                | 36 +++++--------
>  cpukit/rtems/src/timergetinfo.c               | 39 +++++---------
>  cpukit/rtems/src/timerreset.c                 | 74 +++++++++----------------
>  cpukit/score/Makefile.am                      |  1 +
>  cpukit/score/include/rtems/score/objectimpl.h | 23 ++++++++
>  cpukit/score/src/objectgetlocal.c             | 52 ++++++++++++++++++
>  14 files changed, 242 insertions(+), 266 deletions(-)
>  create mode 100644 cpukit/score/src/objectgetlocal.c
>
> diff --git a/cpukit/posix/include/rtems/posix/timerimpl.h b/cpukit/posix/include/rtems/posix/timerimpl.h
> index 2eefd70..bf25629 100644
> --- a/cpukit/posix/include/rtems/posix/timerimpl.h
> +++ b/cpukit/posix/include/rtems/posix/timerimpl.h
> @@ -94,14 +94,12 @@ void _POSIX_Timer_TSR( Watchdog_Control *the_watchdog );
>   */
>  RTEMS_INLINE_ROUTINE POSIX_Timer_Control *_POSIX_Timer_Get (
>    timer_t            id,
> -  Objects_Locations *location,
>    ISR_lock_Context  *lock_context
>  )
>  {
> -  return (POSIX_Timer_Control *) _Objects_Get_isr_disable(
> +  return (POSIX_Timer_Control *) _Objects_Get_local(
>      &_POSIX_Timer_Information,
>      (Objects_Id) id,
> -    location,
>      lock_context
>    );
>  }
> diff --git a/cpukit/posix/src/timerdelete.c b/cpukit/posix/src/timerdelete.c
> index c39de8e..5301a70 100644
> --- a/cpukit/posix/src/timerdelete.c
> +++ b/cpukit/posix/src/timerdelete.c
> @@ -44,33 +44,25 @@ int timer_delete(
>    *       because rtems_timer_delete stops the timer before deleting it.
>    */
>    POSIX_Timer_Control *ptimer;
> -  Objects_Locations    location;
>    ISR_lock_Context     lock_context;
> -  Per_CPU_Control     *cpu;
>
>    _Objects_Allocator_lock();
> -  ptimer = _POSIX_Timer_Get( timerid, &location, &lock_context );
> -  switch ( location ) {
>
> -    case OBJECTS_LOCAL:
> -      _Objects_Close( &_POSIX_Timer_Information, &ptimer->Object );
> -      cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
> -      ptimer->state = POSIX_TIMER_STATE_FREE;
> -      _Watchdog_Remove(
> -        &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ],
> -        &ptimer->Timer
> -      );
> -      _POSIX_Timer_Release( cpu, &lock_context );
> -      _POSIX_Timer_Free( ptimer );
> -      _Objects_Allocator_unlock();
> +  ptimer = _POSIX_Timer_Get( timerid, &lock_context );
> +  if ( ptimer != NULL ) {
> +    Per_CPU_Control *cpu;
>
> -      return 0;
> -
> -#if defined(RTEMS_MULTIPROCESSING)
> -    case OBJECTS_REMOTE:
> -#endif
> -    case OBJECTS_ERROR:
> -      break;
> +    _Objects_Close( &_POSIX_Timer_Information, &ptimer->Object );
> +    cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
> +    ptimer->state = POSIX_TIMER_STATE_FREE;
> +    _Watchdog_Remove(
> +      &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ],
> +      &ptimer->Timer
> +    );
> +    _POSIX_Timer_Release( cpu, &lock_context );
> +    _POSIX_Timer_Free( ptimer );
> +    _Objects_Allocator_unlock();
> +    return 0;
>    }
>
>    _Objects_Allocator_unlock();
> diff --git a/cpukit/posix/src/timergetoverrun.c b/cpukit/posix/src/timergetoverrun.c
> index 0a28fa7..0a7b9fa 100644
> --- a/cpukit/posix/src/timergetoverrun.c
> +++ b/cpukit/posix/src/timergetoverrun.c
> @@ -30,27 +30,19 @@ int timer_getoverrun(
>    timer_t   timerid
>  )
>  {
> -  int                  overrun;
>    POSIX_Timer_Control *ptimer;
> -  Objects_Locations    location;
>    ISR_lock_Context     lock_context;
> -  Per_CPU_Control     *cpu;
>
> -  ptimer = _POSIX_Timer_Get( timerid, &location, &lock_context );
> -  switch ( location ) {
> +  ptimer = _POSIX_Timer_Get( timerid, &lock_context );
> +  if ( ptimer != NULL ) {
> +    Per_CPU_Control *cpu;
> +    int              overrun;
>
> -    case OBJECTS_LOCAL:
> -      cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
> -      overrun = ptimer->overrun;
> -      ptimer->overrun = 0;
> -      _POSIX_Timer_Release( cpu, &lock_context );
> -      return overrun;
> -
> -#if defined(RTEMS_MULTIPROCESSING)
> -    case OBJECTS_REMOTE:
> -#endif
> -    case OBJECTS_ERROR:
> -      break;
> +    cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
> +    overrun = ptimer->overrun;
> +    ptimer->overrun = 0;
> +    _POSIX_Timer_Release( cpu, &lock_context );
> +    return overrun;
>    }
>
>    rtems_set_errno_and_return_minus_one( EINVAL );
> diff --git a/cpukit/posix/src/timergettime.c b/cpukit/posix/src/timergettime.c
> index 7f0015b..66708e9 100644
> --- a/cpukit/posix/src/timergettime.c
> +++ b/cpukit/posix/src/timergettime.c
> @@ -41,40 +41,31 @@ int timer_gettime(
>  )
>  {
>    POSIX_Timer_Control *ptimer;
> -  Objects_Locations    location;
>    ISR_lock_Context     lock_context;
> -  Per_CPU_Control     *cpu;
>    uint64_t             now;
>    uint32_t             remaining;
>
>    if ( !value )
>      rtems_set_errno_and_return_minus_one( EINVAL );
>
> -  ptimer = _POSIX_Timer_Get( timerid, &location, &lock_context );
> -  switch ( location ) {
> +  ptimer = _POSIX_Timer_Get( timerid, &lock_context );
> +  if ( ptimer != NULL ) {
> +    Per_CPU_Control *cpu;
>
> -    case OBJECTS_LOCAL:
> +    cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
> +    now = cpu->Watchdog.ticks;
>
> -      cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
> -      now = cpu->Watchdog.ticks;
> +    if ( now < ptimer->Timer.expire ) {
> +      remaining = (uint32_t) ( ptimer->Timer.expire - now );
> +    } else {
> +      remaining = 0;
> +    }
>
> -      if ( now < ptimer->Timer.expire ) {
> -        remaining = (uint32_t) ( ptimer->Timer.expire - now );
> -      } else {
> -        remaining = 0;
> -      }
> +    _Timespec_From_ticks( remaining, &value->it_value );
> +    value->it_interval = ptimer->timer_data.it_interval;
>
> -      _Timespec_From_ticks( remaining, &value->it_value );
> -      value->it_interval = ptimer->timer_data.it_interval;
> -
> -      _POSIX_Timer_Release( cpu, &lock_context );
> -      return 0;
> -
> -#if defined(RTEMS_MULTIPROCESSING)
> -    case OBJECTS_REMOTE:
> -#endif
> -    case OBJECTS_ERROR:
> -      break;
> +    _POSIX_Timer_Release( cpu, &lock_context );
> +    return 0;
>    }
>
>    rtems_set_errno_and_return_minus_one( EINVAL );
> diff --git a/cpukit/posix/src/timersettime.c b/cpukit/posix/src/timersettime.c
> index ac5c258..51678ca 100644
> --- a/cpukit/posix/src/timersettime.c
> +++ b/cpukit/posix/src/timersettime.c
> @@ -107,9 +107,7 @@ int timer_settime(
>  )
>  {
>    POSIX_Timer_Control *ptimer;
> -  Objects_Locations    location;
>    ISR_lock_Context     lock_context;
> -  Per_CPU_Control     *cpu;
>    uint32_t             initial_period;
>    struct itimerspec    normalize;
>
> @@ -148,53 +146,47 @@ int timer_settime(
>     * or start it again
>     */
>
> -  ptimer = _POSIX_Timer_Get( timerid, &location, &lock_context );
> -  switch ( location ) {
> -
> -    case OBJECTS_LOCAL:
> -      cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
> -
> -      /* Stop the timer */
> -      _Watchdog_Remove(
> -        &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ],
> -        &ptimer->Timer
> -      );
> -
> -      /* First, it verifies if the timer must be stopped */
> -      if ( normalize.it_value.tv_sec == 0 && normalize.it_value.tv_nsec == 0 ) {
> -        /* The old data of the timer are returned */
> -        if ( ovalue )
> -          *ovalue = ptimer->timer_data;
> -        /* The new data are set */
> -        ptimer->timer_data = normalize;
> -        /* Indicates that the timer is created and stopped */
> -        ptimer->state = POSIX_TIMER_STATE_CREATE_STOP;
> -        /* Returns with success */
> -        _POSIX_Timer_Release( cpu, &lock_context );
> -        return 0;
> -      }
> -
> -      /* Convert from seconds and nanoseconds to ticks */
> -      ptimer->ticks  = _Timespec_To_ticks( &value->it_interval );
> -      initial_period = _Timespec_To_ticks( &normalize.it_value );
> -
> -      _POSIX_Timer_Insert( ptimer, cpu, initial_period );
> -
> -      /*
> -       * The timer has been started and is running.  So we return the
> -       * old ones in "ovalue"
> -       */
> +  ptimer = _POSIX_Timer_Get( timerid, &lock_context );
> +  if ( ptimer != NULL ) {
> +    Per_CPU_Control *cpu;
> +
> +    cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
> +
> +    /* Stop the timer */
> +    _Watchdog_Remove(
> +      &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ],
> +      &ptimer->Timer
> +    );
> +
> +    /* First, it verifies if the timer must be stopped */
> +    if ( normalize.it_value.tv_sec == 0 && normalize.it_value.tv_nsec == 0 ) {
> +      /* The old data of the timer are returned */
>        if ( ovalue )
>          *ovalue = ptimer->timer_data;
> +      /* The new data are set */
>        ptimer->timer_data = normalize;
> +      /* Indicates that the timer is created and stopped */
> +      ptimer->state = POSIX_TIMER_STATE_CREATE_STOP;
> +      /* Returns with success */
>        _POSIX_Timer_Release( cpu, &lock_context );
>        return 0;
> +    }
>
> -#if defined(RTEMS_MULTIPROCESSING)
> -    case OBJECTS_REMOTE:
> -#endif
> -    case OBJECTS_ERROR:
> -      break;
> +    /* Convert from seconds and nanoseconds to ticks */
> +    ptimer->ticks  = _Timespec_To_ticks( &value->it_interval );
> +    initial_period = _Timespec_To_ticks( &normalize.it_value );
> +
> +    _POSIX_Timer_Insert( ptimer, cpu, initial_period );
> +
> +    /*
> +     * The timer has been started and is running.  So we return the
> +     * old ones in "ovalue"
> +     */
> +    if ( ovalue )
> +      *ovalue = ptimer->timer_data;
> +    ptimer->timer_data = normalize;
> +    _POSIX_Timer_Release( cpu, &lock_context );
> +    return 0;
>    }
>
>    rtems_set_errno_and_return_minus_one( EINVAL );
> diff --git a/cpukit/rtems/include/rtems/rtems/timerimpl.h b/cpukit/rtems/include/rtems/rtems/timerimpl.h
> index e4b4ca2..40e2b5f 100644
> --- a/cpukit/rtems/include/rtems/rtems/timerimpl.h
> +++ b/cpukit/rtems/include/rtems/rtems/timerimpl.h
> @@ -84,14 +84,12 @@ RTEMS_INLINE_ROUTINE void _Timer_Free (
>
>  RTEMS_INLINE_ROUTINE Timer_Control *_Timer_Get(
>    Objects_Id         id,
> -  Objects_Locations *location,
>    ISR_lock_Context  *lock_context
>  )
>  {
> -  return (Timer_Control *) _Objects_Get_isr_disable(
> +  return (Timer_Control *) _Objects_Get_local(
>      &_Timer_Information,
>      id,
> -    location,
>      lock_context
>    );
>  }
> diff --git a/cpukit/rtems/src/timercancel.c b/cpukit/rtems/src/timercancel.c
> index 5d4343e..a69f38e 100644
> --- a/cpukit/rtems/src/timercancel.c
> +++ b/cpukit/rtems/src/timercancel.c
> @@ -20,25 +20,17 @@ rtems_status_code rtems_timer_cancel(
>    rtems_id id
>  )
>  {
> -  Timer_Control     *the_timer;
> -  Objects_Locations  location;
> -  ISR_lock_Context   lock_context;
> -  Per_CPU_Control   *cpu;
> +  Timer_Control    *the_timer;
> +  ISR_lock_Context  lock_context;
>
> -  the_timer = _Timer_Get( id, &location, &lock_context );
> -  switch ( location ) {
> +  the_timer = _Timer_Get( id, &lock_context );
> +  if ( the_timer != NULL ) {
> +    Per_CPU_Control *cpu;
>
> -    case OBJECTS_LOCAL:
> -      cpu = _Timer_Acquire_critical( the_timer, &lock_context );
> -      _Timer_Cancel( cpu, the_timer );
> -      _Timer_Release( cpu, &lock_context );
> -      return RTEMS_SUCCESSFUL;
> -
> -#if defined(RTEMS_MULTIPROCESSING)
> -    case OBJECTS_REMOTE:            /* should never return this */
> -#endif
> -    case OBJECTS_ERROR:
> -      break;
> +    cpu = _Timer_Acquire_critical( the_timer, &lock_context );
> +    _Timer_Cancel( cpu, the_timer );
> +    _Timer_Release( cpu, &lock_context );
> +    return RTEMS_SUCCESSFUL;
>    }
>
>    return RTEMS_INVALID_ID;
> diff --git a/cpukit/rtems/src/timercreate.c b/cpukit/rtems/src/timercreate.c
> index 80c1356..fc6d43e 100644
> --- a/cpukit/rtems/src/timercreate.c
> +++ b/cpukit/rtems/src/timercreate.c
> @@ -54,46 +54,38 @@ rtems_status_code _Timer_Fire(
>    Watchdog_Service_routine_entry     adaptor
>  )
>  {
> -  Timer_Control        *the_timer;
> -  Objects_Locations     location;
> -  ISR_lock_Context      lock_context;
> -  Per_CPU_Control      *cpu;
> -
> -  the_timer = _Timer_Get( id, &location, &lock_context );
> -  switch ( location ) {
> -
> -    case OBJECTS_LOCAL:
> -      cpu = _Timer_Acquire_critical( the_timer, &lock_context );
> -      _Timer_Cancel( cpu, the_timer );
> -      _Watchdog_Initialize( &the_timer->Ticker, adaptor );
> -      the_timer->the_class = the_class;
> -      the_timer->routine = routine;
> -      the_timer->user_data = user_data;
> -      the_timer->initial = interval;
> -      the_timer->start_time = _Timer_Get_CPU_ticks( cpu );
> -
> -      if ( _Timer_Is_interval_class( the_class ) ) {
> -        _Watchdog_Insert(
> -          &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ],
> -          &the_timer->Ticker,
> -          cpu->Watchdog.ticks + interval
> -        );
> -      } else {
> -        _Watchdog_Insert(
> -          &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_ABSOLUTE ],
> -          &the_timer->Ticker,
> -          _Watchdog_Ticks_from_seconds( interval )
> -        );
> -      }
> -
> -      _Timer_Release( cpu, &lock_context );
> -      return RTEMS_SUCCESSFUL;
> -
> -#if defined(RTEMS_MULTIPROCESSING)
> -    case OBJECTS_REMOTE:            /* should never return this */
> -#endif
> -    case OBJECTS_ERROR:
> -      break;
> +  Timer_Control    *the_timer;
> +  ISR_lock_Context  lock_context;
> +
> +  the_timer = _Timer_Get( id, &lock_context );
> +  if ( the_timer != NULL ) {
> +    Per_CPU_Control *cpu;
> +
> +    cpu = _Timer_Acquire_critical( the_timer, &lock_context );
> +    _Timer_Cancel( cpu, the_timer );
> +    _Watchdog_Initialize( &the_timer->Ticker, adaptor );
> +    the_timer->the_class = the_class;
> +    the_timer->routine = routine;
> +    the_timer->user_data = user_data;
> +    the_timer->initial = interval;
> +    the_timer->start_time = _Timer_Get_CPU_ticks( cpu );
> +
> +    if ( _Timer_Is_interval_class( the_class ) ) {
> +      _Watchdog_Insert(
> +        &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ],
> +        &the_timer->Ticker,
> +        cpu->Watchdog.ticks + interval
> +      );
> +    } else {
> +      _Watchdog_Insert(
> +        &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_ABSOLUTE ],
> +        &the_timer->Ticker,
> +        _Watchdog_Ticks_from_seconds( interval )
> +      );
> +    }
> +
> +    _Timer_Release( cpu, &lock_context );
> +    return RTEMS_SUCCESSFUL;
>    }
>
>    return RTEMS_INVALID_ID;
> diff --git a/cpukit/rtems/src/timerdelete.c b/cpukit/rtems/src/timerdelete.c
> index 9c41397..8b23c31 100644
> --- a/cpukit/rtems/src/timerdelete.c
> +++ b/cpukit/rtems/src/timerdelete.c
> @@ -24,32 +24,24 @@ rtems_status_code rtems_timer_delete(
>    rtems_id id
>  )
>  {
> -  Timer_Control     *the_timer;
> -  Objects_Locations  location;
> -  ISR_lock_Context   lock_context;
> -  Per_CPU_Control   *cpu;
> +  Timer_Control    *the_timer;
> +  ISR_lock_Context  lock_context;
>
>    _Objects_Allocator_lock();
> -  the_timer = _Timer_Get( id, &location, &lock_context );
> -  switch ( location ) {
> -
> -    case OBJECTS_LOCAL:
> -      _Objects_Close( &_Timer_Information, &the_timer->Object );
> -      cpu = _Timer_Acquire_critical( the_timer, &lock_context );
> -      _Timer_Cancel( cpu, the_timer );
> -      _Timer_Release( cpu, &lock_context );
> -      _Timer_Free( the_timer );
> -      _Objects_Allocator_unlock();
> -      return RTEMS_SUCCESSFUL;
> -
> -#if defined(RTEMS_MULTIPROCESSING)
> -    case OBJECTS_REMOTE:            /* should never return this */
> -#endif
> -    case OBJECTS_ERROR:
> -      break;
> +
> +  the_timer = _Timer_Get( id, &lock_context );
> +  if ( the_timer != NULL ) {
> +    Per_CPU_Control *cpu;
> +
> +    _Objects_Close( &_Timer_Information, &the_timer->Object );
> +    cpu = _Timer_Acquire_critical( the_timer, &lock_context );
> +    _Timer_Cancel( cpu, the_timer );
> +    _Timer_Release( cpu, &lock_context );
> +    _Timer_Free( the_timer );
> +    _Objects_Allocator_unlock();
> +    return RTEMS_SUCCESSFUL;
>    }
>
>    _Objects_Allocator_unlock();
> -
>    return RTEMS_INVALID_ID;
>  }
> diff --git a/cpukit/rtems/src/timergetinfo.c b/cpukit/rtems/src/timergetinfo.c
> index a11861c..804b0cf 100644
> --- a/cpukit/rtems/src/timergetinfo.c
> +++ b/cpukit/rtems/src/timergetinfo.c
> @@ -18,43 +18,30 @@
>  #include "config.h"
>  #endif
>
> -#include <rtems/system.h>
> -#include <rtems/rtems/status.h>
> -#include <rtems/rtems/support.h>
> -#include <rtems/score/thread.h>
>  #include <rtems/rtems/timerimpl.h>
> -#include <rtems/score/watchdog.h>
>
>  rtems_status_code rtems_timer_get_information(
>    rtems_id                 id,
>    rtems_timer_information *the_info
>  )
>  {
> -  Timer_Control     *the_timer;
> -  Objects_Locations  location;
> -  ISR_lock_Context   lock_context;
> -  Per_CPU_Control   *cpu;
> +  Timer_Control    *the_timer;
> +  ISR_lock_Context  lock_context;
>
>    if ( !the_info )
>      return RTEMS_INVALID_ADDRESS;
>
> -  the_timer = _Timer_Get( id, &location, &lock_context );
> -  switch ( location ) {
> -
> -    case OBJECTS_LOCAL:
> -      cpu = _Timer_Acquire_critical( the_timer, &lock_context );
> -      the_info->the_class  = the_timer->the_class;
> -      the_info->initial    = the_timer->initial;
> -      the_info->start_time = the_timer->start_time;
> -      the_info->stop_time  = the_timer->stop_time;
> -      _Timer_Release( cpu, &lock_context );
> -      return RTEMS_SUCCESSFUL;
> -
> -#if defined(RTEMS_MULTIPROCESSING)
> -    case OBJECTS_REMOTE:            /* should never return this */
> -#endif
> -    case OBJECTS_ERROR:
> -      break;
> +  the_timer = _Timer_Get( id, &lock_context );
> +  if ( the_timer != NULL ) {
> +    Per_CPU_Control *cpu;
> +
> +    cpu = _Timer_Acquire_critical( the_timer, &lock_context );
> +    the_info->the_class  = the_timer->the_class;
> +    the_info->initial    = the_timer->initial;
> +    the_info->start_time = the_timer->start_time;
> +    the_info->stop_time  = the_timer->stop_time;
> +    _Timer_Release( cpu, &lock_context );
> +    return RTEMS_SUCCESSFUL;
>    }
>
>    return RTEMS_INVALID_ID;
> diff --git a/cpukit/rtems/src/timerreset.c b/cpukit/rtems/src/timerreset.c
> index 72c912b..a409015 100644
> --- a/cpukit/rtems/src/timerreset.c
> +++ b/cpukit/rtems/src/timerreset.c
> @@ -18,62 +18,36 @@
>  #include "config.h"
>  #endif
>
> -#include <rtems/system.h>
> -#include <rtems/rtems/status.h>
> -#include <rtems/rtems/support.h>
> -#include <rtems/score/thread.h>
>  #include <rtems/rtems/timerimpl.h>
> -#include <rtems/score/watchdogimpl.h>
> -
> -/*
> - *  rtems_timer_reset
> - *
> - *  This directive allows a thread to reset a timer.
> - *
> - *  Input parameters:
> - *    id - timer id
> - *
> - *  Output parameters:
> - *    RTEMS_SUCCESSFUL - if successful
> - *    error code       - if unsuccessful
> - */
>
>  rtems_status_code rtems_timer_reset(
>    rtems_id id
>  )
>  {
> -  Timer_Control     *the_timer;
> -  Objects_Locations  location;
> -  ISR_lock_Context   lock_context;
> -  Per_CPU_Control   *cpu;
> -  rtems_status_code  status;
> -
> -  the_timer = _Timer_Get( id, &location, &lock_context );
> -  switch ( location ) {
> -
> -    case OBJECTS_LOCAL:
> -      cpu = _Timer_Acquire_critical( the_timer, &lock_context );
> -
> -      if ( _Timer_Is_interval_class( the_timer->the_class ) ) {
> -        _Timer_Cancel( cpu, the_timer );
> -        _Watchdog_Insert(
> -          &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ],
> -          &the_timer->Ticker,
> -          cpu->Watchdog.ticks + the_timer->initial
> -        );
> -        status = RTEMS_SUCCESSFUL;
> -      } else {
> -        status = RTEMS_NOT_DEFINED;
> -      }
> -
> -      _Timer_Release( cpu, &lock_context );
> -      return status;
> -
> -#if defined(RTEMS_MULTIPROCESSING)
> -    case OBJECTS_REMOTE:            /* should never return this */
> -#endif
> -    case OBJECTS_ERROR:
> -      break;
> +  Timer_Control    *the_timer;
> +  ISR_lock_Context  lock_context;
> +
> +  the_timer = _Timer_Get( id, &lock_context );
> +  if ( the_timer != NULL ) {
> +    Per_CPU_Control   *cpu;
> +    rtems_status_code  status;
> +
> +    cpu = _Timer_Acquire_critical( the_timer, &lock_context );
> +
> +    if ( _Timer_Is_interval_class( the_timer->the_class ) ) {
> +      _Timer_Cancel( cpu, the_timer );
> +      _Watchdog_Insert(
> +        &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ],
> +        &the_timer->Ticker,
> +        cpu->Watchdog.ticks + the_timer->initial
> +      );
> +      status = RTEMS_SUCCESSFUL;
> +    } else {
> +      status = RTEMS_NOT_DEFINED;
> +    }
> +
> +    _Timer_Release( cpu, &lock_context );
> +    return status;
>    }
>
>    return RTEMS_INVALID_ID;
> diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am
> index ea440b3..af78f15 100644
> --- a/cpukit/score/Makefile.am
> +++ b/cpukit/score/Makefile.am
> @@ -214,6 +214,7 @@ libscore_a_SOURCES += src/objectallocate.c src/objectclose.c \
>      src/objectgetinfo.c src/objectgetinfoid.c src/objectapimaximumclass.c \
>      src/objectnamespaceremove.c \
>      src/objectactivecount.c
> +libscore_a_SOURCES += src/objectgetlocal.c
>
>  ## SCHEDULER_C_FILES
>  libscore_a_SOURCES += src/log2table.c
> diff --git a/cpukit/score/include/rtems/score/objectimpl.h b/cpukit/score/include/rtems/score/objectimpl.h
> index f7bd69a..933e7e9 100644
> --- a/cpukit/score/include/rtems/score/objectimpl.h
> +++ b/cpukit/score/include/rtems/score/objectimpl.h
> @@ -559,6 +559,29 @@ Objects_Control *_Objects_Get_isr_disable(
>  );
>
>  /**
> + * @brief Maps the specified object identifier to the associated local object
> + * control block.
> + *
> + * In this function interrupts are disabled during the object lookup.  In case
> + * an associated object exists, then interrupts remain disabled, otherwise the
> + * previous interrupt state is restored.
> + *
> + * @param information The object class information block.
> + * @param[in] id The object identifier.
> + * @param[in] lock_context The interrupt lock context.
> + *
> + * @retval NULL No associated object exists.
> + * @retval other The pointer to the associated object control block.
> + * Interrupts are now disabled and must be restored using the specified lock
> + * context via _ISR_lock_ISR_enable() or _ISR_lock_Release_and_ISR_enable().
> + */
> +Objects_Control *_Objects_Get_local(
> +  const Objects_Information *information,
> +  Objects_Id                 id,
> +  ISR_lock_Context          *lock_context
> +);
> +
> +/**
>   *  @brief  Maps object ids to object control blocks.
>   *
>   *  This function maps object ids to object control blocks.
> diff --git a/cpukit/score/src/objectgetlocal.c b/cpukit/score/src/objectgetlocal.c
> new file mode 100644
> index 0000000..73ff97a
> --- /dev/null
> +++ b/cpukit/score/src/objectgetlocal.c
> @@ -0,0 +1,52 @@
> +/**
> + *  @file
> + *
> + *  @brief Object Get Local
> + *  @ingroup ScoreObject
> + */
> +
> +/*
> + * Copyright (c) 2016 embedded brains GmbH.  All rights reserved.
> + *
> + *  embedded brains GmbH
> + *  Dornierstr. 4
> + *  82178 Puchheim
> + *  Germany
> + *  <rtems at embedded-brains.de>
> + *
> + * The license and distribution terms for this file may be
> + * found in the file LICENSE in this distribution or at
> + * http://www.rtems.org/license/LICENSE.
> + */
> +
> +#if HAVE_CONFIG_H
> +#include "config.h"
> +#endif
> +
> +#include <rtems/score/objectimpl.h>
> +
> +Objects_Control *_Objects_Get_local(
> +  const Objects_Information *information,
> +  Objects_Id                 id,
> +  ISR_lock_Context          *lock_context
> +)
> +{
> +  uint32_t index;
> +
> +  index = id - information->minimum_id + 1;
> +
> +  if ( information->maximum >= index ) {
> +    Objects_Control *the_object;
> +
> +    _ISR_lock_ISR_disable( lock_context );
> +
> +    the_object = information->local_table[ index ];
> +    if ( the_object != NULL ) {
> +      return the_object;
> +    }
> +
> +    _ISR_lock_ISR_enable( lock_context );
> +  }
> +
> +  return NULL;
> +}
> --
> 1.8.4.5
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel



More information about the devel mailing list