@@ -165,7 +165,7 @@ pub unsafe fn bx_ns(addr: u32) {
165
165
call_asm ! ( __bxns( addr: u32 ) ) ;
166
166
}
167
167
168
- /// Semihosing syscall.
168
+ /// Semihosting syscall.
169
169
///
170
170
/// This method is used by cortex-m-semihosting to provide semihosting syscalls.
171
171
#[ inline]
@@ -175,30 +175,34 @@ pub unsafe fn sh_syscall(nr: u32, arg: u32) -> u32 {
175
175
176
176
/// Bootstrap.
177
177
///
178
- /// Sets the active stack to the main stack, updates the main stack pointer to `msp`,
179
- /// then jumps execution to the address in `rv`.
180
- /// Writes `msp` to the MSP special register, then jumps to the address in `rv`.
178
+ /// Clears CONTROL.SPSEL (setting the main stack to be the active stack),
179
+ /// updates the main stack pointer to the address in `msp`, then jumps
180
+ /// to the address in `rv`.
181
+ ///
182
+ /// # Safety
183
+ ///
184
+ /// `msp` and `rv` must point to valid stack memory and executable code,
185
+ /// respectively.
181
186
#[ inline]
182
187
pub unsafe fn bootstrap ( msp : * const u32 , rv : * const u32 ) -> ! {
188
+ // Ensure thumb mode is set.
189
+ let rv = ( rv as u32 ) | 1 ;
183
190
let msp = msp as u32 ;
184
- let rv = rv as u32 ;
185
- call_asm ! ( __bootstrap( msp: u32 , rv: u32 ) ) ;
186
- core:: hint:: unreachable_unchecked ( ) ;
191
+ call_asm ! ( __bootstrap( msp: u32 , rv: u32 ) -> !) ;
187
192
}
188
193
189
194
/// Bootload.
190
195
///
191
196
/// Reads the initial stack pointer value and reset vector from
192
197
/// the provided vector table address, sets the active stack to
193
198
/// the main stack, sets the main stack pointer to the new initial
194
- /// stack pointer view , then jumps to the reset vector.
199
+ /// stack pointer, then jumps to the reset vector.
195
200
///
196
201
/// # Safety
197
202
///
198
203
/// The provided `vector_table` must point to a valid vector
199
204
/// table, with a valid stack pointer as the first word and
200
- /// a valid reset vector (in thumb mode, with the least significant
201
- /// bit cleared) as the second word.
205
+ /// a valid reset vector as the second word.
202
206
#[ inline]
203
207
pub unsafe fn bootload ( vector_table : * const u32 ) -> ! {
204
208
let msp = core:: ptr:: read_volatile ( vector_table) ;
0 commit comments