1 | /* |
---|
2 | * ISR Handler |
---|
3 | * |
---|
4 | * |
---|
5 | * COPYRIGHT (c) 1989-2008. |
---|
6 | * On-Line Applications Research Corporation (OAR). |
---|
7 | * |
---|
8 | * The license and distribution terms for this file may be |
---|
9 | * found in the file LICENSE in this distribution or at |
---|
10 | * http://www.rtems.com/license/LICENSE. |
---|
11 | */ |
---|
12 | |
---|
13 | #if HAVE_CONFIG_H |
---|
14 | #include "config.h" |
---|
15 | #endif |
---|
16 | |
---|
17 | #include <rtems/system.h> |
---|
18 | #include <rtems/score/isr.h> |
---|
19 | #include <rtems/score/stack.h> |
---|
20 | #include <rtems/score/interr.h> |
---|
21 | #include <rtems/score/wkspace.h> |
---|
22 | #include <rtems/config.h> |
---|
23 | |
---|
24 | /* _ISR_Handler_initialization |
---|
25 | * |
---|
26 | * This routine initializes the ISR handler. |
---|
27 | * |
---|
28 | * Input parameters: NONE |
---|
29 | * |
---|
30 | * Output parameters: NONE |
---|
31 | */ |
---|
32 | |
---|
33 | void _ISR_Handler_initialization( void ) |
---|
34 | { |
---|
35 | _ISR_Nest_level = 0; |
---|
36 | |
---|
37 | #if (CPU_SIMPLE_VECTORED_INTERRUPTS == TRUE) |
---|
38 | _ISR_Vector_table = _Workspace_Allocate_or_fatal_error( |
---|
39 | sizeof(ISR_Handler_entry) * ISR_NUMBER_OF_VECTORS |
---|
40 | ); |
---|
41 | #endif |
---|
42 | |
---|
43 | _CPU_Initialize_vectors(); |
---|
44 | |
---|
45 | #if ( CPU_ALLOCATE_INTERRUPT_STACK == TRUE ) |
---|
46 | |
---|
47 | if ( !_Stack_Is_enough(Configuration.interrupt_stack_size) ) |
---|
48 | _Internal_error_Occurred( |
---|
49 | INTERNAL_ERROR_CORE, |
---|
50 | true, |
---|
51 | INTERNAL_ERROR_INTERRUPT_STACK_TOO_SMALL |
---|
52 | ); |
---|
53 | |
---|
54 | _CPU_Interrupt_stack_low = _Workspace_Allocate_or_fatal_error( |
---|
55 | Configuration.interrupt_stack_size |
---|
56 | ); |
---|
57 | |
---|
58 | _CPU_Interrupt_stack_high = _Addresses_Add_offset( |
---|
59 | _CPU_Interrupt_stack_low, |
---|
60 | Configuration.interrupt_stack_size |
---|
61 | ); |
---|
62 | |
---|
63 | #if (CPU_STACK_ALIGNMENT != 0) |
---|
64 | _CPU_Interrupt_stack_high = (void *) |
---|
65 | ((uintptr_t) _CPU_Interrupt_stack_high & ~(CPU_STACK_ALIGNMENT - 1)); |
---|
66 | #endif |
---|
67 | |
---|
68 | /* Interrupt stack might have to be aligned and/or setup |
---|
69 | * in a specific way. |
---|
70 | */ |
---|
71 | #if defined(_CPU_Interrupt_stack_setup) |
---|
72 | _CPU_Interrupt_stack_setup(_CPU_Interrupt_stack_low, _CPU_Interrupt_stack_high); |
---|
73 | #endif |
---|
74 | |
---|
75 | #endif |
---|
76 | |
---|
77 | #if ( CPU_HAS_HARDWARE_INTERRUPT_STACK == TRUE ) |
---|
78 | _CPU_Install_interrupt_stack(); |
---|
79 | #endif |
---|
80 | |
---|
81 | #if defined(RTEMS_SMP) |
---|
82 | _ISR_SMP_Initialize(); |
---|
83 | #endif |
---|
84 | } |
---|