Ejemplo n.º 1
0
POSIX_Condition_variables_Control *_POSIX_Condition_variables_Get (
  pthread_cond_t    *cond,
  Objects_Locations *location
)
{
  int status;

  if ( !cond ) {
    *location = OBJECTS_ERROR;
    return (POSIX_Condition_variables_Control *) 0;
  }

  if ( *cond == PTHREAD_COND_INITIALIZER ) {
    /*
     *  Do an "auto-create" here.
     */

    status = pthread_cond_init( cond, 0 );
    if ( status ) {
      *location = OBJECTS_ERROR;
      return (POSIX_Condition_variables_Control *) 0;
    }
  }

  /*
   *  Now call Objects_Get()
   */
  return (POSIX_Condition_variables_Control *)_Objects_Get(
    &_POSIX_Condition_variables_Information,
    (Objects_Id) *cond,
    location
  );
}
Ejemplo n.º 2
0
RTEMS_INLINE_ROUTINE Extension_Control *_Extension_Get (
  Objects_Id         id,
  Objects_Locations *location
)
{
  return (Extension_Control *)
    _Objects_Get( &_Extension_Information, id, location );
}
Ejemplo n.º 3
0
/**
 *  @brief Timer_Get
 *
 *  This function maps timer IDs to timer control blocks.
 *  If ID corresponds to a local timer, then it returns
 *  the timer control pointer which maps to ID and location
 *  is set to OBJECTS_LOCAL.  Otherwise, location is set
 *  to OBJECTS_ERROR and the returned value is undefined.
 */
RTEMS_INLINE_ROUTINE Timer_Control *_Timer_Get (
  Objects_Id         id,
  Objects_Locations *location
)
{
  return (Timer_Control *)
    _Objects_Get( &_Timer_Information, id, location );
}
Ejemplo n.º 4
0
/**
 *  @brief Rate_monotonic_Get
 *
 *  This function maps period IDs to period control blocks.
 *  If ID corresponds to a local period, then it returns
 *  the_period control pointer which maps to ID and location
 *  is set to OBJECTS_LOCAL.  Otherwise, location is set
 *  to OBJECTS_ERROR and the_period is undefined.
 */
RTEMS_INLINE_ROUTINE Rate_monotonic_Control *_Rate_monotonic_Get (
  Objects_Id         id,
  Objects_Locations *location
)
{
  return (Rate_monotonic_Control *)
    _Objects_Get( &_Rate_monotonic_Information, id, location );
}
Ejemplo n.º 5
0
POSIX_Mutex_Control *_POSIX_Mutex_Get (
    pthread_mutex_t   *mutex,
    Objects_Locations *location
)
{
    ___POSIX_Mutex_Get_support_error_check( mutex, location );

    ___POSIX_Mutex_Get_support_auto_initialization( mutex, location );

    return (POSIX_Mutex_Control *)
           _Objects_Get( &_POSIX_Mutex_Information, (Objects_Id) *mutex, location );
}
Ejemplo n.º 6
0
/**
 *  This function maps thread IDs to thread control
 *  blocks.  If ID corresponds to a local thread, then it
 *  returns the_thread control pointer which maps to ID
 *  and location is set to OBJECTS_LOCAL.  If the thread ID is
 *  global and resides on a remote node, then location is set
 *  to OBJECTS_REMOTE, and the_thread is undefined.
 *  Otherwise, location is set to OBJECTS_ERROR and
 *  the_thread is undefined.
 *
 *  @note  The performance of many RTEMS services depends upon
 *         the quick execution of the "good object" path in this
 *         routine.  If there is a possibility of saving a few
 *         cycles off the execution time, this routine is worth
 *         further optimization attention.
 */
Thread_Control *_Thread_Get (
  Objects_Id         id,
  Objects_Locations *location
)
{
  uint32_t             the_api;
  uint32_t             the_class;
  Objects_Information **api_information;
  Objects_Information *information;
  Thread_Control      *tp = (Thread_Control *) 0;

  if ( _Objects_Are_ids_equal( id, OBJECTS_ID_OF_SELF ) ) {
    _Thread_Disable_dispatch();
    *location = OBJECTS_LOCAL;
    tp = _Thread_Executing;
    goto done;
  }

  the_api = _Objects_Get_API( id );
  if ( !_Objects_Is_api_valid( the_api ) ) {
    *location = OBJECTS_ERROR;
    goto done;
  }

  the_class = _Objects_Get_class( id );
  if ( the_class != 1 ) {       /* threads are always first class :) */
    *location = OBJECTS_ERROR;
    goto done;
  }

  api_information = _Objects_Information_table[ the_api ];
  /*
   *  There is no way for this to happen if POSIX is enabled.  But there
   *  is actually a test case in sp43 for this which trips it whether or
   *  not POSIX is enabled.  So in the interest of safety, this is left
   *  on in all configurations.
   */
  if ( !api_information ) {
    *location = OBJECTS_ERROR;
    goto done;
  }

  information = api_information[ the_class ];
  if ( !information ) {
    *location = OBJECTS_ERROR;
    goto done;
  }

  tp = (Thread_Control *) _Objects_Get( information, id, location );

done:
  return tp;
}
Ejemplo n.º 7
0
static Semaphore_Control *get_semaphore_control(rtems_id id)
{
  Objects_Locations location;
  Semaphore_Control *sem;

  sem = (Semaphore_Control *)
    _Objects_Get(&_Semaphore_Information, id, &location);
  _Thread_Unnest_dispatch();

  rtems_test_assert(sem != NULL && location == OBJECTS_LOCAL);

  return sem;
}
Ejemplo n.º 8
0
static rtems_rate_monotonic_period_states getState(void)
{
  Objects_Locations       location;
  Rate_monotonic_Control *period;

  period = (Rate_monotonic_Control *)_Objects_Get(
    &_Rate_monotonic_Information, Period, &location );
  if ( location != OBJECTS_LOCAL ) {
    puts( "Bad object lookup" );
    rtems_test_exit(0);
  }
  _Thread_Unnest_dispatch();

  return period->state;
}
Ejemplo n.º 9
0
static Thread_blocking_operation_States getState(void)
{
    Objects_Locations  location;
    Semaphore_Control *sem;

    sem = (Semaphore_Control *)_Objects_Get(
              &_Semaphore_Information, Semaphore, &location );
    if ( location != OBJECTS_LOCAL ) {
        puts( "Bad object lookup" );
        rtems_test_exit(0);
    }
    _Thread_Unnest_dispatch();

    return sem->Core_control.semaphore.Wait_queue.sync_state;
}
Thread_Control *_Thread_Get (
  Objects_Id         id,
  Objects_Locations *location
)
{
  uint32_t             the_api;
  uint32_t             the_class;
  Objects_Information **api_information;
  Objects_Information *information;
  Thread_Control      *tp = (Thread_Control *) 0;

  if ( _Objects_Are_ids_equal( id, OBJECTS_ID_OF_SELF ) ) {
    _Thread_Disable_dispatch();
    *location = OBJECTS_LOCAL;
    tp = _Thread_Executing;
    goto done;
  }

  the_api = _Objects_Get_API( id );
  if ( !_Objects_Is_api_valid( the_api ) ) {
    *location = OBJECTS_ERROR;
    goto done;
  }

  the_class = _Objects_Get_class( id );
  if ( the_class != 1 ) {       /* threads are always first class :) */
    *location = OBJECTS_ERROR;
    goto done;
  }

  api_information = _Objects_Information_table[ the_api ];
  if ( !api_information ) {
    *location = OBJECTS_ERROR;
    goto done;
  }

  information = api_information[ the_class ];
  if ( !information ) {
    *location = OBJECTS_ERROR;
    goto done;
  }

  tp = (Thread_Control *) _Objects_Get( information, id, location );

done:
  return tp;
}
Ejemplo n.º 11
0
/*
 *  _Objects_Id_to_name
 *
 *  DESCRIPTION:
 *
 *  This routine returns the name associated with the given ID.
 *
 *  INPUT:
 *
 *  id   - id of object to lookup name
 *  name - pointer to location in which to store name
 *
 */
Objects_Name_or_id_lookup_errors _Objects_Id_to_name (
  Objects_Id      id,
  Objects_Name   *name
)
{
  uint32_t             the_api;
  uint32_t             the_class;
  Objects_Id           tmpId;
  Objects_Information *information;
  Objects_Control     *the_object = (Objects_Control *) 0;
  Objects_Locations    ignored_location;

  /*
   *  Caller is trusted for name != NULL.
   */

  tmpId = (id == OBJECTS_ID_OF_SELF) ? _Thread_Executing->Object.id : id;

  the_api = _Objects_Get_API( tmpId );
  if ( !_Objects_Is_api_valid( the_api ) )
    return OBJECTS_INVALID_ID;

  if ( !_Objects_Information_table[ the_api ] )
    return OBJECTS_INVALID_ID;

  the_class = _Objects_Get_class( tmpId );

  information = _Objects_Information_table[ the_api ][ the_class ];
  if ( !information )
    return OBJECTS_INVALID_ID;

  #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
    if ( information->is_string )
      return OBJECTS_INVALID_ID;
  #endif

  the_object = _Objects_Get( information, tmpId, &ignored_location );
  if ( !the_object )
    return OBJECTS_INVALID_ID;

  *name = the_object->name;
  _Thread_Enable_dispatch();
  return OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL;
}
Ejemplo n.º 12
0
Objects_Control *
_Objects_Get_next(
    Objects_Information *information,
    Objects_Id           id,
    Objects_Locations   *location_p,
    Objects_Id          *next_id_p
)
{
    Objects_Control *object;
    Objects_Id       next_id;

    if ( !information )
      return NULL;

    if ( !location_p )
      return NULL;

    if ( !next_id_p )
      return NULL;

    if (_Objects_Get_index(id) == OBJECTS_ID_INITIAL_INDEX)
        next_id = information->minimum_id;
    else
        next_id = id;

    do {
        /* walked off end of list? */
        if (_Objects_Get_index(next_id) > information->maximum)
        {
            *location_p = OBJECTS_ERROR;
            goto final;
        }

        /* try to grab one */
        object = _Objects_Get(information, next_id, location_p);

        next_id++;

    } while (*location_p != OBJECTS_LOCAL);
Ejemplo n.º 13
0
/*
 *  This method will set the object name based upon the user string.
 *  If the object class uses 32-bit names, then only the first 4 bytes
 *  of the string will be used.
 */
rtems_status_code rtems_object_set_name(
  rtems_id       id,
  const char    *name
)
{
  Objects_Information *information;
  Objects_Locations    location;
  Objects_Control     *the_object;
  Objects_Id           tmpId;

  if ( !name )
    return RTEMS_INVALID_ADDRESS;

  tmpId = (id == OBJECTS_ID_OF_SELF) ? _Thread_Get_executing()->Object.id : id;

  information  = _Objects_Get_information_id( tmpId );
  if ( !information )
    return RTEMS_INVALID_ID;

  the_object = _Objects_Get( information, tmpId, &location );
  switch ( location ) {

    case OBJECTS_LOCAL:
      _Objects_Set_name( information, the_object, name );
      _Objects_Put( the_object );
      return RTEMS_SUCCESSFUL;

#if defined(RTEMS_MULTIPROCESSING)
    case OBJECTS_REMOTE:
#endif
    case OBJECTS_ERROR:
      break;
  }

  return RTEMS_INVALID_ID;
}