File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -257,6 +257,25 @@ impl ITM {
257257 pub fn configure ( & mut self , settings : ITMSettings ) -> Result < ( ) , ITMConfigurationError > {
258258 use ITMConfigurationError as Error ;
259259
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+
260279 unsafe {
261280 self . tcr . modify ( |mut r| {
262281 r. set_gtsfreq ( match settings. global_timestamps {
@@ -327,6 +346,10 @@ impl ITM {
327346 } ) ;
328347 }
329348
349+ if self . has_software_lock ( ) {
350+ self . lock ( ) ;
351+ }
352+
330353 Ok ( ( ) )
331354 }
332355}
You can’t perform that action at this time.
0 commit comments