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 @@ -257,6 +257,25 @@ impl ITM {
257
257
pub fn configure ( & mut self , settings : ITMSettings ) -> Result < ( ) , ITMConfigurationError > {
258
258
use ITMConfigurationError as Error ;
259
259
260
+ // The ITM must be unlocked before we apply any changes.
261
+ if self . has_software_lock ( ) && self . locked ( ) {
262
+ self . unlock ( ) ;
263
+ while self . locked ( ) { }
264
+ }
265
+
266
+ // The ITM must then be disabled before altering certain fields
267
+ // in order to avoid trace stream corruption.
268
+ //
269
+ // NOTE: this is only required before modifying the TraceBusID
270
+ // field, but better be on the safe side for now.
271
+ unsafe {
272
+ self . tcr . modify ( |mut r| {
273
+ r. set_itmena ( false ) ;
274
+ r
275
+ } ) ;
276
+ while self . busy ( ) { }
277
+ }
278
+
260
279
unsafe {
261
280
self . tcr . modify ( |mut r| {
262
281
r. set_gtsfreq ( match settings. global_timestamps {
@@ -327,6 +346,10 @@ impl ITM {
327
346
} ) ;
328
347
}
329
348
349
+ if self . has_software_lock ( ) {
350
+ self . lock ( ) ;
351
+ }
352
+
330
353
Ok ( ( ) )
331
354
}
332
355
}
You can’t perform that action at this time.
0 commit comments