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/config.h> |
---|
21 | #include <string.h> |
---|
22 | |
---|
23 | #if defined(RTEMS_SMP) |
---|
24 | |
---|
25 | #include <rtems/score/smp.h> |
---|
26 | |
---|
27 | void _SMP_Handler_initialize(void) |
---|
28 | { |
---|
29 | int cpu; |
---|
30 | size_t size; |
---|
31 | uintptr_t ptr; |
---|
32 | |
---|
33 | /* |
---|
34 | * Initialize per CPU structures. |
---|
35 | */ |
---|
36 | size = (_SMP_Processor_count) * sizeof(Per_CPU_Control); |
---|
37 | memset( _Per_CPU_Information, '\0', size ); |
---|
38 | |
---|
39 | /* |
---|
40 | * Initialize per cpu pointer table |
---|
41 | */ |
---|
42 | size = Configuration.interrupt_stack_size; |
---|
43 | _Per_CPU_Information_p[0] = &_Per_CPU_Information[0]; |
---|
44 | for (cpu=1 ; cpu < rtems_configuration_smp_maximum_processors; cpu++ ) { |
---|
45 | |
---|
46 | Per_CPU_Control *p = &_Per_CPU_Information[cpu]; |
---|
47 | |
---|
48 | _Per_CPU_Information_p[cpu] = p; |
---|
49 | |
---|
50 | p->interrupt_stack_low = _Workspace_Allocate_or_fatal_error( size ); |
---|
51 | |
---|
52 | ptr = (uintptr_t) _Addresses_Add_offset( p->interrupt_stack_low, size ); |
---|
53 | ptr &= ~CPU_STACK_ALIGNMENT; |
---|
54 | p->interrupt_stack_high = (void *)ptr; |
---|
55 | p->state = RTEMS_BSP_SMP_CPU_INITIAL_STATE; |
---|
56 | RTEMS_COMPILER_MEMORY_BARRIER(); |
---|
57 | } |
---|
58 | } |
---|
59 | #else |
---|
60 | /* |
---|
61 | * On single core systems, we can efficiently directly access a single |
---|
62 | * statically allocated per cpu structure. And the fields are initialized |
---|
63 | * as individual elements just like it has always been done. |
---|
64 | */ |
---|
65 | Per_CPU_Control _Per_CPU_Information[1]; |
---|
66 | #endif |
---|