aboutsummaryrefslogtreecommitdiff
path: root/cortex-m-rt/src
diff options
context:
space:
mode:
authorGravatar Jonas Schievink <jonasschievink@gmail.com> 2020-08-30 00:29:59 +0200
committerGravatar Jonas Schievink <jonasschievink@gmail.com> 2020-08-30 00:44:29 +0200
commite9eae4ded99c6f1f3a62bf379664e1503798c11f (patch)
treec7e4826e89a1f82a01b7ffc965c15c485838e8dd /cortex-m-rt/src
parentb9afdecc8fff3d2fe2d1a8c2695cc92cfebb3bb9 (diff)
downloadcortex-m-e9eae4ded99c6f1f3a62bf379664e1503798c11f.tar.gz
cortex-m-e9eae4ded99c6f1f3a62bf379664e1503798c11f.tar.zst
cortex-m-e9eae4ded99c6f1f3a62bf379664e1503798c11f.zip
Avoid depending on `cortex-m`
Diffstat (limited to 'cortex-m-rt/src')
-rw-r--r--cortex-m-rt/src/lib.rs36
1 files changed, 10 insertions, 26 deletions
diff --git a/cortex-m-rt/src/lib.rs b/cortex-m-rt/src/lib.rs
index 524b161..e2dd667 100644
--- a/cortex-m-rt/src/lib.rs
+++ b/cortex-m-rt/src/lib.rs
@@ -937,9 +937,6 @@ pub unsafe extern "C" fn Reset() -> ! {
static mut __sdata: u32;
static mut __edata: u32;
static __sidata: u32;
-
- // This symbol will be provided by the user via `#[entry]`
- fn main() -> !;
}
extern "Rust" {
@@ -956,33 +953,20 @@ pub unsafe extern "C" fn Reset() -> ! {
#[allow(clippy::match_single_binding)]
match () {
#[cfg(not(has_fpu))]
- () => main(),
+ () => {
+ extern "C" {
+ // This symbol will be provided by the user via `#[entry]`
+ fn main() -> !;
+ }
+ main()
+ }
#[cfg(has_fpu)]
() => {
- const SCB_CPACR: *mut u32 = 0xE000_ED88 as *mut u32;
- const SCB_CPACR_FPU_ENABLE: u32 = 0b01_01 << 20;
- const SCB_CPACR_FPU_USER: u32 = 0b10_10 << 20;
-
- // enable the FPU
- core::ptr::write_volatile(
- SCB_CPACR,
- *SCB_CPACR | SCB_CPACR_FPU_ENABLE | SCB_CPACR_FPU_USER,
- );
-
- cortex_m::asm::dsb();
- cortex_m::asm::isb();
-
- // this is used to prevent the compiler from inlining the user `main` into the reset
- // handler. Inlining can cause the FPU instructions in the user `main` to be executed
- // before enabling the FPU, and that would produce a hard to diagnose hard fault at
- // runtime.
- #[inline(never)]
- #[export_name = "ResetTrampoline"]
- fn trampoline() -> ! {
- unsafe { main() }
+ extern "C" {
+ fn FpuTrampoline() -> !;
}
- trampoline()
+ FpuTrampoline()
}
}
}