diff options
Diffstat (limited to 'cortex-m-rt/src')
-rw-r--r-- | cortex-m-rt/src/lang_items.rs | 35 | ||||
-rw-r--r-- | cortex-m-rt/src/lib.rs | 11 |
2 files changed, 9 insertions, 37 deletions
diff --git a/cortex-m-rt/src/lang_items.rs b/cortex-m-rt/src/lang_items.rs index 7b3fa9d..236b2bd 100644 --- a/cortex-m-rt/src/lang_items.rs +++ b/cortex-m-rt/src/lang_items.rs @@ -1,37 +1,12 @@ /// Default panic handler +#[cfg(feature = "abort-on-panic")] #[lang = "panic_fmt"] -#[linkage = "weak"] unsafe extern "C" fn panic_fmt( - _args: ::core::fmt::Arguments, - _file: &'static str, - _line: u32, + _: ::core::fmt::Arguments, + _: &'static str, + _: u32, ) -> ! { - match () { - #[cfg(feature = "panic-over-itm")] - () => { - use cortex_m::itm; - use cortex_m::peripheral::ITM; - - let port = &(*ITM.get()).stim[0]; - iprint!(port, "panicked at '"); - itm::write_fmt(port, _args); - iprintln!(port, "', {}:{}", _file, _line); - } - #[cfg(feature = "panic-over-semihosting")] - () => { - hprint!("panicked at '"); - ::cortex_m_semihosting::io::write_fmt(_args); - hprintln!("', {}:{}", _file, _line); - } - #[cfg(not(any(feature = "panic-over-itm", - feature = "panic-over-semihosting")))] - () => {} - } - - #[cfg(target_arch = "arm")] - asm!("bkpt" :::: "volatile"); - - loop {} + ::core::intrinsics::abort() } /// Lang item required to make the normal `main` work in applications diff --git a/cortex-m-rt/src/lib.rs b/cortex-m-rt/src/lib.rs index fa87e6f..4e10b59 100644 --- a/cortex-m-rt/src/lib.rs +++ b/cortex-m-rt/src/lib.rs @@ -145,6 +145,7 @@ //! 8000404: b084 sub sp, #16 //! ``` +#![cfg_attr(feature = "abort-on-panic", feature(core_intrinsics))] #![deny(missing_docs)] #![deny(warnings)] #![feature(asm)] @@ -154,13 +155,9 @@ #![feature(used)] #![no_std] -#[cfg(any(feature = "panic-over-itm", feature = "exceptions"))] -#[cfg_attr(feature = "panic-over-itm", macro_use)] +#[cfg(feature = "exceptions")] extern crate cortex_m; extern crate compiler_builtins; -#[cfg(feature = "panic-over-semihosting")] -#[macro_use] -extern crate cortex_m_semihosting; extern crate r0; mod lang_items; @@ -189,8 +186,8 @@ extern "C" { /// This is the entry point of all programs #[link_section = ".reset_handler"] unsafe extern "C" fn reset_handler() -> ! { - ::r0::zero_bss(&mut _sbss, &mut _ebss); - ::r0::init_data(&mut _sdata, &mut _edata, &_sidata); + r0::zero_bss(&mut _sbss, &mut _ebss); + r0::init_data(&mut _sdata, &mut _edata, &_sidata); // Neither `argc` or `argv` make sense in bare metal context so we just // stub them |