aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cortex-m-rt/build.rs15
-rw-r--r--cortex-m-rt/src/lib.rs14
2 files changed, 25 insertions, 4 deletions
diff --git a/cortex-m-rt/build.rs b/cortex-m-rt/build.rs
index 6494c13..1d0160c 100644
--- a/cortex-m-rt/build.rs
+++ b/cortex-m-rt/build.rs
@@ -4,7 +4,10 @@ use std::io::Write;
use std::path::PathBuf;
fn main() {
- has_fpu();
+ let target = env::var("TARGET").unwrap();
+
+ has_fpu(&target);
+ is_armv6m(&target);
// Put the linker script somewhere the linker can find it
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
@@ -18,10 +21,14 @@ fn main() {
println!("cargo:rerun-if-changed=link.x");
}
-fn has_fpu() {
- let target = env::var("TARGET").unwrap();
-
+fn has_fpu(target: &str) {
if target.ends_with("eabihf") {
println!("cargo:rustc-cfg=has_fpu");
}
}
+
+fn is_armv6m(target: &str) {
+ if target.starts_with("thumbv6m-") {
+ println!("cargo:rustc-cfg=armv6m");
+ }
+}
diff --git a/cortex-m-rt/src/lib.rs b/cortex-m-rt/src/lib.rs
index 82dd9eb..df6640f 100644
--- a/cortex-m-rt/src/lib.rs
+++ b/cortex-m-rt/src/lib.rs
@@ -400,6 +400,12 @@ PENDSV = DEFAULT_HANDLER
SYS_TICK = DEFAULT_HANDLER
"#);
+#[cfg(not(armv6m))]
+global_asm!(r#"
+.weak DEBUG_MONITOR
+DEBUG_MONITOR = DEFAULT_HANDLER
+"#);
+
#[cfg(target_arch = "arm")]
extern "C" {
fn NMI();
@@ -408,6 +414,8 @@ extern "C" {
fn BUS_FAULT();
fn USAGE_FAULT();
fn SVCALL();
+ #[cfg(not(armv6m))]
+ fn DEBUG_MONITOR();
fn PENDSV();
fn SYS_TICK();
}
@@ -429,7 +437,10 @@ pub static EXCEPTIONS: [Option<unsafe extern "C" fn()>; 14] = [
None,
None,
Some(SVCALL),
+ #[cfg(armv6m)]
None,
+ #[cfg(not(armv6m))]
+ Some(DEBUG_MONITOR),
None,
Some(PENDSV),
Some(SYS_TICK),
@@ -520,6 +531,9 @@ pub enum Exception {
USAGE_FAULT,
/// System service call via SWI instruction
SVCALL,
+ /// Debug monitor
+ #[cfg(not(armv6m))]
+ DEBUG_MONITOR,
/// Pendable request for system service
PENDSV,
/// System tick timer