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

4.115
Last change on this file since baf8f4d was baf8f4d, checked in by Sebastian Huber <sebastian.huber@…>, on 05/14/13 at 08:12:52

smp: Simplify main CPU initialization

Call _SMP_Handler_initialize() later and move bsp_smp_initialize() into
_SMP_Handler_initialize(). Change bsp_smp_initialize() prototype to
match integer types of calling context.

  • Property mode set to 100644
File size: 1.9 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/thread.h>
23#include <rtems/score/percpu.h>
24#include <rtems/score/wkspace.h>
25#include <rtems/config.h>
26#include <string.h>
27
28#if defined(RTEMS_SMP)
29
30  #include <rtems/score/smp.h>
31
32  void _SMP_Handler_initialize(void)
33  {
34    uint32_t max_cpus = rtems_configuration_get_maximum_processors();
35    uint32_t cpu;
36
37    /*
38     *  Initialize per cpu pointer table
39     */
40    _Per_CPU_Information_p[0] = &_Per_CPU_Information[0];
41    for ( cpu = 1 ; cpu < max_cpus; ++cpu ) {
42
43      Per_CPU_Control *p = &_Per_CPU_Information[cpu];
44
45      _Per_CPU_Information_p[cpu] = p;
46
47#if CPU_ALLOCATE_INTERRUPT_STACK == TRUE
48      {
49        size_t size = rtems_configuration_get_interrupt_stack_size();
50        uintptr_t ptr;
51
52        p->interrupt_stack_low = _Workspace_Allocate_or_fatal_error( size );
53
54        ptr = (uintptr_t) _Addresses_Add_offset( p->interrupt_stack_low, size );
55        ptr &= ~(CPU_STACK_ALIGNMENT - 1);
56        p->interrupt_stack_high = (void *)ptr;
57      }
58#endif
59
60      p->state = RTEMS_BSP_SMP_CPU_INITIAL_STATE;
61      RTEMS_COMPILER_MEMORY_BARRIER();
62    }
63
64    /*
65     * Discover and initialize the secondary cores in an SMP system.
66     */
67    max_cpus = bsp_smp_initialize( max_cpus );
68
69    _SMP_Processor_count = max_cpus;
70  }
71#else
72  /*
73   * On single core systems, we can efficiently directly access a single
74   * statically allocated per cpu structure.  And the fields are initialized
75   * as individual elements just like it has always been done.
76   */
77  Per_CPU_Control _Per_CPU_Information[1];
78#endif
Note: See TracBrowser for help on using the repository browser.