aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jorge Aparicio <jorge@japaric.io> 2017-05-07 16:44:04 -0500
committerGravatar Jorge Aparicio <jorge@japaric.io> 2017-05-07 16:44:30 -0500
commit70b967629e31a9d6581ea5fc14d2880f0cc32eab (patch)
tree374623964bb7c75d8da5ebc6944cf3e0876e4afb
parent0e3dd2df58e52f9af80e47327a62a83511e010f9 (diff)
downloadcortex-m-70b967629e31a9d6581ea5fc14d2880f0cc32eab.tar.gz
cortex-m-70b967629e31a9d6581ea5fc14d2880f0cc32eab.tar.zst
cortex-m-70b967629e31a9d6581ea5fc14d2880f0cc32eab.zip
make `interrupt::enable` unsafe
closes #23
-rw-r--r--CHANGELOG.md12
-rw-r--r--Cargo.toml2
-rw-r--r--src/interrupt.rs8
3 files changed, 19 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c8ea0fc..67373f4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]
+## [v0.2.5] - 2017-05-07
+
+### Added
+
+- Higher level API for the SysTick and FPU peripherals
+
+### Fixed
+
+- MEMORY SAFETY. `interrupt::enable` was safe to call inside an
+ `interrupt::free` critical section thus breaking the preemption protection.
+ The `interrupt::enable` method is now `unsafe`.
+
## [v0.2.4] - 2017-04-20
### Fixed
diff --git a/Cargo.toml b/Cargo.toml
index b221e6e..33c6023 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -6,7 +6,7 @@ keywords = ["arm", "cortex-m", "register", "peripheral"]
license = "MIT OR Apache-2.0"
name = "cortex-m"
repository = "https://github.com/japaric/cortex-m"
-version = "0.2.4"
+version = "0.2.5"
[dependencies]
volatile-register = "0.2.0"
diff --git a/src/interrupt.rs b/src/interrupt.rs
index a4eac00..412c483 100644
--- a/src/interrupt.rs
+++ b/src/interrupt.rs
@@ -47,8 +47,12 @@ pub fn disable() {
}
/// Enables all the interrupts
+///
+/// # Safety
+///
+/// - Do not call this function inside an `interrupt::free` critical section
#[inline(always)]
-pub fn enable() {
+pub unsafe fn enable() {
match () {
#[cfg(target_arch = "arm")]
() => unsafe {
@@ -87,7 +91,7 @@ where
// If the interrupts were active before our `disable` call, then re-enable
// them. Otherwise, keep them disabled
if primask.is_active() {
- enable();
+ unsafe { enable() }
}
r