aboutsummaryrefslogtreecommitdiff
path: root/src/exception.rs
diff options
context:
space:
mode:
authorGravatar bors[bot] <bors[bot]@users.noreply.github.com> 2018-05-11 17:58:13 +0000
committerGravatar bors[bot] <bors[bot]@users.noreply.github.com> 2018-05-11 17:58:13 +0000
commite3217ad94d6c941796c2d7ee8735e7b250a69387 (patch)
tree6488e7d0ad3910d30077f3fdd7eee553b1839f27 /src/exception.rs
parent00d6faae149c062e79a822b8d46b6b5e7e972f57 (diff)
parent05bbc3b815703a0654d2e37966547e392f856161 (diff)
downloadcortex-m-e3217ad94d6c941796c2d7ee8735e7b250a69387.tar.gz
cortex-m-e3217ad94d6c941796c2d7ee8735e7b250a69387.tar.zst
cortex-m-e3217ad94d6c941796c2d7ee8735e7b250a69387.zip
Merge #88
88: make compilable on stable r=japaric a=japaric This PR makes this crate compilable on stable when the "inline-asm" and "singleton" Cargo features are disabled (they are enabled by default to maintain backwards compatibility). The main change has been replacing almost (\*) all inline `asm!` invocations with FFI calls into external assembly files. (\*) Stuff that has not been converted into external assembly file and thus is not available on stable: - Reading the (A)PSR register (I'm not sure if this will work with the extra function call overhead) - Reading and writing the Link Register (LR) - Reading and writing the Program Counter (PC) I would appreciate if someone checked that all the stuff that's now using FFI calls has the same semantics as the inline `asm!` version. Co-authored-by: Jorge Aparicio <jorge@japaric.io>
Diffstat (limited to 'src/exception.rs')
-rw-r--r--src/exception.rs72
1 files changed, 0 insertions, 72 deletions
diff --git a/src/exception.rs b/src/exception.rs
deleted file mode 100644
index b40cf1b..0000000
--- a/src/exception.rs
+++ /dev/null
@@ -1,72 +0,0 @@
-//! Exceptions
-
-/// Enumeration of all the exception types
-#[derive(Clone, Copy, Debug, Eq, PartialEq)]
-pub enum Exception {
- /// Non-maskable interrupt
- NMI,
- /// Other type of faults and unhandled faults
- HardFault,
- /// Memory protection related fault
- MenManage,
- /// Pre-fetch or memory access fault
- BusFault,
- /// Fault due to undefined instruction or illegal state
- UsageFault,
- /// Supervisor call
- SVCall,
- /// Pendable request for system-level service
- PendSV,
- /// System timer exception
- SysTick,
- /// An interrupt
- Interrupt(u8),
- // Unreachable variant
- #[doc(hidden)] Reserved,
-}
-
-impl Exception {
- /// Returns the type of the exception that's currently active
- ///
- /// Returns `None` if no exception is currently active
- pub fn active() -> Option<Exception> {
- // NOTE(safe) atomic read with no side effects
- let icsr = unsafe { (*::peripheral::SCB::ptr()).icsr.read() };
-
- Some(match icsr as u8 {
- 0 => return None,
- 2 => Exception::NMI,
- 3 => Exception::HardFault,
- 4 => Exception::MenManage,
- 5 => Exception::BusFault,
- 6 => Exception::UsageFault,
- 11 => Exception::SVCall,
- 14 => Exception::PendSV,
- 15 => Exception::SysTick,
- n if n >= 16 => Exception::Interrupt(n - 16),
- _ => Exception::Reserved,
- })
- }
-}
-
-/// Registers stacked (pushed into the stack) during an exception
-#[derive(Clone, Copy, Debug)]
-#[repr(C)]
-pub struct ExceptionFrame {
- /// (General purpose) Register 0
- pub r0: u32,
- /// (General purpose) Register 1
- pub r1: u32,
- /// (General purpose) Register 2
- pub r2: u32,
- /// (General purpose) Register 3
- pub r3: u32,
- /// (General purpose) Register 12
- pub r12: u32,
- /// Linker Register
- pub lr: u32,
- /// Program Counter
- pub pc: u32,
- /// Program Status Register
- pub xpsr: u32,
-}