File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -79,29 +79,48 @@ impl<const N: usize> core::default::Default for Stack<N> {
7979/// In Unprivileged Mode, code can no longer perform privileged operations,
8080/// such as disabling interrupts.
8181///
82- #[ cfg( cortex_m) ]
83- pub fn switch_to_unprivileged_psp ( mut psp_stack : StackHandle , function : extern "C" fn ( ) -> !) -> ! {
84- // set the stack limit
85- #[ cfg( armv8m_main) ]
86- unsafe {
87- crate :: register:: psplim:: write ( psp_stack. bottom ( ) as u32 ) ;
82+ pub fn switch_to_unprivileged_psp ( psp_stack : StackHandle , function : extern "C" fn ( ) -> !) -> ! {
83+ #[ cfg( cortex_m) ]
84+ {
85+ let mut psp_stack = psp_stack;
86+ // set the stack limit
87+ #[ cfg( armv8m_main) ]
88+ unsafe {
89+ crate :: register:: psplim:: write ( psp_stack. bottom ( ) as u32 ) ;
90+ }
91+ // do the switch
92+ unsafe {
93+ crate :: asm:: enter_unprivileged_psp ( psp_stack. top ( ) , function) ;
94+ }
8895 }
89- // do the switch
90- unsafe {
91- crate :: asm:: enter_unprivileged_psp ( psp_stack. top ( ) , function) ;
96+ #[ cfg( not( cortex_m) ) ]
97+ {
98+ _ = psp_stack;
99+ _ = function;
100+ unimplemented ! ( )
92101 }
93102}
94103
95104/// Switch to running on the Process Stack Pointer (PSP), but remain in privileged mode
96105#[ cfg( cortex_m) ]
97- pub fn switch_to_privileged_psp ( mut psp_stack : StackHandle , function : extern "C" fn ( ) -> !) -> ! {
98- // set the stack limit
99- #[ cfg( armv8m_main) ]
100- unsafe {
101- crate :: register:: psplim:: write ( psp_stack. bottom ( ) as u32 ) ;
106+ pub fn switch_to_privileged_psp ( psp_stack : StackHandle , function : extern "C" fn ( ) -> !) -> ! {
107+ #[ cfg( cortex_m) ]
108+ {
109+ let mut psp_stack = psp_stack;
110+ // set the stack limit
111+ #[ cfg( armv8m_main) ]
112+ unsafe {
113+ crate :: register:: psplim:: write ( psp_stack. bottom ( ) as u32 ) ;
114+ }
115+ // do the switch
116+ unsafe {
117+ crate :: asm:: enter_privileged_psp ( psp_stack. top ( ) , function) ;
118+ }
102119 }
103- // do the switch
104- unsafe {
105- crate :: asm:: enter_privileged_psp ( psp_stack. top ( ) , function) ;
120+ #[ cfg( not( cortex_m) ) ]
121+ {
122+ _ = psp_stack;
123+ _ = function;
124+ unimplemented ! ( )
106125 }
107126}
You can’t perform that action at this time.
0 commit comments