source: rtems/cpukit/score/src/percpu.c @ c2934b96

4.115
Last change on this file since c2934b96 was c2934b96, checked in by Sebastian Huber <sebastian.huber@…>, on 02/17/14 at 12:24:55

score: Move SMP interrupt stack initialization

Move SMP interrupt stack initialization for secondary processors from
_SMP_Handler_initialize() to _ISR_Handler_initialization() to avoid code
duplication. Apply _CPU_Interrupt_stack_setup() to all interrupt
stacks.

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/**
2 * @file
3 *
4 * @brief Allocate and Initialize Per CPU Structures
5 * @ingroup PerCPU
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2011.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/system.h>
22#include <rtems/score/address.h>
23#include <rtems/score/thread.h>
24#include <rtems/score/percpu.h>
25#include <rtems/score/wkspace.h>
26#include <rtems/config.h>
27#include <string.h>
28
29#if defined(RTEMS_SMP)
30
31  #include <rtems/score/smp.h>
32  #include <rtems/bspsmp.h>
33
34  void _SMP_Handler_initialize(void)
35  {
36    uint32_t max_cpus = rtems_configuration_get_maximum_processors();
37    uint32_t cpu;
38
39    /*
40     * Discover and initialize the secondary cores in an SMP system.
41     */
42    max_cpus = bsp_smp_initialize( max_cpus );
43
44    _SMP_Processor_count = max_cpus;
45
46    for ( cpu = 1 ; cpu < max_cpus; ++cpu ) {
47      const Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( cpu );
48
49      _Per_CPU_Wait_for_state(
50        per_cpu,
51        PER_CPU_STATE_READY_TO_BEGIN_MULTITASKING
52      );
53    }
54  }
55
56  void _Per_CPU_Change_state(
57    Per_CPU_Control *per_cpu,
58    Per_CPU_State new_state
59  )
60  {
61    per_cpu->state = new_state;
62    _CPU_SMP_Processor_event_broadcast();
63  }
64
65  void _Per_CPU_Wait_for_state(
66    const Per_CPU_Control *per_cpu,
67    Per_CPU_State desired_state
68  )
69  {
70    while ( per_cpu->state != desired_state ) {
71      _CPU_SMP_Processor_event_receive();
72    }
73  }
74#else
75  /*
76   * On single core systems, we can efficiently directly access a single
77   * statically allocated per cpu structure.  And the fields are initialized
78   * as individual elements just like it has always been done.
79   */
80  Per_CPU_Control_envelope _Per_CPU_Information[1];
81#endif
Note: See TracBrowser for help on using the repository browser.