From 127fa814a8ed1d5d57a7fe978c37638d5d129b83 Mon Sep 17 00:00:00 2001 From: Adam Greig Date: Tue, 16 Jun 2020 20:07:22 +0100 Subject: [PATCH 1/6] Remove StaticResource and deny(warnings), bump version to 1.0.0 --- Cargo.toml | 2 +- src/lib.rs | 49 ------------------------------------------------- 2 files changed, 1 insertion(+), 50 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 94bea04..27a0f49 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,4 +7,4 @@ keywords = ["bare-metal", "register", "peripheral", "interrupt"] license = "MIT OR Apache-2.0" name = "bare-metal" repository = "https://github.com/rust-embedded/bare-metal" -version = "0.2.5" +version = "1.0.0" diff --git a/src/lib.rs b/src/lib.rs index b1acb15..c318134 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,6 @@ //! Abstractions common to bare metal systems. #![deny(missing_docs)] -#![deny(warnings)] #![no_std] use core::cell::UnsafeCell; @@ -93,51 +92,3 @@ unsafe impl Sync for Mutex where T: Send {} /// ``` #[allow(dead_code)] const GH_6: () = (); - -/// Trait for static (singleton) resources with managed ownership. -/// -/// This trait allows application code and libraries to take ownership of resources that exist once -/// on every core, or once on the entire system. -/// -/// # Safety -/// -/// In order to safely implement this trait, the implementor must ensure that: -/// - A call to `take()` or `steal()` atomically ensures that no further call to `take()` will -/// succeed. This is commonly accomplished by using a static `AtomicBool` variable and a -/// compare-and-swap operation or a critical section. -/// - It is impossible to link multiple crates containing the synchronization state together. This -/// is usually accomplished by defining a well-known [`links = "..."`][links] key in the -/// `Cargo.toml`. -/// -/// [links]: https://doc.rust-lang.org/cargo/reference/build-scripts.html#the-links-manifest-key -pub unsafe trait StaticResource: Sized { - /// Obtains ownership of this resource singleton and makes it unavailable to future callers of - /// `take()`. - /// - /// If `take()` or `steal()` have been called before, this returns `None`. - fn take() -> Option; - - /// Obtains an instance of this resource and makes all future calls to `take()` return `None`. - /// - /// This will not check if `take()` or `steal()` have already been called before. It is the - /// caller's responsibility to use the returned instance in a safe way that does not conflict - /// with other instances. - /// - /// This function is intended to be used when it is statically known that the resource is still - /// available (for example, in generated code that runs immediately after reset). It generally - /// has lower cost than `take().unwrap()`. - unsafe fn steal() -> Self; - - /// Unsafely obtains an instance of this resource. - /// - /// This will not check if `take()` or `steal()` have already been called before. It is the - /// caller's responsibility to use the returned instance in a safe way that does not conflict - /// with other instances. - /// - /// Contrary to `steal()`, `conjure()` will *not* make future calls to `take()` return `None`. - /// - /// This function can be used to perform operations on a resource, ignoring any current - /// ownership of the resource. The safety of this depends on the specific resource, and on the - /// operations performed. - unsafe fn conjure() -> Self; -} From 91892888f2b52b61fe63b2562cc050ab2e80967b Mon Sep 17 00:00:00 2001 From: Adam Greig Date: Tue, 16 Jun 2020 20:12:25 +0100 Subject: [PATCH 2/6] Deny warnings in CI --- ci/script.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ci/script.sh b/ci/script.sh index b0aec22..78b71a5 100644 --- a/ci/script.sh +++ b/ci/script.sh @@ -1,5 +1,7 @@ set -euxo pipefail +export RUSTFLAGS="-D warnings" + main() { cargo check --target $TARGET From 6d9909e61e1a0eb67e267350cac126d8e56ae5d3 Mon Sep 17 00:00:00 2001 From: Adam Greig Date: Tue, 23 Jun 2020 20:05:34 +0100 Subject: [PATCH 3/6] Update CHANGELOG, add README to Cargo.toml, hide GH_6 from docs --- CHANGELOG.md | 7 +++---- Cargo.toml | 1 + src/lib.rs | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3cf98ce..4c6a6c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,9 +5,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] -### Added - -- Added the `StaticResource` trait. +## [v1.0.0] - 2020-06-23 ### Breaking Changes @@ -77,7 +75,8 @@ YANKED due to a soundness issue: see v0.2.1 for details - Initial release -[Unreleased]: https://github.com/japaric/bare-metal/compare/v0.2.5...HEAD +[Unreleased]: https://github.com/japaric/bare-metal/compare/v1.0.0...HEAD +[Unreleased]: https://github.com/japaric/bare-metal/compare/v0.2.5...v1.0.0 [v0.2.5]: https://github.com/japaric/bare-metal/compare/v0.2.4...v0.2.5 [v0.2.4]: https://github.com/japaric/bare-metal/compare/v0.2.3...v0.2.4 [v0.2.3]: https://github.com/japaric/bare-metal/compare/v0.2.2...v0.2.3 diff --git a/Cargo.toml b/Cargo.toml index 27a0f49..6d2a953 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,3 +8,4 @@ license = "MIT OR Apache-2.0" name = "bare-metal" repository = "https://github.com/rust-embedded/bare-metal" version = "1.0.0" +readme = "README.md" diff --git a/src/lib.rs b/src/lib.rs index c318134..8cb02d6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -91,4 +91,5 @@ unsafe impl Sync for Mutex where T: Send {} /// } /// ``` #[allow(dead_code)] +#[doc(hidden)] const GH_6: () = (); From b5e4f9f61e9081926e2115e639538e50c5ebf578 Mon Sep 17 00:00:00 2001 From: Adam Greig Date: Wed, 24 Jun 2020 11:37:52 +0100 Subject: [PATCH 4/6] Derive Debug for CriticalSection and Mutex --- src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 8cb02d6..6c28d75 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,7 +11,7 @@ use core::marker::PhantomData; /// An instance of this type indicates that the current core is executing code within a critical /// section. This means that no interrupts must be enabled that could preempt the currently running /// code. -#[derive(Clone, Copy)] +#[derive(Clone, Copy, Debug)] pub struct CriticalSection<'cs> { _0: PhantomData<&'cs ()>, } @@ -46,6 +46,7 @@ impl<'cs> CriticalSection<'cs> { /// **This Mutex is only safe on single-core systems.** /// /// On multi-core systems, a `CriticalSection` **is not sufficient** to ensure exclusive access. +#[derive(Debug)] pub struct Mutex { inner: UnsafeCell, } From 23db60bf7d3d283822473e0c8801358048ad7e38 Mon Sep 17 00:00:00 2001 From: Adam Greig Date: Tue, 30 Jun 2020 23:27:50 +0100 Subject: [PATCH 5/6] Add html_root_url --- src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib.rs b/src/lib.rs index 6c28d75..f21ddc8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,6 +2,7 @@ #![deny(missing_docs)] #![no_std] +#![doc(html_root_url="https://docs.rs/bare-metal/1.0")] use core::cell::UnsafeCell; use core::marker::PhantomData; From 828da459c3106e16ac8c0dcd7bb1e99313284c52 Mon Sep 17 00:00:00 2001 From: Adam Greig Date: Wed, 1 Jul 2020 00:03:39 +0100 Subject: [PATCH 6/6] Update CHANGELOG.md Co-authored-by: Jonas Schievink --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c6a6c1..4ee990c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -76,7 +76,7 @@ YANKED due to a soundness issue: see v0.2.1 for details - Initial release [Unreleased]: https://github.com/japaric/bare-metal/compare/v1.0.0...HEAD -[Unreleased]: https://github.com/japaric/bare-metal/compare/v0.2.5...v1.0.0 +[v1.0.0]: https://github.com/japaric/bare-metal/compare/v0.2.5...v1.0.0 [v0.2.5]: https://github.com/japaric/bare-metal/compare/v0.2.4...v0.2.5 [v0.2.4]: https://github.com/japaric/bare-metal/compare/v0.2.3...v0.2.4 [v0.2.3]: https://github.com/japaric/bare-metal/compare/v0.2.2...v0.2.3