@@ -28,23 +28,32 @@ extern void z_arm64_fpu_restore(struct z_arm64_fp_context *saved_fp_context);
28
28
29
29
#include <string.h>
30
30
31
- static void DBG ( char * msg , struct k_thread * th )
31
+ static char * dbg_prefix ( char * buf , char * msg , struct k_thread * th )
32
32
{
33
- char buf [80 ], * p ;
34
- unsigned int v ;
35
-
36
33
strcpy (buf , "CPU# exc# " );
37
34
buf [3 ] = '0' + _current_cpu -> id ;
38
35
buf [8 ] = '0' + arch_exception_depth ();
39
36
strcat (buf , _current -> name );
40
37
strcat (buf , ": " );
41
38
strcat (buf , msg );
42
- strcat (buf , " " );
43
- strcat (buf , th -> name );
39
+ if (th != NULL ) {
40
+ strcat (buf , " " );
41
+ strcat (buf , th -> name );
42
+ }
43
+ return buf + strlen (buf );
44
+ }
44
45
46
+ static void DBG (char * msg , struct k_thread * th )
47
+ {
48
+ char buf [80 ], * p ;
49
+ unsigned int v ;
45
50
51
+ p = dbg_prefix (buf , msg , th );
52
+
53
+ if (th == NULL ) {
54
+ th = _current ;
55
+ }
46
56
v = * (unsigned char * )& th -> arch .saved_fp_context ;
47
- p = buf + strlen (buf );
48
57
* p ++ = ' ' ;
49
58
* p ++ = ((v >> 4 ) < 10 ) ? ((v >> 4 ) + '0' ) : ((v >> 4 ) - 10 + 'a' );
50
59
* p ++ = ((v & 15 ) < 10 ) ? ((v & 15 ) + '0' ) : ((v & 15 ) - 10 + 'a' );
@@ -54,9 +63,31 @@ static void DBG(char *msg, struct k_thread *th)
54
63
k_str_out (buf , p - buf );
55
64
}
56
65
66
+ static void DBG_PC (char * msg , uintptr_t pc )
67
+ {
68
+ char buf [80 ], * p ;
69
+ uintptr_t addr = pc ;
70
+ int i ;
71
+
72
+ p = dbg_prefix (buf , msg , NULL );
73
+ strcpy (p , " PC=0x" );
74
+ p += 6 ;
75
+
76
+ /* Format PC address as hex */
77
+ for (i = (sizeof (uintptr_t ) * 2 ) - 1 ; i >= 0 ; i -- ) {
78
+ unsigned int nibble = (addr >> (i * 4 )) & 0xf ;
79
+ * p ++ = (nibble < 10 ) ? (nibble + '0' ) : (nibble - 10 + 'a' );
80
+ }
81
+ * p ++ = '\n' ;
82
+ * p = 0 ;
83
+
84
+ k_str_out (buf , p - buf );
85
+ }
86
+
57
87
#else
58
88
59
89
static inline void DBG (char * msg , struct k_thread * t ) { }
90
+ static inline void DBG_PC (char * msg , uintptr_t pc ) { }
60
91
61
92
#endif /* FPU_DEBUG */
62
93
@@ -199,6 +230,7 @@ static bool simulate_str_q_insn(struct arch_esf *esf)
199
230
200
231
/* did we do something? */
201
232
if (pc != (uint32_t * )esf -> elr ) {
233
+ DBG_PC ("simulated" , esf -> elr );
202
234
/* resume execution past the simulated instructions */
203
235
esf -> elr = (uintptr_t )pc ;
204
236
return true;
@@ -230,6 +262,8 @@ void z_arm64_fpu_trap(struct arch_esf *esf)
230
262
return ;
231
263
}
232
264
265
+ DBG_PC ("trap entry" , esf -> elr );
266
+
233
267
/* turn on FPU access */
234
268
write_cpacr_el1 (read_cpacr_el1 () | CPACR_EL1_FPEN_NOTRAP );
235
269
barrier_isync_fence_full ();
@@ -268,7 +302,7 @@ void z_arm64_fpu_trap(struct arch_esf *esf)
268
302
269
303
/* restore our content */
270
304
z_arm64_fpu_restore (& _current -> arch .saved_fp_context );
271
- DBG ("restore" , _current );
305
+ DBG ("restore" , NULL );
272
306
}
273
307
274
308
/*
0 commit comments