@@ -202,6 +202,39 @@ static inline unsigned int get_bits(int offset, int num_bits, unsigned int val)
202
202
return val & mask ;
203
203
}
204
204
205
+ static void print_fatal_exception (_xtensa_irq_bsa_t * bsa , int cause ,
206
+ bool is_dblexc , uint32_t depc )
207
+ {
208
+ void * pc ;
209
+ uint32_t ps , vaddr ;
210
+
211
+ ps = bsa -> ps ;
212
+ pc = (void * )bsa -> pc ;
213
+
214
+ __asm__ volatile ("rsr.excvaddr %0" : "=r" (vaddr ));
215
+
216
+ LOG_ERR (" ** FATAL EXCEPTION%s" , (is_dblexc ? " (DOUBLE)" : "" ));
217
+ LOG_ERR (" ** CPU %d EXCCAUSE %d (%s)" ,
218
+ arch_curr_cpu ()-> id , cause ,
219
+ z_xtensa_exccause (cause ));
220
+ LOG_ERR (" ** PC %p VADDR %p" , pc , (void * )vaddr );
221
+
222
+ if (is_dblexc ) {
223
+ LOG_ERR (" ** DEPC %p" , (void * )depc );
224
+ }
225
+
226
+ #ifdef CONFIG_USERSPACE
227
+ LOG_ERR (" ** THREADPTR %p" , (void * )bsa -> threadptr );
228
+ #endif /* CONFIG_USERSPACE */
229
+
230
+ LOG_ERR (" ** PS %p" , (void * )bsa -> ps );
231
+ LOG_ERR (" ** (INTLEVEL:%d EXCM: %d UM:%d RING:%d WOE:%d OWB:%d CALLINC:%d)" ,
232
+ get_bits (0 , 4 , ps ), get_bits (4 , 1 , ps ),
233
+ get_bits (5 , 1 , ps ), get_bits (6 , 2 , ps ),
234
+ get_bits (18 , 1 , ps ),
235
+ get_bits (8 , 4 , ps ), get_bits (16 , 2 , ps ));
236
+ }
237
+
205
238
static ALWAYS_INLINE void usage_stop (void )
206
239
{
207
240
#ifdef CONFIG_SCHED_THREAD_USAGE
@@ -296,18 +329,13 @@ static inline DEF_INT_C_HANDLER(1)
296
329
*/
297
330
void * xtensa_excint1_c (int * interrupted_stack )
298
331
{
299
- int cause , vaddr ;
332
+ int cause ;
300
333
_xtensa_irq_bsa_t * bsa = (void * )* (int * * )interrupted_stack ;
301
334
bool is_fatal_error = false;
335
+ bool is_dblexc = false;
302
336
uint32_t ps ;
303
337
void * pc ;
304
-
305
- #ifdef CONFIG_XTENSA_MMU
306
- bool is_dblexc ;
307
- uint32_t depc ;
308
- #else
309
- const bool is_dblexc = false;
310
- #endif /* CONFIG_XTENSA_MMU */
338
+ uint32_t depc = 0 ;
311
339
312
340
__asm__ volatile ("rsr.exccause %0" : "=r" (cause ));
313
341
@@ -359,8 +387,6 @@ void *xtensa_excint1_c(int *interrupted_stack)
359
387
}
360
388
#endif /* CONFIG_USERSPACE */
361
389
362
- __asm__ volatile ("rsr.excvaddr %0" : "=r" (vaddr ));
363
-
364
390
/* Default for exception */
365
391
int reason = K_ERR_CPU_EXCEPTION ;
366
392
is_fatal_error = true;
@@ -380,24 +406,7 @@ void *xtensa_excint1_c(int *interrupted_stack)
380
406
reason = bsa -> a2 ;
381
407
}
382
408
383
- LOG_ERR (" ** FATAL EXCEPTION%s" , (is_dblexc ? " (DOUBLE)" : "" ));
384
- LOG_ERR (" ** CPU %d EXCCAUSE %d (%s)" ,
385
- arch_curr_cpu ()-> id , cause ,
386
- z_xtensa_exccause (cause ));
387
- LOG_ERR (" ** PC %p VADDR %p" ,
388
- pc , (void * )vaddr );
389
- LOG_ERR (" ** PS %p" , (void * )bsa -> ps );
390
- if (is_dblexc ) {
391
- LOG_ERR (" ** DEPC %p" , (void * )depc );
392
- }
393
- #ifdef CONFIG_USERSPACE
394
- LOG_ERR (" ** THREADPTR %p" , (void * )bsa -> threadptr );
395
- #endif /* CONFIG_USERSPACE */
396
- LOG_ERR (" ** (INTLEVEL:%d EXCM: %d UM:%d RING:%d WOE:%d OWB:%d CALLINC:%d)" ,
397
- get_bits (0 , 4 , ps ), get_bits (4 , 1 , ps ),
398
- get_bits (5 , 1 , ps ), get_bits (6 , 2 , ps ),
399
- get_bits (18 , 1 , ps ),
400
- get_bits (8 , 4 , ps ), get_bits (16 , 2 , ps ));
409
+ print_fatal_exception (bsa , cause , is_dblexc , depc );
401
410
402
411
/* FIXME: legacy xtensa port reported "HW" exception
403
412
* for all unhandled exceptions, which seems incorrect
0 commit comments