1 | /* |
---|
2 | * Support for SuperH Simulator in GDB |
---|
3 | */ |
---|
4 | |
---|
5 | /* |
---|
6 | * COPYRIGHT (c) 1989-2008. |
---|
7 | * On-Line Applications Research Corporation (OAR). |
---|
8 | * |
---|
9 | * The license and distribution terms for this file may be |
---|
10 | * found in the file LICENSE in this distribution or at |
---|
11 | * http://www.rtems.org/license/LICENSE. |
---|
12 | */ |
---|
13 | |
---|
14 | #include <rtems/system.h> |
---|
15 | #include <rtems/score/cpu.h> |
---|
16 | #include <rtems/score/isr.h> |
---|
17 | #include <rtems/score/percpu.h> |
---|
18 | #include <rtems/score/threaddispatch.h> |
---|
19 | #include <rtems/score/sh.h> |
---|
20 | |
---|
21 | #if (CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE) |
---|
22 | unsigned long *_old_stack_ptr; |
---|
23 | #endif |
---|
24 | |
---|
25 | register unsigned long *stack_ptr __asm__ ("r15"); |
---|
26 | |
---|
27 | void __ISR_Handler(uint32_t vector); |
---|
28 | |
---|
29 | /* |
---|
30 | * This routine provides the RTEMS interrupt management. |
---|
31 | */ |
---|
32 | void __ISR_Handler( uint32_t vector) |
---|
33 | { |
---|
34 | ISR_Level level; |
---|
35 | |
---|
36 | _ISR_Local_disable( level ); |
---|
37 | |
---|
38 | _Thread_Dispatch_disable(); |
---|
39 | |
---|
40 | #if (CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE) |
---|
41 | if ( _ISR_Nest_level == 0 ) |
---|
42 | { |
---|
43 | /* Install irq stack */ |
---|
44 | _old_stack_ptr = stack_ptr; |
---|
45 | stack_ptr = _CPU_Interrupt_stack_high; |
---|
46 | } |
---|
47 | |
---|
48 | #endif |
---|
49 | |
---|
50 | _ISR_Nest_level++; |
---|
51 | |
---|
52 | _ISR_Local_enable( level ); |
---|
53 | |
---|
54 | /* call isp */ |
---|
55 | if ( _ISR_Vector_table[ vector]) |
---|
56 | (*_ISR_Vector_table[ vector ])( vector ); |
---|
57 | |
---|
58 | _ISR_Local_disable( level ); |
---|
59 | |
---|
60 | _Thread_Dispatch_unnest( _Per_CPU_Get() ); |
---|
61 | |
---|
62 | _ISR_Nest_level--; |
---|
63 | |
---|
64 | #if (CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE) |
---|
65 | |
---|
66 | if ( _ISR_Nest_level == 0 ) |
---|
67 | /* restore old stack pointer */ |
---|
68 | stack_ptr = _old_stack_ptr; |
---|
69 | #endif |
---|
70 | |
---|
71 | _ISR_Local_enable( level ); |
---|
72 | |
---|
73 | if ( _ISR_Nest_level ) |
---|
74 | return; |
---|
75 | |
---|
76 | if ( !_Thread_Dispatch_is_enabled() ) { |
---|
77 | return; |
---|
78 | } |
---|
79 | |
---|
80 | if ( _Thread_Dispatch_necessary ) { |
---|
81 | _Thread_Dispatch(); |
---|
82 | } |
---|
83 | } |
---|