1 | /* |
---|
2 | * C4x CPU Dependent Source |
---|
3 | * |
---|
4 | * |
---|
5 | * COPYRIGHT (c) 1989-1999. |
---|
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 | * $Id$ |
---|
13 | */ |
---|
14 | |
---|
15 | #ifdef HAVE_CONFIG_H |
---|
16 | #include "config.h" |
---|
17 | #endif |
---|
18 | |
---|
19 | #include <rtems/system.h> |
---|
20 | #include <rtems/score/cpu.h> |
---|
21 | #include <rtems/score/isr.h> |
---|
22 | #include <rtems/score/thread.h> |
---|
23 | |
---|
24 | /* |
---|
25 | * This routine provides the RTEMS interrupt management. |
---|
26 | */ |
---|
27 | |
---|
28 | #if( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE) |
---|
29 | unsigned long *_old_stack_ptr; |
---|
30 | #endif |
---|
31 | |
---|
32 | register unsigned long *stack_ptr asm("sp"); |
---|
33 | |
---|
34 | void __ISR_Handler(uint32_t vector, void *isr_sp) |
---|
35 | { |
---|
36 | register uint32_t level; |
---|
37 | |
---|
38 | /* already disabled when we get here */ |
---|
39 | /* _CPU_ISR_Disable( level ); */ |
---|
40 | |
---|
41 | _Thread_Dispatch_disable_level++; |
---|
42 | |
---|
43 | #if 0 |
---|
44 | if ( stack_ptr > (_Thread_Executing->Start.stack + |
---|
45 | _Thread_Executing->Start.Initial_stack.size) ) { |
---|
46 | printk( "Blown interrupt stack at 0x%x\n", stack_ptr ); |
---|
47 | } |
---|
48 | #endif |
---|
49 | |
---|
50 | #if( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE) |
---|
51 | if ( _ISR_Nest_level == 0 ) { |
---|
52 | /* Install irq stack */ |
---|
53 | _old_stack_ptr = stack_ptr; |
---|
54 | stack_ptr = _CPU_Interrupt_stack_low; |
---|
55 | } |
---|
56 | #endif |
---|
57 | |
---|
58 | _ISR_Nest_level++; |
---|
59 | |
---|
60 | /* leave it to the ISR to decide if they get reenabled */ |
---|
61 | /* _CPU_ISR_Enable( level ); */ |
---|
62 | |
---|
63 | /* call isp */ |
---|
64 | if ( _ISR_Vector_table[ vector] ) |
---|
65 | (*_ISR_Vector_table[ vector ])( |
---|
66 | vector, isr_sp - sizeof(CPU_Interrupt_frame) + 1 ); |
---|
67 | |
---|
68 | _CPU_ISR_Disable( level ); |
---|
69 | |
---|
70 | _ISR_Nest_level--; |
---|
71 | |
---|
72 | #if( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE) |
---|
73 | if ( _ISR_Nest_level == 0 ) /* restore old stack pointer */ |
---|
74 | stack_ptr = _old_stack_ptr; |
---|
75 | #endif |
---|
76 | |
---|
77 | _Thread_Dispatch_disable_level--; |
---|
78 | |
---|
79 | _CPU_ISR_Enable( level ); |
---|
80 | |
---|
81 | if ( _ISR_Nest_level ) |
---|
82 | return; |
---|
83 | |
---|
84 | if ( _Thread_Dispatch_disable_level ) { |
---|
85 | _ISR_Signals_to_thread_executing = FALSE; |
---|
86 | return; |
---|
87 | } |
---|
88 | |
---|
89 | if ( _Context_Switch_necessary || _ISR_Signals_to_thread_executing ) { |
---|
90 | _ISR_Signals_to_thread_executing = FALSE; |
---|
91 | _Thread_Dispatch(); |
---|
92 | } |
---|
93 | } |
---|