aboutsummaryrefslogtreecommitdiff
path: root/asm/inline.rs
diff options
context:
space:
mode:
authorGravatar Adam Greig <adam@adamgreig.com> 2020-12-02 01:17:53 +0000
committerGravatar Adam Greig <adam@adamgreig.com> 2020-12-02 01:17:53 +0000
commit4a1c82fe37e05223951595648a74792cdc3c2179 (patch)
tree50e8e4faeeeaa462a360bfa074f94b1e4b4851d8 /asm/inline.rs
parent5910cbeac5882670e6a1fd906e21ebcbcced2f83 (diff)
downloadcortex-m-4a1c82fe37e05223951595648a74792cdc3c2179.tar.gz
cortex-m-4a1c82fe37e05223951595648a74792cdc3c2179.tar.zst
cortex-m-4a1c82fe37e05223951595648a74792cdc3c2179.zip
Expose __syscall and add new bootstrap method
Diffstat (limited to 'asm/inline.rs')
-rw-r--r--asm/inline.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/asm/inline.rs b/asm/inline.rs
index f6a3ebb..bba5e6e 100644
--- a/asm/inline.rs
+++ b/asm/inline.rs
@@ -177,11 +177,25 @@ pub unsafe fn __wfi() {
/// Semihosting syscall.
#[inline(always)]
-pub unsafe fn __syscall(mut nr: u32, arg: u32) -> u32 {
+pub unsafe fn __sh_syscall(mut nr: u32, arg: u32) -> u32 {
asm!("bkpt #0xab", inout("r0") nr, in("r1") arg);
nr
}
+/// Bootstrap: ensure we are using the main stack, then write `msp` to MSP and jump to `rv`.
+#[inline(always)]
+pub unsafe fn __bootstrap(msp: u32, rv: u32) {
+ asm!(
+ "msr CONTROL, {}",
+ "isb",
+ "msr MSP, {}",
+ "bx {}",
+ in(reg) 0,
+ in(reg) msp,
+ in(reg) rv,
+ );
+}
+
// v7m *AND* v8m.main, but *NOT* v8m.base
#[cfg(any(armv7m, armv8m_main))]
pub use self::v7m::*;