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

4.11
Last change on this file since c26dd0d was c26dd0d, checked in by Jennifer Averett <Jennifer.Averett@…>, on Mar 18, 2011 at 2:12:46 PM

All possible cpus must be initialized prior to determining how many are actually used.

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2011.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 *
9 *  $Id$
10 */
11
12#if HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <rtems/system.h>
17#include <rtems/score/thread.h>
18#include <rtems/score/percpu.h>
19#include <rtems/score/wkspace.h>
20#include <rtems/score/wkspace.h>
21#include <rtems/config.h>
22#include <rtems/bspsmp.h>
23#include <string.h>
24
25#if defined(RTEMS_SMP)
26  void _SMP_Handler_initialize(void)
27  {
28    int         cpu;
29    size_t      size;
30    uintptr_t   ptr;
31
32    /*
33     *  Initialize per CPU structures.
34     */
35    size = (_SMP_Processor_count) * sizeof(Per_CPU_Control);
36    memset( _Per_CPU_Information, '\0', size );
37
38    /*
39     *  Initialize per cpu pointer table
40     */
41    size = Configuration.interrupt_stack_size;
42    _Per_CPU_Information_p[0] = &_Per_CPU_Information[0];
43    for (cpu=1 ; cpu < rtems_smp_maximum_processors; cpu++ ) {
44
45      printk("Initializing cpu control structure %d\n", cpu );
46
47      Per_CPU_Control *p = &_Per_CPU_Information[cpu];
48
49      _Per_CPU_Information_p[cpu] = p;
50
51      p->interrupt_stack_low = _Workspace_Allocate_or_fatal_error( size );
52
53      ptr = (uintptr_t) _Addresses_Add_offset( p->interrupt_stack_low, size );
54      ptr &= ~CPU_STACK_ALIGNMENT;
55      p->interrupt_stack_high = (void *)ptr;
56      p->state = RTEMS_BSP_SMP_CPU_INITIAL_STATE;
57      RTEMS_COMPILER_MEMORY_BARRIER();
58    }
59  }
60#else
61  /*
62   * On single core systems, we can efficiently directly access a single
63   * statically allocated per cpu structure.  And the fields are initialized
64   * as individual elements just like it has always been done.
65   */
66  Per_CPU_Control _Per_CPU_Information[1];
67#endif
Note: See TracBrowser for help on using the repository browser.