source: rtems/cpukit/score/src/percpustatewait.c @ fce900b5

5
Last change on this file since fce900b5 was 9a1bab2, checked in by Sebastian Huber <sebastian.huber@…>, on 06/05/14 at 09:19:32

score: _Per_CPU_State_wait_for_non_initial_state()

Replace _Per_CPU_State_wait_for_ready_to_start_multitasking() with
_Per_CPU_State_wait_for_non_initial_state(). Implement this function.

  • Property mode set to 100644
File size: 1.3 KB
Line 
1/*
2 * Copyright (c) 2014 embedded brains GmbH.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Dornierstr. 4
6 *  82178 Puchheim
7 *  Germany
8 *  <rtems@embedded-brains.de>
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.org/license/LICENSE.
13 */
14
15#if HAVE_CONFIG_H
16  #include "config.h"
17#endif
18
19#include <rtems/score/percpu.h>
20#include <rtems/counter.h>
21
22bool _Per_CPU_State_wait_for_non_initial_state(
23  uint32_t cpu_index,
24  uint32_t timeout_in_ns
25)
26{
27  const Per_CPU_Control *cpu = _Per_CPU_Get_by_index( cpu_index );
28  Per_CPU_State state = cpu->state;
29
30  if ( timeout_in_ns > 0 ) {
31    rtems_counter_ticks ticks =
32      rtems_counter_nanoseconds_to_ticks( timeout_in_ns );
33    rtems_counter_ticks a = rtems_counter_read();
34    rtems_counter_ticks delta = 0;
35
36    while ( ticks > delta && state == PER_CPU_STATE_INITIAL ) {
37      rtems_counter_ticks b;
38
39      _CPU_SMP_Processor_event_receive();
40      state = cpu->state;
41
42      ticks -= delta;
43
44      b = rtems_counter_read();
45      delta = rtems_counter_difference( b, a );
46      a = b;
47    }
48  } else {
49    while ( state == PER_CPU_STATE_INITIAL ) {
50      _CPU_SMP_Processor_event_receive();
51      state = cpu->state;
52    }
53  }
54
55  return state != PER_CPU_STATE_INITIAL;
56}
Note: See TracBrowser for help on using the repository browser.