1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Initialize the ISR handler |
---|
5 | * @ingroup ScoreISR |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2012. |
---|
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.org/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include <rtems/score/isr.h> |
---|
22 | #include <rtems/score/address.h> |
---|
23 | #include <rtems/score/interr.h> |
---|
24 | #include <rtems/score/percpu.h> |
---|
25 | #include <rtems/score/stackimpl.h> |
---|
26 | #include <rtems/score/wkspace.h> |
---|
27 | #include <rtems/config.h> |
---|
28 | |
---|
29 | #if (CPU_SIMPLE_VECTORED_INTERRUPTS == TRUE) |
---|
30 | ISR_Handler_entry _ISR_Vector_table[ CPU_INTERRUPT_NUMBER_OF_VECTORS ]; |
---|
31 | #elif defined(CPU_INTERRUPT_NUMBER_OF_VECTORS) |
---|
32 | #error "CPU_INTERRUPT_NUMBER_OF_VECTORS is defined for non-simple vectored interrupts" |
---|
33 | #elif defined(CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER) |
---|
34 | #error "CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER is defined for non-simple vectored interrupts" |
---|
35 | #endif |
---|
36 | |
---|
37 | void _ISR_Handler_initialization( void ) |
---|
38 | { |
---|
39 | _ISR_Nest_level = 0; |
---|
40 | |
---|
41 | #if (CPU_SIMPLE_VECTORED_INTERRUPTS == TRUE) |
---|
42 | _CPU_Initialize_vectors(); |
---|
43 | #endif |
---|
44 | |
---|
45 | #if ( CPU_ALLOCATE_INTERRUPT_STACK == TRUE ) |
---|
46 | { |
---|
47 | size_t stack_size = rtems_configuration_get_interrupt_stack_size(); |
---|
48 | uint32_t cpu_max = rtems_configuration_get_maximum_processors(); |
---|
49 | uint32_t cpu_index; |
---|
50 | |
---|
51 | if ( !_Stack_Is_enough( stack_size ) ) |
---|
52 | _Internal_error( INTERNAL_ERROR_INTERRUPT_STACK_TOO_SMALL ); |
---|
53 | |
---|
54 | for ( cpu_index = 0 ; cpu_index < cpu_max; ++cpu_index ) { |
---|
55 | Per_CPU_Control *cpu = _Per_CPU_Get_by_index( cpu_index ); |
---|
56 | void *low = _Workspace_Allocate_or_fatal_error( stack_size ); |
---|
57 | void *high = _Addresses_Add_offset( low, stack_size ); |
---|
58 | |
---|
59 | #if (CPU_STACK_ALIGNMENT != 0) |
---|
60 | high = _Addresses_Align_down( high, CPU_STACK_ALIGNMENT ); |
---|
61 | #endif |
---|
62 | |
---|
63 | cpu->interrupt_stack_low = low; |
---|
64 | cpu->interrupt_stack_high = high; |
---|
65 | |
---|
66 | /* |
---|
67 | * Interrupt stack might have to be aligned and/or setup in a specific |
---|
68 | * way. Do not use the local low or high variables here since |
---|
69 | * _CPU_Interrupt_stack_setup() is a nasty macro that might want to play |
---|
70 | * with the real memory locations. |
---|
71 | */ |
---|
72 | #if defined(_CPU_Interrupt_stack_setup) |
---|
73 | _CPU_Interrupt_stack_setup( |
---|
74 | cpu->interrupt_stack_low, |
---|
75 | cpu->interrupt_stack_high |
---|
76 | ); |
---|
77 | #endif |
---|
78 | } |
---|
79 | } |
---|
80 | |
---|
81 | #endif |
---|
82 | |
---|
83 | #if ( CPU_HAS_HARDWARE_INTERRUPT_STACK == TRUE ) |
---|
84 | _CPU_Install_interrupt_stack(); |
---|
85 | #endif |
---|
86 | } |
---|