aboutsummaryrefslogtreecommitdiff
path: root/src/exception.rs
diff options
context:
space:
mode:
authorGravatar Jorge Aparicio <japaricious@gmail.com> 2017-03-11 20:58:50 -0500
committerGravatar Jorge Aparicio <japaricious@gmail.com> 2017-03-11 20:58:50 -0500
commit6d4478d448423d402aeabb1fefafb8dad619e889 (patch)
tree3f462ea57e8dee910dd12faad43d4942703d2287 /src/exception.rs
parent23c2ee2561d54243a15484b1456b548b2408eadd (diff)
downloadcortex-m-6d4478d448423d402aeabb1fefafb8dad619e889.tar.gz
cortex-m-6d4478d448423d402aeabb1fefafb8dad619e889.tar.zst
cortex-m-6d4478d448423d402aeabb1fefafb8dad619e889.zip
remove unsafe from exception::default_handler
Diffstat (limited to 'src/exception.rs')
-rw-r--r--src/exception.rs22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/exception.rs b/src/exception.rs
index 451332e..82401df 100644
--- a/src/exception.rs
+++ b/src/exception.rs
@@ -54,25 +54,25 @@ impl Exception {
#[repr(C)]
pub struct Handlers {
/// Non-maskable interrupt
- pub nmi: unsafe extern "C" fn(Nmi),
+ pub nmi: extern "C" fn(Nmi),
/// All class of fault
- pub hard_fault: unsafe extern "C" fn(HardFault),
+ pub hard_fault: extern "C" fn(HardFault),
/// Memory management
- pub mem_manage: unsafe extern "C" fn(MemManage),
+ pub mem_manage: extern "C" fn(MemManage),
/// Pre-fetch fault, memory access fault
- pub bus_fault: unsafe extern "C" fn(BusFault),
+ pub bus_fault: extern "C" fn(BusFault),
/// Undefined instruction or illegal state
- pub usage_fault: unsafe extern "C" fn(UsageFault),
+ pub usage_fault: extern "C" fn(UsageFault),
/// Reserved spots in the vector table
pub _reserved0: [Reserved; 4],
/// System service call via SWI instruction
- pub svcall: unsafe extern "C" fn(Svcall),
+ pub svcall: extern "C" fn(Svcall),
/// Reserved spots in the vector table
pub _reserved1: [Reserved; 2],
/// Pendable request for system service
- pub pendsv: unsafe extern "C" fn(Pendsv),
+ pub pendsv: extern "C" fn(Pendsv),
/// System tick timer
- pub sys_tick: unsafe extern "C" fn(SysTick),
+ pub sys_tick: extern "C" fn(SysTick),
}
/// Non-maskable interrupt
@@ -123,6 +123,8 @@ unsafe impl Context for MemManage {}
unsafe impl Context for BusFault {}
+unsafe impl Context for UsageFault {}
+
unsafe impl Context for Svcall {}
unsafe impl Context for Pendsv {}
@@ -150,7 +152,9 @@ pub const DEFAULT_HANDLERS: Handlers = Handlers {
// This needs asm!, #[naked] and unreachable() to avoid modifying the stack
// pointer (MSP), that way it points to the stacked registers
#[naked]
-pub unsafe extern "C" fn default_handler<T>(_token: T) {
+pub extern "C" fn default_handler<T>(_token: T)
+ where T: Context
+{
// This is the actual exception handler. `_sf` is a pointer to the previous
// stack frame
#[cfg(target_arch = "arm")]