Changeset 77e6eba7 in rtems


Ignore:
Timestamp:
Mar 7, 2016, 3:01:57 PM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
62d2540
Parents:
5e368e84
git-author:
Sebastian Huber <sebastian.huber@…> (03/07/16 15:01:57)
git-committer:
Sebastian Huber <sebastian.huber@…> (03/14/16 08:06:27)
Message:

score: Add and use _Objects_Get_local()

This simplifies the handling with local-only objects.

Update #2555.

Location:
cpukit
Files:
1 added
13 edited

Legend:

Unmodified
Added
Removed
  • cpukit/posix/include/rtems/posix/timerimpl.h

    r5e368e84 r77e6eba7  
    9595RTEMS_INLINE_ROUTINE POSIX_Timer_Control *_POSIX_Timer_Get (
    9696  timer_t            id,
    97   Objects_Locations *location,
    9897  ISR_lock_Context  *lock_context
    9998)
    10099{
    101   return (POSIX_Timer_Control *) _Objects_Get_isr_disable(
     100  return (POSIX_Timer_Control *) _Objects_Get_local(
    102101    &_POSIX_Timer_Information,
    103102    (Objects_Id) id,
    104     location,
    105103    lock_context
    106104  );
  • cpukit/posix/src/timerdelete.c

    r5e368e84 r77e6eba7  
    4545  */
    4646  POSIX_Timer_Control *ptimer;
    47   Objects_Locations    location;
    4847  ISR_lock_Context     lock_context;
    49   Per_CPU_Control     *cpu;
    5048
    5149  _Objects_Allocator_lock();
    52   ptimer = _POSIX_Timer_Get( timerid, &location, &lock_context );
    53   switch ( location ) {
    5450
    55     case OBJECTS_LOCAL:
    56       _Objects_Close( &_POSIX_Timer_Information, &ptimer->Object );
    57       cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
    58       ptimer->state = POSIX_TIMER_STATE_FREE;
    59       _Watchdog_Remove(
    60         &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ],
    61         &ptimer->Timer
    62       );
    63       _POSIX_Timer_Release( cpu, &lock_context );
    64       _POSIX_Timer_Free( ptimer );
    65       _Objects_Allocator_unlock();
     51  ptimer = _POSIX_Timer_Get( timerid, &lock_context );
     52  if ( ptimer != NULL ) {
     53    Per_CPU_Control *cpu;
    6654
    67       return 0;
    68 
    69 #if defined(RTEMS_MULTIPROCESSING)
    70     case OBJECTS_REMOTE:
    71 #endif
    72     case OBJECTS_ERROR:
    73       break;
     55    _Objects_Close( &_POSIX_Timer_Information, &ptimer->Object );
     56    cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
     57    ptimer->state = POSIX_TIMER_STATE_FREE;
     58    _Watchdog_Remove(
     59      &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ],
     60      &ptimer->Timer
     61    );
     62    _POSIX_Timer_Release( cpu, &lock_context );
     63    _POSIX_Timer_Free( ptimer );
     64    _Objects_Allocator_unlock();
     65    return 0;
    7466  }
    7567
  • cpukit/posix/src/timergetoverrun.c

    r5e368e84 r77e6eba7  
    3131)
    3232{
    33   int                  overrun;
    3433  POSIX_Timer_Control *ptimer;
    35   Objects_Locations    location;
    3634  ISR_lock_Context     lock_context;
    37   Per_CPU_Control     *cpu;
    3835
    39   ptimer = _POSIX_Timer_Get( timerid, &location, &lock_context );
    40   switch ( location ) {
     36  ptimer = _POSIX_Timer_Get( timerid, &lock_context );
     37  if ( ptimer != NULL ) {
     38    Per_CPU_Control *cpu;
     39    int              overrun;
    4140
    42     case OBJECTS_LOCAL:
    43       cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
    44       overrun = ptimer->overrun;
    45       ptimer->overrun = 0;
    46       _POSIX_Timer_Release( cpu, &lock_context );
    47       return overrun;
    48 
    49 #if defined(RTEMS_MULTIPROCESSING)
    50     case OBJECTS_REMOTE:
    51 #endif
    52     case OBJECTS_ERROR:
    53       break;
     41    cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
     42    overrun = ptimer->overrun;
     43    ptimer->overrun = 0;
     44    _POSIX_Timer_Release( cpu, &lock_context );
     45    return overrun;
    5446  }
    5547
  • cpukit/posix/src/timergettime.c

    r5e368e84 r77e6eba7  
    4242{
    4343  POSIX_Timer_Control *ptimer;
    44   Objects_Locations    location;
    4544  ISR_lock_Context     lock_context;
    46   Per_CPU_Control     *cpu;
    4745  uint64_t             now;
    4846  uint32_t             remaining;
     
    5149    rtems_set_errno_and_return_minus_one( EINVAL );
    5250
    53   ptimer = _POSIX_Timer_Get( timerid, &location, &lock_context );
    54   switch ( location ) {
     51  ptimer = _POSIX_Timer_Get( timerid, &lock_context );
     52  if ( ptimer != NULL ) {
     53    Per_CPU_Control *cpu;
    5554
    56     case OBJECTS_LOCAL:
     55    cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
     56    now = cpu->Watchdog.ticks;
    5757
    58       cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
    59       now = cpu->Watchdog.ticks;
     58    if ( now < ptimer->Timer.expire ) {
     59      remaining = (uint32_t) ( ptimer->Timer.expire - now );
     60    } else {
     61      remaining = 0;
     62    }
    6063
    61       if ( now < ptimer->Timer.expire ) {
    62         remaining = (uint32_t) ( ptimer->Timer.expire - now );
    63       } else {
    64         remaining = 0;
    65       }
     64    _Timespec_From_ticks( remaining, &value->it_value );
     65    value->it_interval = ptimer->timer_data.it_interval;
    6666
    67       _Timespec_From_ticks( remaining, &value->it_value );
    68       value->it_interval = ptimer->timer_data.it_interval;
    69 
    70       _POSIX_Timer_Release( cpu, &lock_context );
    71       return 0;
    72 
    73 #if defined(RTEMS_MULTIPROCESSING)
    74     case OBJECTS_REMOTE:
    75 #endif
    76     case OBJECTS_ERROR:
    77       break;
     67    _POSIX_Timer_Release( cpu, &lock_context );
     68    return 0;
    7869  }
    7970
  • cpukit/posix/src/timersettime.c

    r5e368e84 r77e6eba7  
    108108{
    109109  POSIX_Timer_Control *ptimer;
    110   Objects_Locations    location;
    111110  ISR_lock_Context     lock_context;
    112   Per_CPU_Control     *cpu;
    113111  uint32_t             initial_period;
    114112  struct itimerspec    normalize;
     
    149147   */
    150148
    151   ptimer = _POSIX_Timer_Get( timerid, &location, &lock_context );
    152   switch ( location ) {
     149  ptimer = _POSIX_Timer_Get( timerid, &lock_context );
     150  if ( ptimer != NULL ) {
     151    Per_CPU_Control *cpu;
    153152
    154     case OBJECTS_LOCAL:
    155       cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
     153    cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
    156154
    157       /* Stop the timer */
    158       _Watchdog_Remove(
    159         &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ],
    160         &ptimer->Timer
    161       );
     155    /* Stop the timer */
     156    _Watchdog_Remove(
     157      &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ],
     158      &ptimer->Timer
     159    );
    162160
    163       /* First, it verifies if the timer must be stopped */
    164       if ( normalize.it_value.tv_sec == 0 && normalize.it_value.tv_nsec == 0 ) {
    165         /* The old data of the timer are returned */
    166         if ( ovalue )
    167           *ovalue = ptimer->timer_data;
    168         /* The new data are set */
    169         ptimer->timer_data = normalize;
    170         /* Indicates that the timer is created and stopped */
    171         ptimer->state = POSIX_TIMER_STATE_CREATE_STOP;
    172         /* Returns with success */
    173         _POSIX_Timer_Release( cpu, &lock_context );
    174         return 0;
    175       }
    176 
    177       /* Convert from seconds and nanoseconds to ticks */
    178       ptimer->ticks  = _Timespec_To_ticks( &value->it_interval );
    179       initial_period = _Timespec_To_ticks( &normalize.it_value );
    180 
    181       _POSIX_Timer_Insert( ptimer, cpu, initial_period );
    182 
    183       /*
    184        * The timer has been started and is running.  So we return the
    185        * old ones in "ovalue"
    186        */
     161    /* First, it verifies if the timer must be stopped */
     162    if ( normalize.it_value.tv_sec == 0 && normalize.it_value.tv_nsec == 0 ) {
     163      /* The old data of the timer are returned */
    187164      if ( ovalue )
    188165        *ovalue = ptimer->timer_data;
     166      /* The new data are set */
    189167      ptimer->timer_data = normalize;
     168      /* Indicates that the timer is created and stopped */
     169      ptimer->state = POSIX_TIMER_STATE_CREATE_STOP;
     170      /* Returns with success */
    190171      _POSIX_Timer_Release( cpu, &lock_context );
    191172      return 0;
     173    }
    192174
    193 #if defined(RTEMS_MULTIPROCESSING)
    194     case OBJECTS_REMOTE:
    195 #endif
    196     case OBJECTS_ERROR:
    197       break;
     175    /* Convert from seconds and nanoseconds to ticks */
     176    ptimer->ticks  = _Timespec_To_ticks( &value->it_interval );
     177    initial_period = _Timespec_To_ticks( &normalize.it_value );
     178
     179    _POSIX_Timer_Insert( ptimer, cpu, initial_period );
     180
     181    /*
     182     * The timer has been started and is running.  So we return the
     183     * old ones in "ovalue"
     184     */
     185    if ( ovalue )
     186      *ovalue = ptimer->timer_data;
     187    ptimer->timer_data = normalize;
     188    _POSIX_Timer_Release( cpu, &lock_context );
     189    return 0;
    198190  }
    199191
  • cpukit/rtems/include/rtems/rtems/timerimpl.h

    r5e368e84 r77e6eba7  
    8585RTEMS_INLINE_ROUTINE Timer_Control *_Timer_Get(
    8686  Objects_Id         id,
    87   Objects_Locations *location,
    8887  ISR_lock_Context  *lock_context
    8988)
    9089{
    91   return (Timer_Control *) _Objects_Get_isr_disable(
     90  return (Timer_Control *) _Objects_Get_local(
    9291    &_Timer_Information,
    9392    id,
    94     location,
    9593    lock_context
    9694  );
  • cpukit/rtems/src/timercancel.c

    r5e368e84 r77e6eba7  
    2121)
    2222{
    23   Timer_Control     *the_timer;
    24   Objects_Locations  location;
    25   ISR_lock_Context   lock_context;
    26   Per_CPU_Control   *cpu;
     23  Timer_Control    *the_timer;
     24  ISR_lock_Context  lock_context;
    2725
    28   the_timer = _Timer_Get( id, &location, &lock_context );
    29   switch ( location ) {
     26  the_timer = _Timer_Get( id, &lock_context );
     27  if ( the_timer != NULL ) {
     28    Per_CPU_Control *cpu;
    3029
    31     case OBJECTS_LOCAL:
    32       cpu = _Timer_Acquire_critical( the_timer, &lock_context );
    33       _Timer_Cancel( cpu, the_timer );
    34       _Timer_Release( cpu, &lock_context );
    35       return RTEMS_SUCCESSFUL;
    36 
    37 #if defined(RTEMS_MULTIPROCESSING)
    38     case OBJECTS_REMOTE:            /* should never return this */
    39 #endif
    40     case OBJECTS_ERROR:
    41       break;
     30    cpu = _Timer_Acquire_critical( the_timer, &lock_context );
     31    _Timer_Cancel( cpu, the_timer );
     32    _Timer_Release( cpu, &lock_context );
     33    return RTEMS_SUCCESSFUL;
    4234  }
    4335
  • cpukit/rtems/src/timercreate.c

    r5e368e84 r77e6eba7  
    5555)
    5656{
    57   Timer_Control        *the_timer;
    58   Objects_Locations     location;
    59   ISR_lock_Context      lock_context;
    60   Per_CPU_Control      *cpu;
    61 
    62   the_timer = _Timer_Get( id, &location, &lock_context );
    63   switch ( location ) {
    64 
    65     case OBJECTS_LOCAL:
    66       cpu = _Timer_Acquire_critical( the_timer, &lock_context );
    67       _Timer_Cancel( cpu, the_timer );
    68       _Watchdog_Initialize( &the_timer->Ticker, adaptor );
    69       the_timer->the_class = the_class;
    70       the_timer->routine = routine;
    71       the_timer->user_data = user_data;
    72       the_timer->initial = interval;
    73       the_timer->start_time = _Timer_Get_CPU_ticks( cpu );
    74 
    75       if ( _Timer_Is_interval_class( the_class ) ) {
    76         _Watchdog_Insert(
    77           &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ],
    78           &the_timer->Ticker,
    79           cpu->Watchdog.ticks + interval
    80         );
    81       } else {
    82         _Watchdog_Insert(
    83           &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_ABSOLUTE ],
    84           &the_timer->Ticker,
    85           _Watchdog_Ticks_from_seconds( interval )
    86         );
    87       }
    88 
    89       _Timer_Release( cpu, &lock_context );
    90       return RTEMS_SUCCESSFUL;
    91 
    92 #if defined(RTEMS_MULTIPROCESSING)
    93     case OBJECTS_REMOTE:            /* should never return this */
    94 #endif
    95     case OBJECTS_ERROR:
    96       break;
     57  Timer_Control    *the_timer;
     58  ISR_lock_Context  lock_context;
     59
     60  the_timer = _Timer_Get( id, &lock_context );
     61  if ( the_timer != NULL ) {
     62    Per_CPU_Control *cpu;
     63
     64    cpu = _Timer_Acquire_critical( the_timer, &lock_context );
     65    _Timer_Cancel( cpu, the_timer );
     66    _Watchdog_Initialize( &the_timer->Ticker, adaptor );
     67    the_timer->the_class = the_class;
     68    the_timer->routine = routine;
     69    the_timer->user_data = user_data;
     70    the_timer->initial = interval;
     71    the_timer->start_time = _Timer_Get_CPU_ticks( cpu );
     72
     73    if ( _Timer_Is_interval_class( the_class ) ) {
     74      _Watchdog_Insert(
     75        &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ],
     76        &the_timer->Ticker,
     77        cpu->Watchdog.ticks + interval
     78      );
     79    } else {
     80      _Watchdog_Insert(
     81        &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_ABSOLUTE ],
     82        &the_timer->Ticker,
     83        _Watchdog_Ticks_from_seconds( interval )
     84      );
     85    }
     86
     87    _Timer_Release( cpu, &lock_context );
     88    return RTEMS_SUCCESSFUL;
    9789  }
    9890
  • cpukit/rtems/src/timerdelete.c

    r5e368e84 r77e6eba7  
    2525)
    2626{
    27   Timer_Control     *the_timer;
    28   Objects_Locations  location;
    29   ISR_lock_Context   lock_context;
    30   Per_CPU_Control   *cpu;
     27  Timer_Control    *the_timer;
     28  ISR_lock_Context  lock_context;
    3129
    3230  _Objects_Allocator_lock();
    33   the_timer = _Timer_Get( id, &location, &lock_context );
    34   switch ( location ) {
    3531
    36     case OBJECTS_LOCAL:
    37       _Objects_Close( &_Timer_Information, &the_timer->Object );
    38       cpu = _Timer_Acquire_critical( the_timer, &lock_context );
    39       _Timer_Cancel( cpu, the_timer );
    40       _Timer_Release( cpu, &lock_context );
    41       _Timer_Free( the_timer );
    42       _Objects_Allocator_unlock();
    43       return RTEMS_SUCCESSFUL;
     32  the_timer = _Timer_Get( id, &lock_context );
     33  if ( the_timer != NULL ) {
     34    Per_CPU_Control *cpu;
    4435
    45 #if defined(RTEMS_MULTIPROCESSING)
    46     case OBJECTS_REMOTE:            /* should never return this */
    47 #endif
    48     case OBJECTS_ERROR:
    49       break;
     36    _Objects_Close( &_Timer_Information, &the_timer->Object );
     37    cpu = _Timer_Acquire_critical( the_timer, &lock_context );
     38    _Timer_Cancel( cpu, the_timer );
     39    _Timer_Release( cpu, &lock_context );
     40    _Timer_Free( the_timer );
     41    _Objects_Allocator_unlock();
     42    return RTEMS_SUCCESSFUL;
    5043  }
    5144
    5245  _Objects_Allocator_unlock();
    53 
    5446  return RTEMS_INVALID_ID;
    5547}
  • cpukit/rtems/src/timergetinfo.c

    r5e368e84 r77e6eba7  
    1919#endif
    2020
    21 #include <rtems/system.h>
    22 #include <rtems/rtems/status.h>
    23 #include <rtems/rtems/support.h>
    24 #include <rtems/score/thread.h>
    2521#include <rtems/rtems/timerimpl.h>
    26 #include <rtems/score/watchdog.h>
    2722
    2823rtems_status_code rtems_timer_get_information(
     
    3126)
    3227{
    33   Timer_Control     *the_timer;
    34   Objects_Locations  location;
    35   ISR_lock_Context   lock_context;
    36   Per_CPU_Control   *cpu;
     28  Timer_Control    *the_timer;
     29  ISR_lock_Context  lock_context;
    3730
    3831  if ( !the_info )
    3932    return RTEMS_INVALID_ADDRESS;
    4033
    41   the_timer = _Timer_Get( id, &location, &lock_context );
    42   switch ( location ) {
     34  the_timer = _Timer_Get( id, &lock_context );
     35  if ( the_timer != NULL ) {
     36    Per_CPU_Control *cpu;
    4337
    44     case OBJECTS_LOCAL:
    45       cpu = _Timer_Acquire_critical( the_timer, &lock_context );
    46       the_info->the_class  = the_timer->the_class;
    47       the_info->initial    = the_timer->initial;
    48       the_info->start_time = the_timer->start_time;
    49       the_info->stop_time  = the_timer->stop_time;
    50       _Timer_Release( cpu, &lock_context );
    51       return RTEMS_SUCCESSFUL;
    52 
    53 #if defined(RTEMS_MULTIPROCESSING)
    54     case OBJECTS_REMOTE:            /* should never return this */
    55 #endif
    56     case OBJECTS_ERROR:
    57       break;
     38    cpu = _Timer_Acquire_critical( the_timer, &lock_context );
     39    the_info->the_class  = the_timer->the_class;
     40    the_info->initial    = the_timer->initial;
     41    the_info->start_time = the_timer->start_time;
     42    the_info->stop_time  = the_timer->stop_time;
     43    _Timer_Release( cpu, &lock_context );
     44    return RTEMS_SUCCESSFUL;
    5845  }
    5946
  • cpukit/rtems/src/timerreset.c

    r5e368e84 r77e6eba7  
    1919#endif
    2020
    21 #include <rtems/system.h>
    22 #include <rtems/rtems/status.h>
    23 #include <rtems/rtems/support.h>
    24 #include <rtems/score/thread.h>
    2521#include <rtems/rtems/timerimpl.h>
    26 #include <rtems/score/watchdogimpl.h>
    27 
    28 /*
    29  *  rtems_timer_reset
    30  *
    31  *  This directive allows a thread to reset a timer.
    32  *
    33  *  Input parameters:
    34  *    id - timer id
    35  *
    36  *  Output parameters:
    37  *    RTEMS_SUCCESSFUL - if successful
    38  *    error code       - if unsuccessful
    39  */
    4022
    4123rtems_status_code rtems_timer_reset(
     
    4325)
    4426{
    45   Timer_Control     *the_timer;
    46   Objects_Locations  location;
    47   ISR_lock_Context   lock_context;
    48   Per_CPU_Control   *cpu;
    49   rtems_status_code  status;
     27  Timer_Control    *the_timer;
     28  ISR_lock_Context  lock_context;
    5029
    51   the_timer = _Timer_Get( id, &location, &lock_context );
    52   switch ( location ) {
     30  the_timer = _Timer_Get( id, &lock_context );
     31  if ( the_timer != NULL ) {
     32    Per_CPU_Control   *cpu;
     33    rtems_status_code  status;
    5334
    54     case OBJECTS_LOCAL:
    55       cpu = _Timer_Acquire_critical( the_timer, &lock_context );
     35    cpu = _Timer_Acquire_critical( the_timer, &lock_context );
    5636
    57       if ( _Timer_Is_interval_class( the_timer->the_class ) ) {
    58         _Timer_Cancel( cpu, the_timer );
    59         _Watchdog_Insert(
    60           &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ],
    61           &the_timer->Ticker,
    62           cpu->Watchdog.ticks + the_timer->initial
    63         );
    64         status = RTEMS_SUCCESSFUL;
    65       } else {
    66         status = RTEMS_NOT_DEFINED;
    67       }
     37    if ( _Timer_Is_interval_class( the_timer->the_class ) ) {
     38      _Timer_Cancel( cpu, the_timer );
     39      _Watchdog_Insert(
     40        &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ],
     41        &the_timer->Ticker,
     42        cpu->Watchdog.ticks + the_timer->initial
     43      );
     44      status = RTEMS_SUCCESSFUL;
     45    } else {
     46      status = RTEMS_NOT_DEFINED;
     47    }
    6848
    69       _Timer_Release( cpu, &lock_context );
    70       return status;
    71 
    72 #if defined(RTEMS_MULTIPROCESSING)
    73     case OBJECTS_REMOTE:            /* should never return this */
    74 #endif
    75     case OBJECTS_ERROR:
    76       break;
     49    _Timer_Release( cpu, &lock_context );
     50    return status;
    7751  }
    7852
  • cpukit/score/Makefile.am

    r5e368e84 r77e6eba7  
    215215    src/objectnamespaceremove.c \
    216216    src/objectactivecount.c
     217libscore_a_SOURCES += src/objectgetlocal.c
    217218
    218219## SCHEDULER_C_FILES
  • cpukit/score/include/rtems/score/objectimpl.h

    r5e368e84 r77e6eba7  
    560560
    561561/**
     562 * @brief Maps the specified object identifier to the associated local object
     563 * control block.
     564 *
     565 * In this function interrupts are disabled during the object lookup.  In case
     566 * an associated object exists, then interrupts remain disabled, otherwise the
     567 * previous interrupt state is restored.
     568 *
     569 * @param information The object class information block.
     570 * @param[in] id The object identifier.
     571 * @param[in] lock_context The interrupt lock context.
     572 *
     573 * @retval NULL No associated object exists.
     574 * @retval other The pointer to the associated object control block.
     575 * Interrupts are now disabled and must be restored using the specified lock
     576 * context via _ISR_lock_ISR_enable() or _ISR_lock_Release_and_ISR_enable().
     577 */
     578Objects_Control *_Objects_Get_local(
     579  const Objects_Information *information,
     580  Objects_Id                 id,
     581  ISR_lock_Context          *lock_context
     582);
     583
     584/**
    562585 *  @brief  Maps object ids to object control blocks.
    563586 *
Note: See TracChangeset for help on using the changeset viewer.