1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief RTEMS Interrupt Catch |
---|
5 | * @ingroup ClassicINTR |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-1999. |
---|
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/system.h> |
---|
22 | #include <rtems/rtems/status.h> |
---|
23 | #include <rtems/score/isr.h> |
---|
24 | #include <rtems/rtems/intr.h> |
---|
25 | |
---|
26 | #if (CPU_SIMPLE_VECTORED_INTERRUPTS == TRUE) |
---|
27 | |
---|
28 | /** |
---|
29 | * This function returns true if the vector is a valid vector number |
---|
30 | * for this processor and false otherwise. |
---|
31 | */ |
---|
32 | |
---|
33 | RTEMS_INLINE_ROUTINE bool _ISR_Is_vector_number_valid ( |
---|
34 | uint32_t vector |
---|
35 | ) |
---|
36 | { |
---|
37 | return ( vector <= CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER ); |
---|
38 | } |
---|
39 | |
---|
40 | /** |
---|
41 | * This function returns true if handler is the entry point of a valid |
---|
42 | * use interrupt service routine and false otherwise. |
---|
43 | */ |
---|
44 | |
---|
45 | RTEMS_INLINE_ROUTINE bool _ISR_Is_valid_user_handler ( |
---|
46 | void *handler |
---|
47 | ) |
---|
48 | { |
---|
49 | return (handler != NULL); |
---|
50 | } |
---|
51 | |
---|
52 | rtems_status_code rtems_interrupt_catch( |
---|
53 | rtems_isr_entry new_isr_handler, |
---|
54 | rtems_vector_number vector, |
---|
55 | rtems_isr_entry *old_isr_handler |
---|
56 | ) |
---|
57 | { |
---|
58 | if ( !_ISR_Is_vector_number_valid( vector ) ) |
---|
59 | return RTEMS_INVALID_NUMBER; |
---|
60 | |
---|
61 | if ( !_ISR_Is_valid_user_handler( (void *) new_isr_handler ) ) |
---|
62 | return RTEMS_INVALID_ADDRESS; |
---|
63 | |
---|
64 | if ( !_ISR_Is_valid_user_handler( (void *) old_isr_handler ) ) |
---|
65 | return RTEMS_INVALID_ADDRESS; |
---|
66 | |
---|
67 | _ISR_Install_vector( |
---|
68 | vector, (proc_ptr)new_isr_handler, (proc_ptr *)old_isr_handler ); |
---|
69 | |
---|
70 | return RTEMS_SUCCESSFUL; |
---|
71 | } |
---|
72 | #endif |
---|