@@ -949,13 +949,23 @@ impl SCB {
949
949
#[ cfg( not( armv6m) ) ]
950
950
{
951
951
// NOTE(unsafe) atomic read with no side effects
952
- unsafe { ( * Self :: ptr ( ) ) . shpr [ usize:: from ( index - 4 ) ] . read ( ) }
952
+
953
+ // NOTE(unsafe): Index is bounded to [4,15] by SystemHandler design.
954
+ // TODO: Review it after rust-lang/rust/issues/13926 will be fixed.
955
+ let priority_ref = unsafe { ( * Self :: ptr ( ) ) . shpr . get_unchecked ( usize:: from ( index - 4 ) ) } ;
956
+
957
+ priority_ref. read ( )
953
958
}
954
959
955
960
#[ cfg( armv6m) ]
956
961
{
957
962
// NOTE(unsafe) atomic read with no side effects
958
- let shpr = unsafe { ( * Self :: ptr ( ) ) . shpr [ usize:: from ( ( index - 8 ) / 4 ) ] . read ( ) } ;
963
+
964
+ // NOTE(unsafe): Index is bounded to [11,15] by SystemHandler design.
965
+ // TODO: Review it after rust-lang/rust/issues/13926 will be fixed.
966
+ let priority_ref = unsafe { ( * Self :: ptr ( ) ) . shpr . get_unchecked ( usize:: from ( ( index - 8 ) / 4 ) ) } ;
967
+
968
+ let shpr = priority_ref. read ( ) ;
959
969
let prio = ( shpr >> ( 8 * ( index % 4 ) ) ) & 0x0000_00ff ;
960
970
prio as u8
961
971
}
@@ -979,12 +989,20 @@ impl SCB {
979
989
980
990
#[ cfg( not( armv6m) ) ]
981
991
{
982
- self . shpr [ usize:: from ( index - 4 ) ] . write ( prio)
992
+ // NOTE(unsafe): Index is bounded to [4,15] by SystemHandler design.
993
+ // TODO: Review it after rust-lang/rust/issues/13926 will be fixed.
994
+ let priority_ref = ( * Self :: ptr ( ) ) . shpr . get_unchecked ( usize:: from ( index - 4 ) ) ;
995
+
996
+ priority_ref. write ( prio)
983
997
}
984
998
985
999
#[ cfg( armv6m) ]
986
1000
{
987
- self . shpr [ usize:: from ( ( index - 8 ) / 4 ) ] . modify ( |value| {
1001
+ // NOTE(unsafe): Index is bounded to [11,15] by SystemHandler design.
1002
+ // TODO: Review it after rust-lang/rust/issues/13926 will be fixed.
1003
+ let priority_ref = ( * Self :: ptr ( ) ) . shpr . get_unchecked ( usize:: from ( ( index - 8 ) / 4 ) ) ;
1004
+
1005
+ priority_ref. modify ( |value| {
988
1006
let shift = 8 * ( index % 4 ) ;
989
1007
let mask = 0x0000_00ff << shift;
990
1008
let prio = u32:: from ( prio) << shift;
0 commit comments