Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed VectActive::from() returning incorrect value #500

Open
wants to merge 6 commits into
base: v0.7.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/bors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ delete_merged_branches = true
required_approvals = 1
status = [
"ci-linux (stable)",
"ci-linux (1.38.0)",
"ci-linux (1.59.0)",
"rustfmt",
"clippy",
]
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

include:
# Test MSRV
- rust: 1.38.0
- rust: 1.59.0
features: ""

# Test nightly but don't fail
Expand Down
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ version = "1"
features = [ "derive" ]
optional = true

[dependencies.serde_json]
version = "1"
optional = true

[features]
cm7 = []
cm7-r0p1 = ["cm7"]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This project is developed and maintained by the [Cortex-M team][team].

## Minimum Supported Rust Version (MSRV)

This crate is guaranteed to compile on stable Rust 1.38 and up. It might compile with older versions but that may change in any new patch release.
This crate is guaranteed to compile on stable Rust 1.59 and up. It might compile with older versions but that may change in any new patch release.

## License

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
//!
//! # Minimum Supported Rust Version (MSRV)
//!
//! This crate is guaranteed to compile on stable Rust 1.38 and up. It *might*
//! This crate is guaranteed to compile on stable Rust 1.59 and up. It *might*
//! compile with older versions but that may change in any new patch release.

#![deny(missing_docs)]
Expand Down
23 changes: 3 additions & 20 deletions src/peripheral/scb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,25 +172,8 @@
pub fn vect_active() -> VectActive {
let icsr = unsafe { ptr::read(&(*SCB::PTR).icsr as *const _ as *const u32) };

match icsr as u8 {
0 => VectActive::ThreadMode,
2 => VectActive::Exception(Exception::NonMaskableInt),
3 => VectActive::Exception(Exception::HardFault),
#[cfg(not(armv6m))]
4 => VectActive::Exception(Exception::MemoryManagement),
#[cfg(not(armv6m))]
5 => VectActive::Exception(Exception::BusFault),
#[cfg(not(armv6m))]
6 => VectActive::Exception(Exception::UsageFault),
#[cfg(any(armv8m, native))]
7 => VectActive::Exception(Exception::SecureFault),
11 => VectActive::Exception(Exception::SVCall),
#[cfg(not(armv6m))]
12 => VectActive::Exception(Exception::DebugMonitor),
14 => VectActive::Exception(Exception::PendSV),
15 => VectActive::Exception(Exception::SysTick),
irqn => VectActive::Interrupt { irqn: irqn - 16 },
}
// NOTE(unsafe): Assume correctly selected target.
unsafe { VectActive::from(icsr as u8).unwrap_unchecked() }
}
}

Expand Down Expand Up @@ -300,7 +283,7 @@
12 => VectActive::Exception(Exception::DebugMonitor),
14 => VectActive::Exception(Exception::PendSV),
15 => VectActive::Exception(Exception::SysTick),
irqn if irqn >= 16 => VectActive::Interrupt { irqn },
irqn if irqn >= 16 => VectActive::Interrupt { irqn: irqn - 16 },
_ => return None,
})
}
Expand Down Expand Up @@ -665,7 +648,7 @@
pub unsafe fn invalidate_dcache_by_slice<T>(&mut self, slice: &mut [T]) {
self.invalidate_dcache_by_address(
slice.as_ptr() as usize,
slice.len() * core::mem::size_of::<T>(),

Check warning on line 651 in src/peripheral/scb.rs

View workflow job for this annotation

GitHub Actions / clippy

manual slice size calculation

warning: manual slice size calculation --> src/peripheral/scb.rs:651:13 | 651 | slice.len() * core::mem::size_of::<T>(), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `core::mem::size_of_val(slice)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_slice_size_calculation = note: `#[warn(clippy::manual_slice_size_calculation)]` on by default
);
}

Expand Down Expand Up @@ -751,7 +734,7 @@
pub fn clean_dcache_by_slice<T>(&mut self, slice: &[T]) {
self.clean_dcache_by_address(
slice.as_ptr() as usize,
slice.len() * core::mem::size_of::<T>(),

Check warning on line 737 in src/peripheral/scb.rs

View workflow job for this annotation

GitHub Actions / clippy

manual slice size calculation

warning: manual slice size calculation --> src/peripheral/scb.rs:737:13 | 737 | slice.len() * core::mem::size_of::<T>(), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `core::mem::size_of_val(slice)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_slice_size_calculation
);
}

Expand Down
4 changes: 1 addition & 3 deletions xtask/tests/ci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ fn check_crates_build(is_nightly: bool, is_msrv: bool) {
// Relies on all crates in this repo to use the same convention.
let should_use_feature = |feat: &str| {
match feat {
// critical-section doesn't build in 1.38 due to using `#[doc(include_str!(..))]`
"critical-section-single-core" => !is_msrv,
// This is nightly-only, so don't use it on stable.
"inline-asm" => is_nightly,
// This only affects thumbv7em targets.
Expand Down Expand Up @@ -105,7 +103,7 @@ fn main() {

let output = Command::new("rustc").arg("-V").output().unwrap();
let is_nightly = str::from_utf8(&output.stdout).unwrap().contains("nightly");
let is_msrv = str::from_utf8(&output.stdout).unwrap().contains("1.38");
let is_msrv = str::from_utf8(&output.stdout).unwrap().contains("1.59");

check_crates_build(is_nightly, is_msrv);

Expand Down