@@ -164,3 +164,44 @@ pub fn ttat(addr: *mut u32) -> u32 {
164
164
pub unsafe fn bx_ns ( addr : u32 ) {
165
165
call_asm ! ( __bxns( addr: u32 ) ) ;
166
166
}
167
+
168
+ /// Semihosing syscall.
169
+ ///
170
+ /// This method is used by cortex-m-semihosting to provide semihosting syscalls.
171
+ #[ inline]
172
+ pub unsafe fn sh_syscall ( nr : u32 , arg : u32 ) -> u32 {
173
+ call_asm ! ( __sh_syscall( nr: u32 , arg: u32 ) -> u32 )
174
+ }
175
+
176
+ /// Bootstrap.
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`.
181
+ #[ inline]
182
+ pub unsafe fn bootstrap ( msp : * const u32 , rv : * const u32 ) -> ! {
183
+ let msp = msp as u32 ;
184
+ let rv = rv as u32 ;
185
+ call_asm ! ( __bootstrap( msp: u32 , rv: u32 ) ) ;
186
+ core:: hint:: unreachable_unchecked ( ) ;
187
+ }
188
+
189
+ /// Bootload.
190
+ ///
191
+ /// Reads the initial stack pointer value and reset vector from
192
+ /// the provided vector table address, sets the active stack to
193
+ /// the main stack, sets the main stack pointer to the new initial
194
+ /// stack pointer view, then jumps to the reset vector.
195
+ ///
196
+ /// # Safety
197
+ ///
198
+ /// The provided `vector_table` must point to a valid vector
199
+ /// 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.
202
+ #[ inline]
203
+ pub unsafe fn bootload ( vector_table : * const u32 ) -> ! {
204
+ let msp = core:: ptr:: read_volatile ( vector_table) ;
205
+ let rv = core:: ptr:: read_volatile ( vector_table. offset ( 1 ) ) ;
206
+ bootstrap ( msp as * const u32 , rv as * const u32 ) ;
207
+ }
0 commit comments