@@ -15,43 +15,85 @@ extern uint32_t _irq_vector_table[];
15
15
#define HAS_DIRECT_IRQS
16
16
#endif
17
17
18
+ #define ISR1_OFFSET 0
19
+ #define ISR2_OFFSET 1
20
+ #define ISR3_OFFSET 2
21
+ #define ISR4_OFFSET 3
22
+
23
+ #define IRQ_LINE (offset ) (CONFIG_NUM_IRQS - ((offset) + 1))
24
+ #define TABLE_INDEX (offset ) (IRQ_TABLE_SIZE - ((offset) + 1))
25
+
26
+ #define ISR3_ARG 0xb01dface
27
+ #define ISR4_ARG 0xca55e77e
28
+ static volatile int trigger_check [4 ];
29
+
30
+ #if defined(CONFIG_ARM )
31
+ #include <arch/arm/cortex_m/cmsis.h>
32
+
33
+ void trigger_irq (int irq )
34
+ {
35
+ #if defined(CONFIG_SOC_TI_LM3S6965_QEMU )
36
+ /* QEMU does not simulate the STIR register: this is a workaround */
37
+ NVIC_SetPendingIRQ (irq );
38
+ #else
39
+ NVIC -> STIR = irq ;
40
+ #endif
41
+ }
42
+ #else
43
+ /* So far, Nios II and Risc V do not support this */
44
+ #define NO_TRIGGER_FROM_SW
45
+ #endif
46
+
18
47
#ifdef HAS_DIRECT_IRQS
19
48
ISR_DIRECT_DECLARE (isr1 )
20
49
{
21
- printk ("isr1\n" );
50
+ printk ("isr1 ran\n" );
51
+ trigger_check [ISR1_OFFSET ]++ ;
22
52
return 0 ;
23
53
}
24
54
25
55
ISR_DIRECT_DECLARE (isr2 )
26
56
{
27
- printk ("isr2\n" );
57
+ printk ("isr2 ran\n" );
58
+ trigger_check [ISR2_OFFSET ]++ ;
28
59
return 1 ;
29
60
}
30
61
#endif
31
62
32
63
void isr3 (void * param )
33
64
{
34
- printk ("isr3 %p\n" , param );
65
+ printk ("isr3 ran with parameter %p\n" , param );
66
+ trigger_check [ISR3_OFFSET ]++ ;
35
67
}
36
68
37
69
38
70
void isr4 (void * param )
39
71
{
40
- printk ("isr4 %p\n" , param );
72
+ printk ("isr4 ran with parameter %p\n" , param );
73
+ trigger_check [ISR4_OFFSET ]++ ;
41
74
}
42
75
43
- #define ISR1_OFFSET 0
44
- #define ISR2_OFFSET 1
45
- #define ISR3_OFFSET 2
46
- #define ISR4_OFFSET 3
76
+ int test_irq (int offset )
77
+ {
78
+ #ifndef NO_TRIGGER_FROM_SW
79
+ TC_PRINT ("triggering irq %d\n" , IRQ_LINE (offset ));
80
+ trigger_irq (IRQ_LINE (offset ));
81
+ if (trigger_check [offset ] != 1 ) {
82
+ TC_PRINT ("interrupt %d didn't run once, ran %d times\n" ,
83
+ IRQ_LINE (offset ),
84
+ trigger_check [offset ]);
85
+ return -1 ;
86
+ }
87
+ #else
88
+ /* This arch doesn't support triggering interrupts from software */
89
+ ARG_UNUSED (offset );
90
+ #endif
91
+ return 0 ;
92
+ }
47
93
48
- #define IRQ_LINE (offset ) (CONFIG_NUM_IRQS - ((offset) + 1))
49
- #define TABLE_INDEX (offset ) (IRQ_TABLE_SIZE - ((offset) + 1))
50
94
51
- #define ISR3_ARG 0xb01dface
52
- #define ISR4_ARG 0xca55e77e
53
95
54
- #ifdef CONFIG_GEN_IRQ_VECTOR_TABLE
96
+ #ifdef HAS_DIRECT_IRQS
55
97
static int check_vector (void * isr , int offset )
56
98
{
57
99
TC_PRINT ("Checking _irq_vector_table entry %d for irq %d\n" ,
@@ -61,6 +103,11 @@ static int check_vector(void *isr, int offset)
61
103
TC_PRINT ("bad entry %d in vector table\n" , TABLE_INDEX (offset ));
62
104
return -1 ;
63
105
}
106
+
107
+ if (test_irq (offset )) {
108
+ return -1 ;
109
+ }
110
+
64
111
return 0 ;
65
112
}
66
113
#endif
@@ -94,6 +141,9 @@ static int check_sw_isr(void *isr, uint32_t arg, int offset)
94
141
}
95
142
#endif
96
143
144
+ if (test_irq (offset )) {
145
+ return -1 ;
146
+ }
97
147
return 0 ;
98
148
}
99
149
#endif
@@ -109,6 +159,8 @@ void main(void)
109
159
#ifdef HAS_DIRECT_IRQS
110
160
IRQ_DIRECT_CONNECT (IRQ_LINE (ISR1_OFFSET ), 0 , isr1 , 0 );
111
161
IRQ_DIRECT_CONNECT (IRQ_LINE (ISR2_OFFSET ), 0 , isr2 , 0 );
162
+ irq_enable (IRQ_LINE (ISR1_OFFSET ));
163
+ irq_enable (IRQ_LINE (ISR2_OFFSET ));
112
164
TC_PRINT ("isr1 isr=%p irq=%d\n" , isr1 , IRQ_LINE (ISR1_OFFSET ));
113
165
TC_PRINT ("isr2 isr=%p irq=%d\n" , isr2 , IRQ_LINE (ISR2_OFFSET ));
114
166
@@ -126,6 +178,8 @@ void main(void)
126
178
#ifdef CONFIG_GEN_SW_ISR_TABLE
127
179
IRQ_CONNECT (IRQ_LINE (ISR3_OFFSET ), 1 , isr3 , ISR3_ARG , 0 );
128
180
IRQ_CONNECT (IRQ_LINE (ISR4_OFFSET ), 2 , isr4 , ISR4_ARG , 0 );
181
+ irq_enable (IRQ_LINE (ISR3_OFFSET ));
182
+ irq_enable (IRQ_LINE (ISR4_OFFSET ));
129
183
TC_PRINT ("isr3 isr=%p irq=%d param=%p\n" , isr3 , IRQ_LINE (ISR3_OFFSET ),
130
184
(void * )ISR3_ARG );
131
185
TC_PRINT ("isr4 isr=%p irq=%d param=%p\n" , isr4 , IRQ_LINE (ISR4_OFFSET ),
0 commit comments