57
57
58
58
use core:: marker:: PhantomData ;
59
59
use core:: ops;
60
+ use core:: ptr:: NonNull ;
60
61
61
62
use crate :: interrupt;
62
63
@@ -408,12 +409,12 @@ unsafe impl Send for ICB {}
408
409
409
410
impl ICB {
410
411
/// Pointer to the register block
411
- pub const PTR : * mut icb:: RegisterBlock = 0xE000_E004 as * mut _ ;
412
+ pub const PTR : NonNull < icb:: RegisterBlock > = unsafe { NonNull :: new_unchecked ( 0xE000_E004 as * mut _ ) } ;
412
413
413
414
/// Returns a pointer to the register block (to be deprecated in 0.7)
414
415
#[ inline( always) ]
415
416
pub const fn ptr ( ) -> * mut icb:: RegisterBlock {
416
- Self :: PTR
417
+ Self :: PTR . as_ptr ( )
417
418
}
418
419
}
419
420
@@ -422,14 +423,14 @@ impl ops::Deref for ICB {
422
423
423
424
#[ inline( always) ]
424
425
fn deref ( & self ) -> & Self :: Target {
425
- unsafe { & * Self :: PTR }
426
+ unsafe { Self :: PTR . as_ref ( ) }
426
427
}
427
428
}
428
429
429
430
impl ops:: DerefMut for ICB {
430
431
#[ inline( always) ]
431
432
fn deref_mut ( & mut self ) -> & mut Self :: Target {
432
- unsafe { & mut * Self :: PTR }
433
+ unsafe { & mut * Self :: ptr ( ) }
433
434
}
434
435
}
435
436
@@ -443,12 +444,12 @@ unsafe impl Send for ITM {}
443
444
#[ cfg( all( not( armv6m) , not( armv8m_base) ) ) ]
444
445
impl ITM {
445
446
/// Pointer to the register block
446
- pub const PTR : * mut itm:: RegisterBlock = 0xE000_0000 as * mut _ ;
447
+ pub const PTR : NonNull < itm:: RegisterBlock > = unsafe { NonNull :: new_unchecked ( 0xE000_0000 as * mut _ ) } ;
447
448
448
449
/// Returns a pointer to the register block (to be deprecated in 0.7)
449
450
#[ inline( always) ]
450
451
pub const fn ptr ( ) -> * mut itm:: RegisterBlock {
451
- Self :: PTR
452
+ Self :: PTR . as_ptr ( )
452
453
}
453
454
}
454
455
@@ -458,15 +459,15 @@ impl ops::Deref for ITM {
458
459
459
460
#[ inline( always) ]
460
461
fn deref ( & self ) -> & Self :: Target {
461
- unsafe { & * Self :: PTR }
462
+ unsafe { Self :: PTR . as_ref ( ) }
462
463
}
463
464
}
464
465
465
466
#[ cfg( all( not( armv6m) , not( armv8m_base) ) ) ]
466
467
impl ops:: DerefMut for ITM {
467
468
#[ inline( always) ]
468
469
fn deref_mut ( & mut self ) -> & mut Self :: Target {
469
- unsafe { & mut * Self :: PTR }
470
+ unsafe { & mut * Self :: ptr ( ) }
470
471
}
471
472
}
472
473
0 commit comments