File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -81,11 +81,27 @@ impl<const N: usize> core::default::Default for Stack<N> {
8181///
8282#[ cfg( cortex_m) ]
8383pub fn switch_to_unprivileged_psp ( mut psp_stack : StackHandle , function : extern "C" fn ( ) -> !) -> ! {
84- unsafe { crate :: asm:: enter_unprivileged_psp ( psp_stack. top ( ) , function) }
84+ // set the stack limit
85+ #[ cfg( armv8m_main) ]
86+ unsafe {
87+ crate :: register:: psplim:: write ( psp_stack. bottom ( ) as u32 ) ;
88+ }
89+ // do the switch
90+ unsafe {
91+ crate :: asm:: enter_unprivileged_psp ( psp_stack. top ( ) , function) ;
92+ }
8593}
8694
8795/// Switch to running on the Process Stack Pointer (PSP), but remain in privileged mode
8896#[ cfg( cortex_m) ]
8997pub fn switch_to_privileged_psp ( mut psp_stack : StackHandle , function : extern "C" fn ( ) -> !) -> ! {
90- unsafe { crate :: asm:: enter_privileged_psp ( psp_stack. top ( ) , function) }
98+ // set the stack limit
99+ #[ cfg( armv8m_main) ]
100+ unsafe {
101+ crate :: register:: psplim:: write ( psp_stack. bottom ( ) as u32 ) ;
102+ }
103+ // do the switch
104+ unsafe {
105+ crate :: asm:: enter_privileged_psp ( psp_stack. top ( ) , function) ;
106+ }
91107}
You can’t perform that action at this time.
0 commit comments