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> {
81
81
///
82
82
#[ cfg( cortex_m) ]
83
83
pub 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
+ }
85
93
}
86
94
87
95
/// Switch to running on the Process Stack Pointer (PSP), but remain in privileged mode
88
96
#[ cfg( cortex_m) ]
89
97
pub 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
+ }
91
107
}
You can’t perform that action at this time.
0 commit comments