File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,26 @@ impl Cpsr {
8181 }
8282 Self :: new_with_raw_value ( r)
8383 }
84+
85+ /// Writes the *Current Program Status Register*
86+ ///
87+ /// # Safety
88+ ///
89+ /// Changing the Program Status Register can affect whether interrupts are
90+ /// enabled, whether we are executing Arm or Thumb instructions, or which
91+ /// processor mode are in. You must be absolutely certain that the new CPSR
92+ /// value is valid and appropriate for continued Rust code execution.
93+ ///
94+ /// You almost certainly want to follow this with an [ISB](crate::asm::isb)
95+ /// instruction.
96+ #[ inline]
97+ pub unsafe fn write ( _value : Self ) {
98+ // Safety: We're in an unsafe function
99+ #[ cfg( target_arch = "arm" ) ]
100+ unsafe {
101+ core:: arch:: asm!( "msr CPSR, {}" , in( reg) _value. raw_value( ) ) ;
102+ }
103+ }
84104}
85105
86106impl core:: fmt:: Debug for Cpsr {
You can’t perform that action at this time.
0 commit comments