@@ -331,11 +331,45 @@ impl SCB {
331
331
cbp. iciallu ( ) ;
332
332
333
333
// Enable I-cache
334
- // NOTE(unsafe): We have synchronised access by &mut self
335
- unsafe { self . ccr . modify ( |r| r | SCB_CCR_IC_MASK ) } ;
334
+ match ( ) {
335
+ #[ cfg( not( feature = "inline-asm" ) ) ]
336
+ ( ) => {
337
+ extern "C" {
338
+ // see asm-v7m.s
339
+ fn __enable_icache ( ) ;
340
+ }
341
+
342
+ // NOTE(unsafe): Having &mut self means no ISR, for example, is
343
+ // going to try to alter this register at the same time. That
344
+ // being said, this is still unsafe if not executed in a
345
+ // critical section (TODO).
346
+ unsafe { __enable_icache ( ) ; }
347
+ }
348
+ #[ cfg( feature = "inline-asm" ) ]
349
+ ( ) => {
350
+ // NOTE(unsafe): Having &mut self means no ISR, for example, is
351
+ // going to try to alter this register at the same time. That
352
+ // being said, this is still unsafe if not executed in a
353
+ // critical section (TODO).
354
+ unsafe {
355
+ let _unused_ccr_val: u32 ;
356
+ llvm_asm ! ( "
357
+ ldr $0, [$1]
358
+ orr.w $0, $0, $2
359
+ str $0, [$1]
360
+ dsb
361
+ isb
362
+ "
363
+ : "=&r" ( _unused_ccr_val)
364
+ : "r" ( & self . ccr) ,
365
+ "c" ( SCB_CCR_IC_MASK )
366
+ : "memory"
367
+ : "volatile"
368
+ ) ;
369
+ }
370
+ }
336
371
337
- crate :: asm:: dsb ( ) ;
338
- crate :: asm:: isb ( ) ;
372
+ }
339
373
}
340
374
341
375
/// Disables I-cache if currently enabled.
@@ -401,10 +435,44 @@ impl SCB {
401
435
402
436
// Now turn on the D-cache
403
437
// NOTE(unsafe): We have synchronised access by &mut self
404
- unsafe { self . ccr . modify ( |r| r | SCB_CCR_DC_MASK ) } ;
405
-
406
- crate :: asm:: dsb ( ) ;
407
- crate :: asm:: isb ( ) ;
438
+ match ( ) {
439
+ #[ cfg( not( feature = "inline-asm" ) ) ]
440
+ ( ) => {
441
+ extern "C" {
442
+ // see asm-v7m.s
443
+ fn __enable_dcache ( ) ;
444
+ }
445
+
446
+ // NOTE(unsafe): Having &mut self means no ISR, for example, is
447
+ // going to try to alter this register at the same time. That
448
+ // being said, this is still unsafe if not executed in a
449
+ // critical section (TODO).
450
+ unsafe { __enable_dcache ( ) ; }
451
+ }
452
+ #[ cfg( feature = "inline-asm" ) ]
453
+ ( ) => {
454
+ // NOTE(unsafe): Having &mut self means no ISR, for example, is
455
+ // going to try to alter this register at the same time. That
456
+ // being said, this is still unsafe if not executed in a
457
+ // critical section (TODO).
458
+ unsafe {
459
+ let _unused_ccr_val: u32 ;
460
+ llvm_asm ! ( "
461
+ ldr $0, [$1]
462
+ orr.w $0, $0, $2
463
+ str $0, [$1]
464
+ dsb
465
+ isb
466
+ "
467
+ : "=&r" ( _unused_ccr_val)
468
+ : "r" ( & self . ccr) ,
469
+ "c" ( SCB_CCR_DC_MASK )
470
+ : "memory"
471
+ : "volatile"
472
+ ) ;
473
+ }
474
+ }
475
+ }
408
476
}
409
477
410
478
/// Disables D-cache if currently enabled.
0 commit comments