diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-03-16 20:05:06 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-03-16 20:05:06 +0000 |
commit | 06dcaf09e6c0eae0b3a3c8d84adb663d03a53a4b (patch) | |
tree | 931cf314d5a87d1d3dcd6e5c366b5ce58270a6aa /cpukit/score/src/percpu.c | |
parent | 2011-03-16 Joel Sherrill <joel.sherrill@oarcorp.com> (diff) | |
download | rtems-06dcaf09e6c0eae0b3a3c8d84adb663d03a53a4b.tar.bz2 |
2011-03-16 Jennifer Averett <jennifer.averett@OARcorp.com>
PR 1729/cpukit
* configure.ac, sapi/include/confdefs.h, sapi/src/exinit.c,
score/Makefile.am, score/preinstall.am,
score/cpu/i386/rtems/score/cpu.h, score/cpu/sparc/cpu_asm.S,
score/cpu/sparc/rtems/score/cpu.h,
score/include/rtems/score/basedefs.h,
score/include/rtems/score/context.h,
score/include/rtems/score/percpu.h, score/src/percpu.c,
score/src/thread.c, score/src/threadcreateidle.c: Add next step in
SMP support. This adds an allocated array of the Per_CPU structures
to support multiple cpus vs a single instance of the structure which
is still used if SMP support is disabled. Configuration support is
also added to explicitly enable or disable SMP. But SMP can only be
enabled for the CPUs which will support it initially -- SPARC and
i386. With the stub BSP support, a BSP can be run as a single core
SMP system from an RTEMS data structure standpoint.
* aclocal/check-smp.m4, aclocal/enable-smp.m4,
score/include/rtems/bspsmp.h, score/include/rtems/score/smplock.h,
score/src/smp.c, score/src/smplock.c: New files.
Diffstat (limited to 'cpukit/score/src/percpu.c')
-rw-r--r-- | cpukit/score/src/percpu.c | 49 |
1 files changed, 42 insertions, 7 deletions
diff --git a/cpukit/score/src/percpu.c b/cpukit/score/src/percpu.c index 4c719af6db..2d429b4db9 100644 --- a/cpukit/score/src/percpu.c +++ b/cpukit/score/src/percpu.c @@ -1,5 +1,5 @@ /* - * COPYRIGHT (c) 1989-2010. + * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -19,11 +19,46 @@ #include <rtems/score/wkspace.h> #include <rtems/score/wkspace.h> #include <rtems/config.h> +#include <rtems/bspsmp.h> #include <string.h> -/* - * On single core systems, we can efficiently directly access a single - * statically allocated per cpu structure. And the fields are initialized - * as individual elements just like it has always been done. - */ -Per_CPU_Control _Per_CPU_Information; +#if defined(RTEMS_SMP) + void _SMP_Handler_initialize(void) + { + int cpu; + size_t size; + uintptr_t ptr; + + /* + * Initialize per CPU structures. + */ + size = (_SMP_Processor_count) * sizeof(Per_CPU_Control); + memset( _Per_CPU_Information, '\0', size ); + + /* + * Initialize per cpu pointer table + */ + size = Configuration.interrupt_stack_size; + _Per_CPU_Information_p[0] = &_Per_CPU_Information[0]; + for (cpu=1 ; cpu < _SMP_Processor_count ; cpu++ ) { + Per_CPU_Control *p = &_Per_CPU_Information[cpu]; + + _Per_CPU_Information_p[cpu] = p; + + p->interrupt_stack_low = _Workspace_Allocate_or_fatal_error( size ); + + ptr = (uintptr_t) _Addresses_Add_offset( p->interrupt_stack_low, size ); + ptr &= ~CPU_STACK_ALIGNMENT; + p->interrupt_stack_high = (void *)ptr; + p->state = RTEMS_BSP_SMP_CPU_INITIAL_STATE; + RTEMS_COMPILER_MEMORY_BARRIER(); + } + } +#else + /* + * On single core systems, we can efficiently directly access a single + * statically allocated per cpu structure. And the fields are initialized + * as individual elements just like it has always been done. + */ + Per_CPU_Control _Per_CPU_Information[1]; +#endif |