示例#1
0
文件: init.c 项目: krohini1593/rtems
static void standard_funcs_giant_taken_test( size_t set_size,
    cpu_set_t *cpu_set, SMP_barrier_State *bs )
{
  if ( rtems_get_current_processor() == 0)
    _Thread_Disable_dispatch();

  _SMP_barrier_Wait( &ctx.barrier, bs, rtems_get_processor_count() );

  cache_manager_smp_functions( set_size, cpu_set );

  if ( rtems_get_current_processor() == 0)
    _Thread_Enable_dispatch();
}
示例#2
0
文件: init.c 项目: krohini1593/rtems
static void test_func_test( size_t set_size, cpu_set_t *cpu_set,
    SMP_barrier_State *bs )
{
  ctx.count[rtems_get_current_processor()] = 0;
  _SMP_barrier_Wait( &ctx.barrier, bs, rtems_get_processor_count() );

  _SMP_Multicast_action( set_size, cpu_set, test_cache_message, &ctx );

  _SMP_barrier_Wait( &ctx.barrier, bs, rtems_get_processor_count() );

  rtems_test_assert( ctx.count[rtems_get_current_processor()] ==
      rtems_get_processor_count() );
}
示例#3
0
文件: init.c 项目: gedare/rtems
static void *thread_b(void *arg)
{
  test_context *ctx;
  rtems_id scheduler_b_id;
  rtems_status_code sc;
  rtems_task_priority prio;
  int prio_ceiling;
  int eno;

  ctx = arg;

  rtems_test_assert(rtems_get_current_processor() == 0);

  sc = rtems_scheduler_ident(SCHED_B, &scheduler_b_id);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  sc = rtems_task_set_priority(pthread_self(), RTEMS_CURRENT_PRIORITY, &prio);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  sc = rtems_task_set_scheduler(pthread_self(), scheduler_b_id, prio);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  rtems_test_assert(rtems_get_current_processor() == 1);

  eno = pthread_mutex_init(&ctx->mtx_b, &ctx->mtx_attr);
  rtems_test_assert(eno == 0);

  eno = pthread_mutex_getprioceiling(&ctx->mtx_b, &prio_ceiling);
  rtems_test_assert(eno == 0);
  rtems_test_assert(prio_ceiling == 254);

  eno = pthread_mutex_lock(&ctx->mtx_b);
  rtems_test_assert(eno == 0);

  eno = pthread_mutex_unlock(&ctx->mtx_b);
  rtems_test_assert(eno == 0);

  eno = pthread_mutex_destroy(&ctx->mtx_b);
  rtems_test_assert(eno == 0);

  eno = pthread_mutex_getprioceiling(&ctx->mtx_a, &prio_ceiling);
  rtems_test_assert(eno == 0);
  rtems_test_assert(prio_ceiling == 126);

  eno = pthread_mutex_lock(&ctx->mtx_a);
  rtems_test_assert(eno == EINVAL);

  return ctx;
}
示例#4
0
文件: init.c 项目: Dipupo/rtems
static void delay_clock_tick(test_context *ctx)
{
  rtems_interrupt_level level;
  const Per_CPU_Control *cpu_self = _Per_CPU_Get_by_index(0);
  const Per_CPU_Control *cpu_other = _Per_CPU_Get_by_index(1);
  uint64_t ticks;

  rtems_test_assert(rtems_get_current_processor() == 0);

  rtems_test_spin_until_next_tick();
  ticks = cpu_self->Watchdog.ticks;

  rtems_interrupt_local_disable(level);

  /* (A) */
  wait(ctx, &ctx->delay_barrier_state);

  /* (B) */
  wait(ctx, &ctx->delay_barrier_state);

  rtems_test_assert(cpu_self->Watchdog.ticks == ticks);
  rtems_test_assert(cpu_other->Watchdog.ticks == ticks + 1);

  rtems_interrupt_local_enable(level);

  rtems_test_assert(cpu_self->Watchdog.ticks == ticks + 1);
  rtems_test_assert(cpu_other->Watchdog.ticks == ticks + 1);

  /* (C) */
  wait(ctx, &ctx->delay_barrier_state);
}
示例#5
0
rtems_task Test_task(
  rtems_task_argument task_index
)
{
  uint32_t          cpu_num;
  char              name[5];
  char             *p;

  /* Get the task name */
  p = rtems_object_get_name( RTEMS_SELF, 5, name );
  rtems_test_assert( p != NULL );

   /* Get the CPU Number */
  cpu_num = rtems_get_current_processor();

  /* Print that the task is up and running. */
  Loop();
  locked_printf(" CPU %" PRIu32 " running Task %s\n", cpu_num, name);

  /* Set the flag that the task is up and running */
  TaskRan[cpu_num] = true;


  /* Drop into a loop which will keep this task on
   * running on the cpu.
   */
  while(1);
}
示例#6
0
文件: init.c 项目: greenmeent/rtems
rtems_task Test_task(
  rtems_task_argument argument
)
{
  locked_printf( "Shut down from CPU %" PRIu32 "\n", rtems_get_current_processor() );
  success();
}
示例#7
0
文件: init.c 项目: gedare/rtems
static void task(rtems_task_argument arg)
{
  rtems_status_code sc;

  (void) arg;

  rtems_test_assert(rtems_get_current_processor() == 1);
  rtems_test_assert(sched_get_priority_min(SCHED_RR) == 1);
  rtems_test_assert(sched_get_priority_max(SCHED_RR) == INT_MAX - 1);

  sc = rtems_semaphore_obtain(cmtx_id, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
  rtems_test_assert(sc == RTEMS_NOT_DEFINED);

  sc = rtems_event_transient_send(main_task_id);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  sc = rtems_semaphore_obtain(imtx_id, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  sc = rtems_semaphore_release(imtx_id);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  sc = rtems_event_transient_send(main_task_id);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  while (1) {
    /* Do nothing */
  }
}
示例#8
0
文件: init.c 项目: Avanznow/rtems
static void fatal_extension(
  rtems_fatal_source source,
  bool is_internal,
  rtems_fatal_code code
)
{
  if (
    source == RTEMS_FATAL_SOURCE_APPLICATION
      || source == RTEMS_FATAL_SOURCE_SMP
  ) {
    uint32_t self = rtems_get_current_processor();
    SMP_barrier_State state = SMP_BARRIER_STATE_INITIALIZER;

    assert(!is_internal);

    if (self == main_cpu) {
      assert(source == RTEMS_FATAL_SOURCE_SMP);
      assert(code == SMP_FATAL_SHUTDOWN_RESPONSE);
    } else {
      assert(source == RTEMS_FATAL_SOURCE_APPLICATION);
      assert(code == 0xdeadbeef);
    }

    _SMP_barrier_Wait(&fatal_barrier, &state, CPU_COUNT);

    if (self == 0) {
      rtems_test_endk();
    }

    _SMP_barrier_Wait(&fatal_barrier, &state, CPU_COUNT);
  }
}
示例#9
0
文件: init.c 项目: Avanznow/rtems
static void runner(rtems_task_argument self)
{
  test_context *ctx = &ctx_instance;
  rtems_task_argument next = (self + 1) % RUNNER_COUNT;
  rtems_id next_runner = ctx->runner_ids[next];
  test_counters *counters = &ctx->counters[self];
  test_counters *next_counters = &ctx->counters[next];

  while (true) {
    uint32_t current_cpu = rtems_get_current_processor();

    ++counters->cycles_per_cpu[current_cpu].counter;

    if (ctx->token == self) {
      uint32_t other_cpu = (current_cpu + 1) % CPU_COUNT;
      uint32_t snapshot;

      ++counters->tokens_per_cpu[current_cpu].counter;

      change_prio(next_runner, PRIO_HIGH);

      snapshot = next_counters->cycles_per_cpu[other_cpu].counter;
      while (next_counters->cycles_per_cpu[other_cpu].counter == snapshot) {
        /* Wait for other thread to resume execution */
      }

      ctx->token = next;

      change_prio(RTEMS_SELF, PRIO_NORMAL);
    }
  }
}
示例#10
0
rtems_task Test_task(
  rtems_task_argument unused
)
{
  rtems_id          tid;
  rtems_time_of_day time;
  uint32_t    task_index;
  rtems_status_code status;
  uint32_t          cpu_num;
  char              name[5];
  char             *p;

  /* Get the task name */
  p = rtems_object_get_name( RTEMS_SELF, 5, name );
  rtems_test_assert( p != NULL );

  status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );
  task_index = task_number( tid );
  for ( ; ; ) {

    /* Get the CPU Number */
    cpu_num = rtems_get_current_processor();

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

    PrintTaskInfo( p, &time );
    status = rtems_task_wake_after(
      task_index * 5 * rtems_clock_get_ticks_per_second() );
  }
}
示例#11
0
文件: init.c 项目: Avanznow/rtems
static void Init(rtems_task_argument arg)
{
  uint32_t self = rtems_get_current_processor();
  uint32_t cpu_count = rtems_get_processor_count();

  rtems_test_begink();

  main_cpu = self;

  if (cpu_count >= CPU_COUNT) {
    rtems_status_code sc;
    rtems_id id;

    sc = rtems_task_create(
      rtems_build_name( 'W', 'A', 'I', 'T' ),
      1,
      RTEMS_MINIMUM_STACK_SIZE,
      RTEMS_DEFAULT_MODES,
      RTEMS_DEFAULT_ATTRIBUTES,
      &id
    );
    assert(sc == RTEMS_SUCCESSFUL);

    sc = rtems_task_start(id, acquire_giant_and_fatal_task, 0);
    assert(sc == RTEMS_SUCCESSFUL);

    wait_for_giant();
  } else {
    rtems_test_endk();
    exit(0);
  }
}
示例#12
0
文件: init.c 项目: Dipupo/rtems
static void timer_task(rtems_task_argument arg)
{
  test_context *ctx = (test_context *) arg;
  rtems_status_code sc;
  rtems_id timer_id;

  rtems_test_assert(rtems_get_current_processor() == 1);

  sc = rtems_timer_create(SCHEDULER_B, &timer_id);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  /* (A) */
  wait(ctx, &ctx->timer_barrier_state);

  sc = rtems_timer_fire_after(timer_id, 1, timer_isr, ctx);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  sc = rtems_task_wake_after(1);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  sc = rtems_timer_delete(timer_id);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  /* (C) */
  wait(ctx, &ctx->timer_barrier_state);

  while (true) {
    /* Wait for deletion */
  }
}
示例#13
0
文件: init.c 项目: Fyleo/rtems
static void fatal_extension(
  rtems_fatal_source source,
  bool is_internal,
  rtems_fatal_code code
)
{
  if (
    source == RTEMS_FATAL_SOURCE_APPLICATION
      || source == RTEMS_FATAL_SOURCE_SMP
  ) {
    uint32_t self = rtems_get_current_processor();

    assert(!is_internal);

    if (self == main_cpu) {
      uint32_t cpu;

      assert(source == RTEMS_FATAL_SOURCE_APPLICATION);
      assert(code == 0xdeadbeef);

      for (cpu = 0; cpu < MAX_CPUS; ++cpu) {
        const Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( cpu );
        Per_CPU_State state = per_cpu->state;

        assert(state == PER_CPU_STATE_SHUTDOWN);
      }

      rtems_test_endk();
    } else {
      assert(source == RTEMS_FATAL_SOURCE_SMP);
      assert(code == SMP_FATAL_SHUTDOWN);
    }
  }
}
示例#14
0
文件: init.c 项目: krohini1593/rtems
static void test_func_isrdisabled_test( size_t set_size, cpu_set_t *cpu_set,
    SMP_barrier_State *bs )
{
  ISR_Level isr_level;

  ctx.count[rtems_get_current_processor()] = 0;
  _ISR_Disable_without_giant( isr_level );

  _SMP_barrier_Wait( &ctx.barrier, bs, rtems_get_processor_count() );

  _SMP_Multicast_action( set_size, cpu_set, test_cache_message, &ctx );

  _ISR_Enable_without_giant( isr_level );

  _SMP_barrier_Wait( &ctx.barrier, bs, rtems_get_processor_count() );

  rtems_test_assert( ctx.count[rtems_get_current_processor()] ==
      rtems_get_processor_count() );
}
示例#15
0
文件: init.c 项目: gedare/rtems
static void set_init_task(void)
{
  while( rtems_semaphore_obtain (task_sem, RTEMS_NO_WAIT, 0) != RTEMS_SUCCESSFUL );

  /* Set Init task data */
  task_data[0].ran = true;
  task_data[0].actual_cpu = rtems_get_current_processor();

  rtems_semaphore_release(task_sem);
}
示例#16
0
文件: init.c 项目: AlexShiLucky/rtems
static void load_task(rtems_task_argument arg)
{
  volatile int *load_data = (volatile int *) arg;
  size_t n = data_size;
  size_t clsz = cache_line_size;
  int j = (int) rtems_get_current_processor();

  while (true) {
    j = dirty_data_cache(load_data, n, clsz, j);
  }
}
示例#17
0
文件: init.c 项目: krohini1593/rtems
static void test_func_giant_taken_test( size_t set_size, cpu_set_t *cpu_set,
    SMP_barrier_State *bs )
{
  ctx.count[rtems_get_current_processor()] = 0;

  if ( rtems_get_current_processor() == 0)
    _Thread_Disable_dispatch();

  _SMP_barrier_Wait( &ctx.barrier, bs, rtems_get_processor_count() );

  _SMP_Multicast_action( set_size, cpu_set, test_cache_message, &ctx );

  _SMP_barrier_Wait( &ctx.barrier, bs, rtems_get_processor_count() );

  rtems_test_assert( ctx.count[rtems_get_current_processor()] ==
      rtems_get_processor_count() );

  if ( rtems_get_current_processor() == 0)
    _Thread_Enable_dispatch();
}
示例#18
0
文件: init.c 项目: AlexShiLucky/rtems
static void test_task(rtems_task_argument arg)
{
  test_context *ctx = &test_instance;

  tests();

  ctx->cpu_index[arg] = rtems_get_current_processor();

  barrier_wait(ctx);

  rtems_task_suspend(RTEMS_SELF);
  rtems_test_assert(0);
}
示例#19
0
static void task(rtems_task_argument arg)
{
  rtems_status_code   sc;

  while (true) {
    sc = rtems_semaphore_obtain (task_sem, RTEMS_NO_WAIT, 0);
    if (sc == RTEMS_SUCCESSFUL) {
      task_data[arg].ran = true;
      task_data[arg].actual_cpu = rtems_get_current_processor();
      rtems_semaphore_release(task_sem);
    }
  }
}
示例#20
0
文件: init.c 项目: AlexShiLucky/rtems
static void task(rtems_task_argument arg)
{
  rtems_status_code sc;

  (void) arg;

  rtems_test_assert(rtems_get_current_processor() == 1);

  sc = rtems_event_transient_send(main_task_id);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  while (1) {
    /* Do nothing */
  }
}
示例#21
0
文件: init.c 项目: gedare/rtems
static void test(test_context *ctx)
{
  uint32_t cpu_count;
  int prio_ceiling;
  int eno;

  cpu_count = rtems_get_processor_count();

  rtems_test_assert(rtems_get_current_processor() == 0);

  eno = pthread_mutexattr_init(&ctx->mtx_attr);
  rtems_test_assert(eno == 0);

  eno = pthread_mutexattr_setprotocol(&ctx->mtx_attr, PTHREAD_PRIO_PROTECT);
  rtems_test_assert(eno == 0);

  eno = pthread_mutex_init(&ctx->mtx_a, &ctx->mtx_attr);
  rtems_test_assert(eno == 0);

  eno = pthread_mutex_getprioceiling(&ctx->mtx_a, &prio_ceiling);
  rtems_test_assert(eno == 0);
  rtems_test_assert(prio_ceiling == 126);

  eno = pthread_mutex_lock(&ctx->mtx_a);
  rtems_test_assert(eno == 0);

  eno = pthread_mutex_unlock(&ctx->mtx_a);
  rtems_test_assert(eno == 0);

  if (cpu_count > 1) {
    void *exit_code;

    eno = pthread_create(&ctx->thread_b, NULL, thread_b, ctx);
    rtems_test_assert(eno == 0);

    exit_code = NULL;
    eno = pthread_join(ctx->thread_b, &exit_code);
    rtems_test_assert(eno == 0);
    rtems_test_assert(exit_code == ctx);
  }

  eno = pthread_mutex_destroy(&ctx->mtx_a);
  rtems_test_assert(eno == 0);

  eno = pthread_mutexattr_destroy(&ctx->mtx_attr);
  rtems_test_assert(eno == 0);
}
示例#22
0
文件: init.c 项目: Avanznow/rtems
rtems_task Init(
  rtems_task_argument argument
)
{
  uint32_t           i;
  char               ch;
  uint32_t           cpu_num;
  rtems_id           id;
  rtems_status_code  status;

  TEST_BEGIN();

  locked_print_initialize();

  for ( killtime=0; killtime<1000000; killtime++ )
    ;
  
  for ( i=0; i<rtems_get_processor_count() -1; i++ ) {
    ch = '1' + i;

    status = rtems_task_create(
      rtems_build_name( 'T', 'A', ch, ' ' ),
      1,
      RTEMS_MINIMUM_STACK_SIZE,
      RTEMS_DEFAULT_MODES,
      RTEMS_DEFAULT_ATTRIBUTES,
      &id
    );
    directive_failed( status, "task create" );

    cpu_num = rtems_get_current_processor();
    locked_printf(" CPU %" PRIu32 " start task TA%c\n", cpu_num, ch);

    status = rtems_task_start( id, Test_task, i+1 );
    directive_failed( status, "task start" );
  }

  locked_printf(" kill 10 clock ticks\n" );
  while ( rtems_clock_get_ticks_since_boot() < 10 )
    ;

  rtems_cpu_usage_report();

  TEST_END();
  rtems_test_exit(0);
}
示例#23
0
文件: init.c 项目: AlexShiLucky/rtems
static void test_send_message_while_processing_a_message(
  test_context *ctx
)
{
  uint32_t cpu_count = rtems_get_processor_count();
  uint32_t cpu_index_self = rtems_get_current_processor();
  uint32_t cpu_index;
  SMP_barrier_State *bs = &ctx->main_barrier_state;

  _SMP_Set_test_message_handler(barrier_handler);

  for (cpu_index = 0; cpu_index < cpu_count; ++cpu_index) {
    if (cpu_index != cpu_index_self) {
      _SMP_Send_message(cpu_index, SMP_MESSAGE_TEST);

      /* (A) */
      barrier(ctx, bs);

      rtems_test_assert(ctx->counters[cpu_index].value == 1);
      _SMP_Send_message(cpu_index, SMP_MESSAGE_TEST);

      /* (B) */
      barrier(ctx, bs);

      rtems_test_assert(ctx->counters[cpu_index].value == 1);

      /* (C) */
      barrier(ctx, bs);

      /* (A) */
      barrier(ctx, bs);

      rtems_test_assert(ctx->counters[cpu_index].value == 2);

      /* (B) */
      barrier(ctx, bs);

      /* (C) */
      barrier(ctx, bs);

      ctx->counters[cpu_index].value = 0;
    }
  }
}
示例#24
0
文件: init.c 项目: AlexShiLucky/rtems
static void test_send_message_flood(
  test_context *ctx
)
{
  uint32_t cpu_count = rtems_get_processor_count();
  uint32_t cpu_index_self = rtems_get_current_processor();
  uint32_t cpu_index;

  _SMP_Set_test_message_handler(counter_handler);

  for (cpu_index = 0; cpu_index < cpu_count; ++cpu_index) {
    uint32_t i;

    /* Wait 1us so that all outstanding messages have been processed */
    rtems_counter_delay_nanoseconds(1000000);

    for (i = 0; i < cpu_count; ++i) {
      if (i != cpu_index) {
        ctx->copy_counters[i] = ctx->counters[i].value;
      }
    }

    for (i = 0; i < 100000; ++i) {
      _SMP_Send_message(cpu_index, SMP_MESSAGE_TEST);
    }

    for (i = 0; i < cpu_count; ++i) {
      if (i != cpu_index) {
        rtems_test_assert(ctx->copy_counters[i] == ctx->counters[i].value);
      }
    }
  }

  for (cpu_index = 0; cpu_index < cpu_count; ++cpu_index) {
    printf(
      "inter-processor interrupts for processor %"
        PRIu32 "%s: %" PRIu32 "\n",
      cpu_index,
      cpu_index == cpu_index_self ? " (main)" : "",
      ctx->counters[cpu_index].value
    );
  }
}
示例#25
0
文件: init.c 项目: goetzpf/rtems
static void test(void)
{
    test_context *ctx = &ctx_instance;
    rtems_status_code sc;
    rtems_mode mode;

    ctx->consumer = rtems_task_self();
    ctx->consumer_processor = rtems_get_current_processor();

    sc = rtems_signal_catch(signal_handler, RTEMS_DEFAULT_MODES);
    rtems_test_assert(sc == RTEMS_SUCCESSFUL);

    sc = rtems_task_create(
             rtems_build_name('P', 'R', 'O', 'D'),
             RTEMS_MINIMUM_PRIORITY,
             RTEMS_MINIMUM_STACK_SIZE,
             RTEMS_DEFAULT_MODES,
             RTEMS_DEFAULT_ATTRIBUTES,
             &ctx->producer
         );
    rtems_test_assert(sc == RTEMS_SUCCESSFUL);

    sc = rtems_task_start(ctx->producer, producer, (rtems_task_argument) ctx);
    rtems_test_assert(sc == RTEMS_SUCCESSFUL);

    check_consumer_processor(ctx);

    wait_for_state(ctx, SIG_0_SENT);
    change_state(ctx, SIG_0_ENABLE);

    sc = rtems_task_mode(RTEMS_ASR, RTEMS_ASR_MASK, &mode);
    rtems_test_assert(sc == RTEMS_SUCCESSFUL);

    wait_for_state(ctx, SIG_0_PROCESSED);

    check_consumer_processor(ctx);

    change_state(ctx, SIG_1_READY);
    wait_for_state(ctx, SIG_1_PROCESSED);

    check_consumer_processor(ctx);
}
示例#26
0
static void verify_tasks(void)
{
  int i;

  printf("Verify Tasks Ran\n");
 
  while( rtems_semaphore_obtain (task_sem, RTEMS_NO_WAIT, 0) != RTEMS_SUCCESSFUL );
 
  /* Set Init task data */
  task_data[0].ran = true;
  task_data[0].actual_cpu = rtems_get_current_processor();

  /* Verify all tasks */
  for (i = 0; i < NUM_CPUS; i++) {
    if (i==0)
      printf("Init(%d): ran=%d expected=%d actual=%d\n", 
        task_data[i].priority,
        task_data[i].ran,
        task_data[i].expected_cpu,
        task_data[i].actual_cpu
      );
    else
      printf( "TA0%d(%d): ran=%d expected=%d actual=%d\n", 
        i, 
        task_data[i].priority,
        task_data[i].ran,
        task_data[i].expected_cpu,
        task_data[i].actual_cpu
      );

    /*  Abort test if values are not as expected */
    if ( task_data[i].expected_cpu == -1 )
      rtems_test_assert( task_data[i].ran == false );
    else {
      rtems_test_assert( task_data[i].ran == true );
      rtems_test_assert( task_data[i].expected_cpu == task_data[i].actual_cpu );
    }
  }

  rtems_semaphore_release(task_sem);
}
示例#27
0
文件: init.c 项目: AlexShiLucky/rtems
static rtems_status_code test_driver_init(
  rtems_device_major_number major,
  rtems_device_minor_number minor,
  void *arg
)
{
  uint32_t self = rtems_get_current_processor();
  uint32_t cpu_count = rtems_get_processor_count();
  uint32_t cpu;

  rtems_test_begink();

  assert(rtems_configuration_get_maximum_processors() == MAX_CPUS);

  main_cpu = self;

  for (cpu = 0; cpu < MAX_CPUS; ++cpu) {
    const Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( cpu );
    Per_CPU_State state = per_cpu->state;

    if (cpu == self) {
      assert(state == PER_CPU_STATE_INITIAL);
    } else if (cpu < cpu_count) {
      assert(
        state == PER_CPU_STATE_INITIAL
          || state == PER_CPU_STATE_READY_TO_START_MULTITASKING
      );
    } else {
      assert(state == PER_CPU_STATE_INITIAL);
    }
  }

  if (cpu_count > 1) {
    rtems_fatal(RTEMS_FATAL_SOURCE_APPLICATION, 0xdeadbeef);
  } else {
    rtems_test_endk();
    exit(0);
  }

  return RTEMS_SUCCESSFUL;
}
示例#28
0
文件: init.c 项目: goetzpf/rtems
static void producer(rtems_task_argument arg)
{
    test_context *ctx = (test_context *) arg;

    ctx->producer_processor = rtems_get_current_processor();

    rtems_test_assert(ctx->consumer_processor != ctx->producer_processor);

    wait_for_state(ctx, SIG_0_READY);
    signal_send(ctx, SIG_0_SENT);

    check_producer_processor(ctx);

    wait_for_state(ctx, SIG_1_READY);
    signal_send(ctx, SIG_1_SENT);

    check_producer_processor(ctx);

    rtems_task_suspend(RTEMS_SELF);
    rtems_test_assert(0);
}
示例#29
0
文件: init.c 项目: greenmeent/rtems
rtems_task Init(
  rtems_task_argument argument
)
{
  uint32_t           i;
  char               ch;
  uint32_t           cpu_num;
  rtems_id           id;
  rtems_status_code  status;

  locked_print_initialize();
  rtems_test_begin();

  if ( rtems_get_processor_count() == 1 ) {
    success();
  }

  for ( i=0; i<rtems_get_processor_count() ; i++ ) {
    ch = '1' + i;

    status = rtems_task_create(
      rtems_build_name( 'T', 'A', ch, ' ' ),
      1,
      RTEMS_MINIMUM_STACK_SIZE,
      RTEMS_DEFAULT_MODES,
      RTEMS_DEFAULT_ATTRIBUTES,
      &id
    );
    directive_failed( status, "task create" );

    cpu_num = rtems_get_current_processor();
    locked_printf(" CPU %" PRIu32 " start task TA%c\n", cpu_num, ch);

    status = rtems_task_start( id, Test_task, i+1 );
    directive_failed( status, "task start" );
  }

  while (1)
    ;
}
示例#30
0
文件: bspreset.c 项目: Fyleo/rtems
void bsp_reset(void)
{
  uint32_t self_cpu = rtems_get_current_processor();

  if (self_cpu == 0) {
    volatile struct irqmp_regs *irqmp = LEON3_IrqCtrl_Regs;

    if (irqmp != NULL) {
      /*
       * Value was choosen to get something in the magnitude of 1ms on a 200MHz
       * processor.
       */
      uint32_t max_wait = 1234567;

      uint32_t cpu_count = rtems_get_processor_count();
      uint32_t halt_mask = 0;
      uint32_t i;

      for (i = 0; i < cpu_count; ++i) {
        if (i != self_cpu) {
          halt_mask |= UINT32_C(1) << i;
        }
      }

      /* Wait some time for secondary processors to halt */
      i = 0;
      while ((irqmp->mpstat & halt_mask) != halt_mask && i < max_wait) {
        ++i;
      }
    }

    __asm__ volatile (
      "mov 1, %g1\n"
      "ta 0\n"
      "nop"
    );
  }

  leon3_power_down_loop();
}