Exemplo n.º 1
0
void test_errors(void)
{
  rtems_status_code  sc;
  void              *value;

  /*
   *  task variable add error status codes
   */
  puts( "task variable add - NULL pointer - RTEMS_INVALID_ADDRESS" );
  sc = rtems_task_variable_add(RTEMS_SELF, NULL, NULL );
  fatal_directive_status( sc, RTEMS_INVALID_ADDRESS, "add NULL pointer" );

  /*
   *  task variable get error status codes
   */
  puts( "task variable get - bad Id - RTEMS_INVALID_ID" );
  sc = rtems_task_variable_get(
    rtems_task_self() + 10,
    (void **)&taskvar1,
    &value
  );
  fatal_directive_status( sc, RTEMS_INVALID_ID, "bad Id" );

  puts( "task variable get - NULL pointer - RTEMS_INVALID_ADDRESS" );
  sc = rtems_task_variable_get(RTEMS_SELF, NULL, &value );
  fatal_directive_status( sc, RTEMS_INVALID_ADDRESS, "get NULL pointer" );

  puts( "task variable get - bad result - RTEMS_INVALID_ADDRESS" );
  sc = rtems_task_variable_get(RTEMS_SELF, (void **)&taskvar1, NULL);
  fatal_directive_status( sc, RTEMS_INVALID_ADDRESS, "get bad result" );

  puts( "task variable get - bad pointer - RTEMS_INVALID_ADDRESS" );
  sc = rtems_task_variable_get(RTEMS_SELF, (void **)&taskvar1, &value);
  fatal_directive_status( sc, RTEMS_INVALID_ADDRESS, "get bad pointer" );

  /*
   *  task variable delete error status codes
   */
  puts( "task variable delete - bad Id - RTEMS_INVALID_ID" );
  sc = rtems_task_variable_delete( rtems_task_self() + 10, (void **)&taskvar1 );
  fatal_directive_status( sc, RTEMS_INVALID_ID, "bad Id" );

  puts( "task variable delete - NULL pointer - RTEMS_INVALID_ADDRESS" );
  sc = rtems_task_variable_delete(RTEMS_SELF, NULL);
  fatal_directive_status( sc, RTEMS_INVALID_ADDRESS, "delete NULL pointer" );

  puts( "task variable delete - bad pointer - RTEMS_INVALID_ADDRESS" );
  sc = rtems_task_variable_delete(RTEMS_SELF, (void **)&taskvar1);
  fatal_directive_status( sc, RTEMS_INVALID_ADDRESS, "delete bad pointer" );

}
Exemplo n.º 2
0
rtems_status_code rtems_shell_init(
  const char *task_name,
  size_t task_stacksize,
  rtems_task_priority task_priority,
  const char *devname,
  bool forever,
  bool wait,
  rtems_shell_login_check_t login_check
)
{
  rtems_id to_wake = RTEMS_ID_NONE;

  if ( wait )
    to_wake = rtems_task_self();

  return rtems_shell_run(
    task_name,               /* task_name */
    task_stacksize,          /* task_stacksize */
    task_priority,           /* task_priority */
    devname,                 /* devname */
    forever,                 /* forever */
    wait,                    /* wait */
    "stdin",                 /* input */
    "stdout",                /* output */
    false,                   /* output_append */
    to_wake,                 /* wake_on_end */
    false,                   /* echo */
    login_check              /* login check */
  );
}
Exemplo n.º 3
0
void *rtems_gxx_getspecific(__gthread_key_t key)
{
  rtems_status_code  status;
  void              *p= 0;

  /* register with RTEMS the buffer that will hold the key values */
  status = rtems_task_variable_get( RTEMS_SELF, (void **)key, &p );
  if ( status == RTEMS_SUCCESSFUL ) {
    /* We do not have to do this, but what the heck ! */
     p= key->val;
  } else {
    /* fisrt time, always set to zero, it is unknown the value that the others
     * threads are using at the moment of this call
     */
    status = rtems_task_variable_add( RTEMS_SELF, (void **)key, key->dtor );
    if ( status != RTEMS_SUCCESSFUL ) {
      _Internal_error_Occurred(
        INTERNAL_ERROR_CORE,
        true,
        INTERNAL_ERROR_GXX_KEY_ADD_FAILED
      );
    }
    key->val = (void *)0;
  }

  #ifdef DEBUG_GXX_WRAPPERS
    printk(
      "gxx_wrappers: getspecific key=%x, ptr=%x, id=%x\n",
       key,
       p,
       rtems_task_self()
    );
  #endif
  return p;
}
Exemplo n.º 4
0
rtems_task Init(
  rtems_task_argument ignored
)
{
  rtems_status_code     sc;
  rtems_event_set       out;
  int                   resets;

  puts( "\n\n*** TEST INTERRUPT CRITICAL SECTION 10 ***" );

  puts( "Init - Test may not be able to detect case is hit reliably" );
  puts( "Init - Trying to generate timeout while blocking on event" );

  Main_task = rtems_task_self();

  interrupt_critical_section_test_support_initialize( NULL );

  for (resets=0 ; resets< 2 ;) {
    if ( interrupt_critical_section_test_support_delay() )
      resets++;

    sc = rtems_event_receive( 0x01, RTEMS_DEFAULT_OPTIONS, 1, &out );
    fatal_directive_status( sc, RTEMS_TIMEOUT, "event_receive timeout" );
  }

  puts( "*** END OF TEST INTERRUPT CRITICAL SECTION 10 ***" );
  rtems_test_exit(0);
}
Exemplo n.º 5
0
Arquivo: init.c Projeto: medivhc/rtems
rtems_task Init(rtems_task_argument ignored)
{
  rtems_status_code sc;
  rtems_id          q;
  uint32_t          flushed;

  puts( "\n\n*** TEST 49 ***" );

  puts( "Create Message Queue" );
  sc = rtems_message_queue_create(
    rtems_build_name('m', 's', 'g', ' '),
    1,
    sizeof(uint32_t),
    RTEMS_DEFAULT_ATTRIBUTES,
    &q
  );
  directive_failed( sc, "rtems_message_queue_create" );

  puts( "Flush Message Queue using Task Self ID" );
  sc = rtems_message_queue_flush( rtems_task_self(), &flushed );
  fatal_directive_status( sc, RTEMS_INVALID_ID, "flush" );

  puts( "Flush returned INVALID_ID as expected" );

  puts( "*** END OF TEST 49 ***" );
  rtems_test_exit( 0 );
}
Exemplo n.º 6
0
/*
 * Task that calls the function we want to trace
 */
static void task(rtems_task_argument arg)
{
  rtems_status_code sc;
  uint32_t i;

  for ( i = 0; i < ITERATIONS; i++ ) {
    /*
     * Wait until the previous task in the task chain
     * has completed its operation.
     */
    sc = rtems_semaphore_obtain(task_data[arg].prev_sem, 0, 0);
    rtems_test_assert(sc == RTEMS_SUCCESSFUL);

    add_number_wrapper(arg, i);

    /*
     * Signal the next task in the chain to continue
     */
    sc = rtems_semaphore_release(task_data[arg].task_sem);
    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
  }

  /* Signal the main task that this task has finished */
  sc = rtems_semaphore_release(finished_sem);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
  rtems_task_suspend(rtems_task_self());
}
Exemplo n.º 7
0
rtems_task Task_2(
  rtems_task_argument argument
)
{
  rtems_status_code status;
  rtems_time_of_day time;
  rtems_name        name;

  status = rtems_object_get_classic_name( rtems_task_self(), &name );
  directive_failed( status, "rtems_object_get_classic_name" );

  while( FOREVER ) {
    status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() );
    directive_failed( status, "rtems_task_wake_after" );

    status = rtems_clock_get_tod( &time );
    directive_failed( status, "rtems_clock_get_tod" );

    if ( time.second >= 17 ) {
      puts( "*** END OF TEST 3 *** " );
      rtems_test_exit( 0 );
    }

    put_name( name, FALSE );
    print_time( "  ", &time, "\n" );
  }
}
Exemplo n.º 8
0
int rtems_gxx_setspecific(__gthread_key_t key, const void *ptr)
{
  pthread_key_t *pkey = key;
  int eno;

  if ( pkey == NULL ) {
    return EINVAL;
  }

  eno = pthread_setspecific( *pkey, ptr );

  #ifdef DEBUG_GXX_WRAPPERS
    printk(
      "gxx_wrappers: setspecific key=%x, ptr=%x, id=%x\n",
      pkey,
      ptr,
      rtems_task_self()
      );
  #endif

  if ( eno != 0 ) {
    _Terminate(
      INTERNAL_ERROR_CORE,
      true,
      INTERNAL_ERROR_GXX_KEY_ADD_FAILED
    );
  }

  return 0;
}
Exemplo n.º 9
0
rtems_task Init(
  rtems_task_argument ignored
)
{
  rtems_event_set       out;
  int                   resets;

  puts( "\n\n*** TEST INTERRUPT CRITICAL SECTION " TEST_NAME " ***" );

  puts( "Init - Test may not be able to detect case is hit reliably" );
  puts( "Init - Trying to generate event send from ISR while blocking" );
  puts( "Init - Variation is: " TEST_STRING );

  Main_task = rtems_task_self();

  interrupt_critical_section_test_support_initialize( test_release_from_isr );

  for (resets=0 ; resets< 2 ;) {
    if ( interrupt_critical_section_test_support_delay() )
      resets++;

    (void) rtems_event_receive( EVENTS_TO_RECEIVE, RTEMS_EVENT_ANY, 1, &out );
  }

  puts( "*** END OF TEST INTERRUPT CRITICAL SECTION " TEST_NAME " ***" );
  rtems_test_exit(0);
}
Exemplo n.º 10
0
/*
 *  CallerName -- print the calling tasks name or id as configured
 */
const char *CallerName(void)
{
  static char buffer[32];
  Thread_Control *executing = _Thread_Get_executing();
#if defined(TEST_PRINT_TASK_ID)
  sprintf( buffer, "0x%08x -- %d",
      rtems_task_self(), _Thread_Get_priority( executing ) );
#else
  volatile union {
    uint32_t u;
    unsigned char c[4];
  } TempName;

  #if defined(TEST_ON_RTEMS_45)
    TempName.u = *(uint32_t *)executing->Object.name;
  #else
    TempName.u = executing->Object.name.name_u32;
  #endif
    sprintf( buffer, "%c%c%c%c -- %" PRIdPriority_Control,
      TempName.c[0], TempName.c[1], TempName.c[2], TempName.c[3],
      _Thread_Get_priority( executing )
  );
#endif
  return buffer;
}
Exemplo n.º 11
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_Control     *the_object;
  Objects_Id           tmpId;

  if ( !name )
    return RTEMS_INVALID_ADDRESS;

  tmpId = (id == OBJECTS_ID_OF_SELF) ? rtems_task_self() : id;

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

  _Objects_Allocator_lock();
  the_object = _Objects_Get_no_protection( tmpId, information );

  if ( the_object == NULL ) {
    _Objects_Allocator_unlock();
    return RTEMS_INVALID_ID;
  }

  _Objects_Set_name( information, the_object, name );
  _Objects_Allocator_unlock();
  return RTEMS_SUCCESSFUL;
}
Exemplo n.º 12
0
Arquivo: init.c Projeto: gedare/rtems
static void Init(rtems_task_argument arg)
{
  test_context *ctx = &test_instance;

  TEST_BEGIN();

  ctx->low = rtems_task_self();

  create_task(&ctx->mid, 3);
  create_task(&ctx->high, 1);
  create_task(&ctx->inversion, 2);
  create_sema(&ctx->sem_a);
  create_sema(&ctx->sem_b);

  obtain_sema(ctx->sem_a);
  start_task(ctx->mid, mid_task);
  start_task(ctx->high, high_task);

  /*
   * Here we see that the priority of the high priority task blocked on
   * semaphore B propagated to the low priority task owning semaphore A
   * on which the owner of semaphore B depends.
   */
  assert_prio(ctx->low, 1);
  assert_prio(ctx->mid, 1);
  assert_prio(ctx->high, 1);
  assert_prio(ctx->inversion, 2);

  TEST_END();
  rtems_test_exit(0);
}
Exemplo n.º 13
0
Arquivo: init.c Projeto: gedare/rtems
static void test_with_request_server(void)
{
  rtems_status_code sc;
  rtems_id id;
  request req;

  sc = rtems_event_transient_receive(RTEMS_NO_WAIT, 0);
  rtems_test_assert(sc == RTEMS_UNSATISFIED);

  req.client = rtems_task_self();
  req.complete = false;

  sc = rtems_task_create(
    rtems_build_name('S', 'E', 'R', 'V'),
    1,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_DEFAULT_MODES,
    RTEMS_DEFAULT_ATTRIBUTES,
    &id
  );
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  sc = rtems_task_start(id, server_task, (rtems_task_argument) &req);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  sc = rtems_event_transient_receive(RTEMS_WAIT, RTEMS_NO_TIMEOUT);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  rtems_test_assert(req.complete);
}
Exemplo n.º 14
0
rtems_task Task_1_through_3(
  rtems_task_argument index
)
{
  rtems_time_of_day time;
  rtems_status_code status;
  rtems_interval    ticks;
  rtems_name        name;

  status = rtems_object_get_classic_name( rtems_task_self(), &name );
  directive_failed( status, "rtems_object_get_classic_name" );

  ticks = RTEMS_MILLISECONDS_TO_TICKS( index * 5 * 1000 );

  while( FOREVER ) {
    status = rtems_clock_get_tod( &time );
    directive_failed( status, "rtems_clock_get_tod" );

    if ( time.second >= 35 ) {
      TEST_END();
      rtems_test_exit( 0 );
    }

    put_name( name, FALSE );
    print_time( " - rtems_clock_get_tod - ", &time, "\n" );

    status = rtems_task_wake_after( ticks );
    directive_failed( status, "rtems_task_wake_after" );
  }
}
Exemplo n.º 15
0
void bestcomm_irq_create(bestcomm_irq *self, int task_index)
{
  assert(task_index >= 0 && task_index <= 15);

  self->task_index = task_index;
  self->event_task_id = rtems_task_self();
  bestcomm_glue_irq_install(task_index, bestcomm_irq_handler, self);
}
Exemplo n.º 16
0
Arquivo: i2c.c Projeto: chch1028/rtems
static rtems_status_code i2c_wait_done(stm32f4_i2c_bus_entry *e)
{
  rtems_status_code sc = RTEMS_SUCCESSFUL;

  bsp_interrupt_vector_enable(e->vector);
  e->task_id = rtems_task_self();
  return rtems_event_transient_receive(RTEMS_WAIT, RTEMS_NO_TIMEOUT);
}
Exemplo n.º 17
0
rtems_status_code rtems_libio_share_private_env(rtems_id task_id)
{
  rtems_status_code  sc;
  rtems_user_env_t * shared_user_env;
  rtems_id           current_task_id;

  /* 
   * get current task id 
   */
  current_task_id = rtems_task_self();

  /*
   * If this was an attempt to share the task with self,
   * if somebody wanted to do it... Lets tell them, its shared
   */

  if( task_id == current_task_id )
    return RTEMS_SUCCESSFUL;
  /* 
   * Try to get the requested user environment 
   */
  sc = rtems_task_variable_get(
	 task_id,
	 (void*)&rtems_current_user_env, 
	 (void*)&shared_user_env );

  /* 
   * If it was not successful, return the error code 
   */
    if (sc != RTEMS_SUCCESSFUL)
      return sc;

    /* 
     * If we are here, we have the required environment to be
     * shared with the current task
    */

    /*
     * If we have a current environment in place, we need to 
     * free it, since we will be sharing the variable with the
     * shared_user_env
     */

  if (rtems_current_user_env->task_id==current_task_id) {
    rtems_user_env_t  *tmp = rtems_current_user_env;
    free_user_env( tmp );
  }

  /* the current_user_env is the same pointer that remote env */
  rtems_current_user_env = shared_user_env;

  /* increase the reference count */
#ifdef HAVE_USERENV_REFCNT
  rtems_current_user_env->refcnt++;
#endif

  return RTEMS_SUCCESSFUL;
}
Exemplo n.º 18
0
static bool
bdbuf_disk_ioctl_process (bdbuf_disk* bdd, rtems_blkdev_request* req)
{
  bool result = true;
  int  b;

  /*
   * Perform the requested action.
   */
  switch (bdd->driver_action)
  {
    case BDBUF_DISK_NOOP:
      break;

    case BDBUF_DISK_WAIT:
      if (bdd->waiting)
        bdbuf_test_printf ("disk ioctl: bad waiter: %s:%08x\n",
                           bdd->waiting_name, bdd->waiting);
      bdd->waiting_name = "bdd";

      bdd->waiting = rtems_task_self ();

      if (bdbuf_disk_unlock (bdd))
        result = bdbuf_wait (bdd->name, 0) == RTEMS_SUCCESSFUL;
      else
        result = false;

      /*
       * Ignore any error if one happens.
       */
      bdbuf_disk_lock (bdd);
      break;

    case BDBUF_DISK_SLEEP:
      bdbuf_test_printf ("disk ioctl: sleeping: %d msecs\n",
                         bdd->driver_sleep);
      result = bdbuf_sleep (bdd->driver_sleep);
      break;

    case BDBUF_DISK_BLOCKS_INORDER:
      bdbuf_test_printf ("disk ioctl: multi-block order check: count = %d\n",
                         req->bufnum);
      for (b = 0; b < (req->bufnum - 1); b++)
        if (req->bufs[b].block >= req->bufs[b + 1].block)
          bdbuf_test_printf ("disk ioctl: out of order: index:%d (%d >= %d\n",
                             b, req->bufs[b].block, req->bufs[b + 1].block);
      break;

    default:
      bdbuf_test_printf ("disk ioctl: invalid action: %d\n",
                         bdd->driver_action);
      result = false;
      break;
  }

  return result;
}
Exemplo n.º 19
0
rtems_task Init(
  rtems_task_argument ignored
)
{
  rtems_status_code     sc;
  int                   resets;

  puts(
    "\n\n*** TEST INTERRUPT CRITICAL SECTION " TEST_NAME " ***\n"
    "Init - Trying to generate timeout of a thread while another is blocking\n"
    "Init -   on the same thread queue\n"
    "Init - There is no way for the test to know if it hits the case"
  );

  puts( "Init - rtems_semaphore_create - OK" );
  sc = rtems_semaphore_create(
    rtems_build_name( 'S', 'M', '1', ' ' ),
    0,
    RTEMS_DEFAULT_ATTRIBUTES,
    RTEMS_NO_PRIORITY,
    &Semaphore
  );
  directive_failed( sc, "rtems_semaphore_create of SM1" );

  puts( "Init - rtems_task_create - OK" );
  sc = rtems_task_create(
    rtems_build_name( 'B', 'L', 'C', 'K' ),
    BLOCKER_PRIORITY,
    RTEMS_MINIMUM_STACK_SIZE,
    RTEMS_NO_PREEMPT,
    RTEMS_DEFAULT_ATTRIBUTES,
    &Secondary_task_id
  );
  directive_failed( sc, "rtems_task_create" );

  sc = rtems_task_start( Secondary_task_id, Secondary_task, 0 );
  directive_failed( sc, "rtems_task_start" );

  Main_task = rtems_task_self();

  interrupt_critical_section_test_support_initialize( NULL );

  for (resets=0 ; resets<10 ;) {
    if ( interrupt_critical_section_test_support_delay() )
      resets++;

    sc = rtems_task_restart( Secondary_task_id, 1 );
    directive_failed( sc, "rtems_task_restart" );

    sc = rtems_semaphore_obtain( Semaphore, RTEMS_DEFAULT_OPTIONS, 1 );
    fatal_directive_status( sc, RTEMS_TIMEOUT, "rtems_semaphore_obtain" );
  }

  puts( "*** END OF TEST INTERRUPT CRITICAL SECTION " TEST_NAME " ***" );
  rtems_test_exit(0);
}
Exemplo n.º 20
0
void rtems_printer_task_drain( rtems_printer_task_context *ctx )
{
  printer_task_buffer buffer;

  buffer.action_kind = ACTION_DRAIN;
  buffer.action_data.task = rtems_task_self();

  printer_task_append_buffer( ctx, &ctx->todo_buffers, &buffer );
  rtems_event_send( ctx->task, PRINT_TASK_WAKE_UP );
  rtems_event_transient_receive( RTEMS_WAIT, RTEMS_NO_TIMEOUT );
}
Exemplo n.º 21
0
static void test_with_normal_and_system_event(void)
{
  rtems_status_code sc;
  rtems_event_set out;

  /* Assert no events pending */

  sc = rtems_event_receive(EVENT, RTEMS_NO_WAIT, 0, &out);
  rtems_test_assert(sc == RTEMS_UNSATISFIED);

  sc = rtems_event_system_receive(EVENT, RTEMS_NO_WAIT, 0, &out);
  rtems_test_assert(sc == RTEMS_UNSATISFIED);

  /* Send system event */

  sc = rtems_event_system_send(rtems_task_self(), EVENT);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  sc = rtems_event_receive(EVENT, RTEMS_NO_WAIT, 0, &out);
  rtems_test_assert(sc == RTEMS_UNSATISFIED);

  out = 0;
  sc = rtems_event_system_receive(EVENT, RTEMS_NO_WAIT, 0, &out);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
  rtems_test_assert(out == EVENT);

  /* Send normal event */

  sc = rtems_event_send(rtems_task_self(), EVENT);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  out = 0;
  sc = rtems_event_receive(EVENT, RTEMS_NO_WAIT, 0, &out);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
  rtems_test_assert(out == EVENT);

  sc = rtems_event_system_receive(EVENT, RTEMS_NO_WAIT, 0, &out);
  rtems_test_assert(sc == RTEMS_UNSATISFIED);
}
Exemplo n.º 22
0
int unmount( const char *path )
{
  int rv = 0;
  rtems_filesystem_eval_path_context_t ctx;
  int eval_flags = RTEMS_FS_FOLLOW_LINK;
  const rtems_filesystem_location_info_t *currentloc =
    rtems_filesystem_eval_path_start( &ctx, path, eval_flags );
  rtems_filesystem_mount_table_entry_t *mt_entry = currentloc->mt_entry;

  if ( rtems_filesystem_location_is_root( currentloc ) ) {
    if ( !contains_root_or_current_directory( mt_entry ) ) {
      const rtems_filesystem_operations_table *mt_point_ops =
        mt_entry->mt_point_node->location.mt_entry->ops;

      rv = (*mt_point_ops->unmount_h)( mt_entry );
      if ( rv == 0 ) {
        rtems_id self_task_id = rtems_task_self();
        rtems_filesystem_mt_entry_declare_lock_context( lock_context );

        rtems_filesystem_mt_entry_lock( lock_context );
        mt_entry->unmount_task = self_task_id;
        mt_entry->mounted = false;
        rtems_filesystem_mt_entry_unlock( lock_context );
      }
    } else {
      errno = EBUSY;
      rv = -1;
    }
  } else {
    errno = EACCES;
    rv = -1;
  }

  rtems_filesystem_eval_path_cleanup( &ctx );

  if ( rv == 0 ) {
    rtems_event_set out;
    rtems_status_code sc = rtems_event_receive(
      RTEMS_FILESYSTEM_UNMOUNT_EVENT,
      RTEMS_EVENT_ALL | RTEMS_WAIT,
      RTEMS_NO_TIMEOUT,
      &out
    );

    if ( sc != RTEMS_SUCCESSFUL ) {
      rtems_fatal_error_occurred( 0xdeadbeef );
    }
  }

  return rv;
}
Exemplo n.º 23
0
static rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_task_priority prio;
  rtems_status_code status;

  TEST_BEGIN();

  Master = rtems_task_self();

  if (RTEMS_MAXIMUM_PRIORITY >= 255)
    Priorities = Priorities_High;
  else if (RTEMS_MAXIMUM_PRIORITY >= 15)
    Priorities = Priorities_Low;
  else {
    puts( "Test needs at least 16 configured priority levels" );
    rtems_test_exit( 0 );
  }

  prio = RTEMS_MAXIMUM_PRIORITY - 1;
  status = rtems_task_set_priority(RTEMS_SELF, prio, &prio);
  directive_failed( status, "rtems_task_set_priority" );

  if ( sizeof(Priorities_Low) / sizeof(rtems_task_priority) != MAX_TASKS ) {
    puts( "Priorities_Low table does not have right number of entries" );
    rtems_test_exit( 0 );
  }

  if ( sizeof(Priorities_High) / sizeof(rtems_task_priority) != MAX_TASKS ) {
    puts( "Priorities_High table does not have right number of entries" );
    rtems_test_exit( 0 );
  }

  puts( "Exercising blocking discipline w/extract in FIFO order " );
  do_test( RTEMS_FIFO, TRUE );

  puts( "Exercising blocking discipline w/unblock in FIFO order" );
  do_test( RTEMS_FIFO, FALSE );

  rtems_test_pause_and_screen_number( 2 );

  puts( "Exercising blocking discipline w/extract in priority order " );
  do_test( RTEMS_PRIORITY, TRUE );

  puts( "Exercising blocking discipline w/unblock in priority order" );
  do_test( RTEMS_PRIORITY, FALSE );

  TEST_END();
  rtems_test_exit(0);
}
Exemplo n.º 24
0
static void test(test_context *self)
{
  uintptr_t pattern_0 = (uintptr_t) 0xaaaaaaaaaaaaaaaaU;
  uintptr_t pattern_1 = (uintptr_t) 0x5555555555555555U;

  memset(self, 0, sizeof(*self));

  self->control_task = rtems_task_self();

  start_validate_task(&self->validate_tasks[0], pattern_0, PRIORITY_LOW);
  start_validate_task(&self->validate_tasks[1], pattern_1, PRIORITY_HIGH);
  start_timer(self);
  wait_for_finish();
}
Exemplo n.º 25
0
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_status_code     status;
  rtems_id              timer;
  rtems_interval        start;
  rtems_interval        now;

  puts( "\n\n*** TEST 38 ***" );

  main_task = rtems_task_self();

  /*
   *  Timer used in multiple ways
   */
  status = rtems_timer_create( 1, &timer );
  directive_failed( status, "rtems_timer_create" );

  /*
   *  Get starting time
   */
  start = rtems_clock_get_ticks_since_boot();

  status = rtems_signal_catch( signal_handler, RTEMS_DEFAULT_MODES );
  directive_failed( status, "rtems_signal_catch" );
  puts( "rtems_signal_catch - handler installed" );

  /*
   * Test Signal from ISR
   */
  signal_sent = FALSE;

  status = rtems_timer_fire_after( timer, 10, test_signal_from_isr, NULL );
  directive_failed( status, "timer_fire_after failed" );

  while (1) {
    now = rtems_clock_get_ticks_since_boot();
    if ( (now-start) > 100 ) {
      puts( "Signal from ISR did not get processed\n" );
      rtems_test_exit( 0 );
    }
    if ( signal_processed )
      break;
  }

  puts( "Signal sent from ISR has been processed" );
  puts( "*** END OF TEST 38 ***" );
  rtems_test_exit( 0 );
}
Exemplo n.º 26
0
rtems_task Init(
  rtems_task_argument ignored
)
{
  rtems_status_code     sc;
  int                   resets;

  puts(
    "\n\n*** TEST INTERRUPT CRITICAL SECTION " TEST_NAME " ***\n"
    "Init - Trying to generate timeout of a thread that had its blocking\n"
    "Init -   request satisfied while blocking but before time timeout"
  );

  puts( "Init - rtems_semaphore_create - OK" );
  sc = rtems_semaphore_create(
    rtems_build_name( 'S', 'M', '1', ' ' ),
    0,
    RTEMS_DEFAULT_ATTRIBUTES,
    RTEMS_NO_PRIORITY,
    &Semaphore
  );
  directive_failed( sc, "rtems_semaphore_create of SM1" );

  Main_task = rtems_task_self();
  Main_TCB  = _Thread_Get_executing();

  interrupt_critical_section_test_support_initialize( test_release_from_isr );

  case_hit = false;

  for (resets=0 ; !case_hit && resets<10 ;) {
    if ( interrupt_critical_section_test_support_delay() )
      resets++;

    sc = rtems_semaphore_obtain( Semaphore, RTEMS_DEFAULT_OPTIONS, 2 );
    if ( sc == RTEMS_SUCCESSFUL )
      break;
    fatal_directive_status( sc, RTEMS_TIMEOUT, "rtems_semaphore_obtain" );
  }

  if ( case_hit ) {
    puts( "Init - Case hit" );
    puts( "*** END OF TEST INTERRUPT CRITICAL SECTION " TEST_NAME " ***" );
  } else
    puts( "Init - Case not hit - ran too long" );


  rtems_test_exit(0);
}
Exemplo n.º 27
0
static void test(
  test_context *self,
  bool task_0_fpu,
  bool task_1_fpu,
  bool task_2_fpu
)
{
  rtems_status_code sc;
  uintptr_t pattern_0 = (uintptr_t) 0xaaaaaaaaaaaaaaaaU;
  uintptr_t pattern_1 = (uintptr_t) 0x5555555555555555U;
  uintptr_t pattern_2 = (uintptr_t) 0x0000000000000000U;

  memset(self, 0, sizeof(*self));

  self->control_task = rtems_task_self();
  start_validate_task(
    &self->validate_tasks[0],
    pattern_0,
    PRIORITY_HIGH,
    task_0_fpu
  );
  start_validate_task(
    &self->validate_tasks[1],
    pattern_1,
    PRIORITY_LOW,
    task_1_fpu
  );
  start_validate_task(
    &self->validate_tasks[2],
    pattern_2,
    PRIORITY_LOW,
    task_2_fpu
  );
  start_timer(self);
  wait_for_finish();

  sc = rtems_task_delete(self->validate_tasks[0]);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  sc = rtems_task_delete(self->validate_tasks[1]);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  sc = rtems_task_delete(self->validate_tasks[2]);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  sc = rtems_timer_delete(self->timer);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
}
Exemplo n.º 28
0
rtems_task Init(
  rtems_task_argument argument
)
{
  rtems_id              main_task;
  int                   count;
  Objects_Control      *o;
  Objects_Locations     location;
  Objects_Id            id;
  Objects_Information  *info;

  puts( "\n\n*** TEST OBJECT GET NEXT ***" );

  info      = &_RTEMS_tasks_Information;
  main_task = rtems_task_self();

  puts( "Init - _Objects_Get_next - NULL object information" );
  o = _Objects_Get_next( NULL, main_task, &location, &id );
  rtems_test_assert( o == NULL );

  puts( "Init - _Objects_Get_next - NULL location" );
  o = _Objects_Get_next( info, main_task, NULL, &id );
  rtems_test_assert( o == NULL );

  puts( "Init - _Objects_Get_next - NULL id" );
  o = _Objects_Get_next( info, main_task, &location, NULL );
  rtems_test_assert( o == NULL );

  /* XXX push the three NULL error cases */

  /* simple case of only all tasks in the system, starting at initial */
  count = scan_objects( info, OBJECTS_ID_INITIAL_INDEX );
  printf( "%d RTEMS Task%s\n", count, ((count == 1) ? "" : "s") );
  rtems_test_assert( count == 1 );

  /* simple case of only 1 task in the system, starting at that task */
  count = scan_objects( info, main_task );
  printf( "%d RTEMS Task%s\n", count, ((count == 1) ? "" : "s") );
  rtems_test_assert( count == 1 );

  /* XXX create >= 1 task and make sure the counts are correct when */
  /* XXX you start the search at initial, first id, arbitrary id */

  /* XXX try with a manager with no objects created */

  puts( "*** END OF TEST OBJECT GET NEXT ***" );
  rtems_test_exit( 0 );
}
Exemplo n.º 29
0
rtems_task Test_task(
  rtems_task_argument index
)
{
  rtems_status_code  status;
  rtems_name         name;

  status = rtems_object_get_classic_name( rtems_task_self(), &name );
  directive_failed( status, "rtems_object_get_classic_name" );

  put_name( name, FALSE );
  puts( " - Successfully yielded it to higher priority task" );

  puts( "*** END OF SP76 TEST ***" );
  rtems_test_exit( 0 );
}
Exemplo n.º 30
0
static void test(void)
{
  test_context *ctx = &test_instance;
  rtems_status_code sc;

  ctx->tasks[M] = rtems_task_self();
  start_task(ctx, A_1, worker, 1);
  start_task(ctx, A_2_0, worker, 2);
  start_task(ctx, A_2_1, worker, 2);
  start_task(ctx, H, helper, 3);

  sc = rtems_semaphore_create(
    rtems_build_name(' ', 'M', 'T', 'X'),
    1,
    RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_INHERIT_PRIORITY,
    0,
    &ctx->mtx
  );
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  obtain(ctx);
  request(ctx, A_1, REQ_MTX_OBTAIN);
  check_generations(ctx, NONE, NONE);
  assert_prio(ctx, M, 1);
  release(ctx);
  check_generations(ctx, A_1, NONE);
  assert_prio(ctx, M, 3);
  request(ctx, A_1, REQ_MTX_RELEASE);
  check_generations(ctx, A_1, NONE);

  obtain(ctx);
  request(ctx, A_2_0, REQ_MTX_OBTAIN);
  request(ctx, A_1, REQ_MTX_OBTAIN);
  request(ctx, A_2_1, REQ_MTX_OBTAIN);
  check_generations(ctx, NONE, NONE);
  assert_prio(ctx, M, 1);
  release(ctx);
  check_generations(ctx, A_1, NONE);
  assert_prio(ctx, M, 3);
  assert_prio(ctx, A_1, 1);
  request(ctx, A_1, REQ_MTX_RELEASE);
  check_generations(ctx, A_1, A_2_0);
  request(ctx, A_2_0, REQ_MTX_RELEASE);
  check_generations(ctx, A_2_0, A_2_1);
  request(ctx, A_2_1, REQ_MTX_RELEASE);
  check_generations(ctx, A_2_1, NONE);
}