File tree 1 file changed +23
-0
lines changed
1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -260,6 +260,25 @@ impl ITM {
260
260
pub fn configure ( & mut self , settings : ITMSettings ) -> Result < ( ) , ITMConfigurationError > {
261
261
use ITMConfigurationError as Error ;
262
262
263
+ // The ITM must be unlocked before we apply any changes.
264
+ if self . has_software_lock ( ) && self . locked ( ) {
265
+ self . unlock ( ) ;
266
+ while self . locked ( ) { }
267
+ }
268
+
269
+ // The ITM must then be disabled before altering certain fields
270
+ // in order to avoid trace stream corruption.
271
+ //
272
+ // NOTE: this is only required before modifying the TraceBusID
273
+ // field, but better be on the safe side for now.
274
+ unsafe {
275
+ self . tcr . modify ( |mut r| {
276
+ r. set_itmena ( false ) ;
277
+ r
278
+ } ) ;
279
+ while self . busy ( ) { }
280
+ }
281
+
263
282
unsafe {
264
283
self . tcr . modify ( |mut r| {
265
284
r. set_gtsfreq ( match settings. global_timestamps {
@@ -330,6 +349,10 @@ impl ITM {
330
349
} ) ;
331
350
}
332
351
352
+ if self . has_software_lock ( ) {
353
+ self . lock ( ) ;
354
+ }
355
+
333
356
Ok ( ( ) )
334
357
}
335
358
}
You can’t perform that action at this time.
0 commit comments