1 | /* |
---|
2 | * Interrupt Manager |
---|
3 | * |
---|
4 | * |
---|
5 | * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. |
---|
6 | * On-Line Applications Research Corporation (OAR). |
---|
7 | * All rights assigned to U.S. Government, 1994. |
---|
8 | * |
---|
9 | * This material may be reproduced by or for the U.S. Government pursuant |
---|
10 | * to the copyright license under the clause at DFARS 252.227-7013. This |
---|
11 | * notice must appear in all copies of this file and its derivatives. |
---|
12 | * |
---|
13 | * $Id$ |
---|
14 | */ |
---|
15 | |
---|
16 | #include <rtems/system.h> |
---|
17 | #include <rtems/isr.h> |
---|
18 | #include <rtems/stack.h> |
---|
19 | #include <rtems/intr.h> |
---|
20 | #include <rtems/wkspace.h> |
---|
21 | |
---|
22 | /* _Interrupt_Manager_initialization |
---|
23 | * |
---|
24 | * This routine initializes the interrupt manager. |
---|
25 | * |
---|
26 | * Input parameters: NONE |
---|
27 | * |
---|
28 | * Output parameters: NONE |
---|
29 | */ |
---|
30 | |
---|
31 | void _Interrupt_Manager_initialization( void ) |
---|
32 | { |
---|
33 | #if ( CPU_ALLOCATE_INTERRUPT_STACK == TRUE ) |
---|
34 | |
---|
35 | if ( _CPU_Table.interrupt_stack_size < RTEMS_MINIMUM_STACK_SIZE ) |
---|
36 | rtems_fatal_error_occurred( RTEMS_INVALID_SIZE ); |
---|
37 | |
---|
38 | _CPU_Interrupt_stack_low = |
---|
39 | _Workspace_Allocate_or_fatal_error( _CPU_Table.interrupt_stack_size ); |
---|
40 | |
---|
41 | _CPU_Interrupt_stack_high = _Addresses_Add_offset( |
---|
42 | _CPU_Interrupt_stack_low, |
---|
43 | _CPU_Table.interrupt_stack_size |
---|
44 | ); |
---|
45 | |
---|
46 | #endif |
---|
47 | |
---|
48 | #if ( CPU_HAS_HARDWARE_INTERRUPT_STACK == TRUE ) |
---|
49 | _CPU_Install_interrupt_stack(); |
---|
50 | #endif |
---|
51 | |
---|
52 | } |
---|
53 | |
---|
54 | /* rtems_interrupt_catch |
---|
55 | * |
---|
56 | * This directive allows a thread to specify what action to take when |
---|
57 | * catching signals. |
---|
58 | * |
---|
59 | * Input parameters: |
---|
60 | * new_isr_handler - address of interrupt service routine (isr) |
---|
61 | * vector - interrupt vector number |
---|
62 | * old_isr_handler - address at which to store previous ISR address |
---|
63 | * |
---|
64 | * Output parameters: |
---|
65 | * RTEMS_SUCCESSFUL - always succeeds |
---|
66 | * *old_isr_handler - previous ISR address |
---|
67 | */ |
---|
68 | |
---|
69 | rtems_status_code rtems_interrupt_catch( |
---|
70 | rtems_isr_entry new_isr_handler, |
---|
71 | rtems_vector_number vector, |
---|
72 | rtems_isr_entry *old_isr_handler |
---|
73 | ) |
---|
74 | { |
---|
75 | if ( !_ISR_Is_vector_number_valid( vector ) ) |
---|
76 | return( RTEMS_INVALID_NUMBER ); |
---|
77 | |
---|
78 | if ( !_ISR_Is_valid_user_handler( new_isr_handler ) ) |
---|
79 | return( RTEMS_INVALID_ADDRESS ); |
---|
80 | |
---|
81 | _ISR_Install_vector( |
---|
82 | vector, (proc_ptr)new_isr_handler, (proc_ptr *)old_isr_handler ); |
---|
83 | |
---|
84 | return( RTEMS_SUCCESSFUL ); |
---|
85 | } |
---|