-
Notifications
You must be signed in to change notification settings - Fork 190
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
[RFC] All functions must be safe #147
Comments
That's almost a safety bug, as the framework have no way of knowing the contract to allow calling these function. |
Can you elaborate on what you mean by "that"? Do you mean the current state or something else? (Today, the framework won't let call any of these functions from software; that's not going to change) |
I mean if your interrupt handler is unsafe, RTFM has no way of knowing in which context this function can be called. |
I would say that this is a good addition, and to be in line with rust-lang/rfcs#2585, makes sense. |
This has enough approvals and no concerns have been raised over the course of several weeks so this RFC is now officially accepted. 🎉 |
176: implement RFCs 147 and 155, fix #141, etc. r=japaric a=japaric This PR: - Implements RFC 147: "all functions must be safe" - Implements RFC 155: "explicit Context parameter" - Implements the pending breaking change #141: reject assign syntax in `init` (which was used to initialize late resources) - Refactors code generation to make it more readable -- there are no more random identifiers in the output -- and align it with the book description of RTFM internals (see PR #175). - Makes the framework hard depend on `core::mem::MaybeUninit` and thus will require nightly until that API is stabilized. - Fixes a ceiling analysis bug where the priority of the system timer was not considered in the analysis (TODO backport this into the v0.4.x branch). - Shrinks the size of all the internal queues by turning `AtomicUsize` indices into `AtomicU8`s. - Removes the integration with `owned_singleton`. closes #141 closes #147 closes #155 Additionally: - This changes CI to push v0.5.x docs to https://japaric.github.io/rtfm5/book/en/ -- we need to do this because our official docs are hosted on https://japaric.github.io/cortex-m-rtfm and we need to keep them on v0.4.x until we release v0.5.0 - I propose that we use the master branch to develop the upcoming v0.5.0. - I have created a branch v0.4.x for backports; new v0.4.x releases will come from that branch. r? @korken89 @TeXitoi, sorry for doing all the impl work in a single commit -- I know that makes things harder to review for you. Suggestions for compile-pass and compile-fail tests are welcome Co-authored-by: Jorge Aparicio <jorge@japaric.io>
53: build(deps): bump cortex-m-rtfm from v0.5.0-beta.1 to v0.5.0 r=jordens a=dependabot-preview[bot] Bumps [cortex-m-rtfm](https://github.com/rtfm-rs/cortex-m-rtfm) from v0.5.0-beta.1 to v0.5.0. <details> <summary>Changelog</summary> *Sourced from [cortex-m-rtfm's changelog](https://github.com/rtfm-rs/cortex-m-rtfm/blob/master/CHANGELOG.md).* > ## v0.5.0 - 2019-11-14 > > ### Added > > - Experimental support for homogeneous and heterogeneous multi-core > microcontrollers has been added. Support is gated behind the `homogeneous` and > `heterogeneous` Cargo features. > > ### Changed > > - [breaking-change][] [RFC 155] "explicit `Context` parameter" has been > implemented. > > [RFC 155]: [rtic-rs/rtic#155](https://github-redirect.dependabot.com/rtfm-rs/cortex-m-rtfm/issues/155) > > - [breaking-change][] [RFC 147] "all functions must be safe" has been > implemented. > > [RFC 147]: [rtic-rs/rtic#147](https://github-redirect.dependabot.com/rtfm-rs/cortex-m-rtfm/issues/147) > > - All the queues internally used by the framework now use `AtomicU8` indices > instead of `AtomicUsize`; this reduces the static memory used by the > framework. > > - [breaking-change][] when the `capacity` argument is omitted, the capacity of > the task is assumed to be `1`. Before, a reasonable (but hard to predict) > capacity was computed based on the number of `spawn` references the task had. > > - [breaking-change][] resources that are appear as exclusive references > (`&mut-`) no longer appear behind the `Exclusive` newtype. > > - [breaking-change][] the `timer-queue` Cargo feature has been removed. The > `schedule` API can be used without enabling any Cargo feature. > > - [breaking-change][] when the `schedule` API is used the type of > `init::Context.core` changes from `cortex_m::Peripherals` to > `rtfm::Peripherals`. The fields of `rtfm::Peripherals` do not change when > Cargo features are enabled. > > - [breaking-change][] the monotonic timer used to implement the `schedule` API > is now user configurable via the `#[app(monotonic = ..)]` argument. IMPORTANT: > it is now the responsibility of the application author to configure and > initialize the chosen `monotonic` timer during the `#[init]` phase. > > - [breaking-change][] the `peripherals` field is not include in `init::Context` > by default. One must opt-in using the `#[app(peripherals = ..)]` argument. > > - [breaking-change][] the `#[exception]` and `#[interrupt]` attributes have been > removed. Hardware tasks are now declared using the `#[task(binds = ..)]` > attribute. ></tr></table> ... (truncated) </details> <details> <summary>Commits</summary> - [`6b0a2df`](rtic-rs/rtic@6b0a2df) Merge [#272](https://github-redirect.dependabot.com/rtfm-rs/cortex-m-rtfm/issues/272) - [`4fcb6ab`](rtic-rs/rtic@4fcb6ab) v0.5.0 final release - [`e28294b`](rtic-rs/rtic@e28294b) Merge [#271](https://github-redirect.dependabot.com/rtfm-rs/cortex-m-rtfm/issues/271) - [`2441b7e`](rtic-rs/rtic@2441b7e) Minor docs update to monotonic - [`85463ed`](rtic-rs/rtic@85463ed) Merge [#268](https://github-redirect.dependabot.com/rtfm-rs/cortex-m-rtfm/issues/268) [#270](https://github-redirect.dependabot.com/rtfm-rs/cortex-m-rtfm/issues/270) - [`76e2345`](rtic-rs/rtic@76e2345) Added struct de-structure-ing example in tips & tricks - [`e9a8394`](rtic-rs/rtic@e9a8394) fix bash comparison - [`da9c6a7`](rtic-rs/rtic@da9c6a7) run cfail tests only when rustc --version == $MSRV - [`31b392f`](rtic-rs/rtic@31b392f) CI: replace compiletest-rs with trybuild - [`72e84cb`](rtic-rs/rtic@72e84cb) Merge [#266](https://github-redirect.dependabot.com/rtfm-rs/cortex-m-rtfm/issues/266) - Additional commits viewable in [compare view](rtic-rs/rtic@1fe9767...6b0a2df) </details> <br /> Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) - `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language - `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language - `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language - `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language - `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme Additionally, you can set the following in your Dependabot [dashboard](https://app.dependabot.com): - Update frequency (including time of day and day of week) - Pull request limits (per update run and/or open at any time) - Automerge options (never/patch/minor, and dev/runtime dependencies) - Out-of-range updates (receive only lockfile updates, if desired) - Security updates (receive only security updates, if desired) </details> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
147: add thumbv8m baseline r=thejpster a=evq Co-authored-by: eV <ev@7pr.xyz>
Summary
Functions marked with any of these attributes:
exception
,idle
,init
,interrupt
andtask
must be safefn
s and notunsafe fn
s.Motivation
Put us in line with rust-lang/rfcs#2585. All the functions inside the
app
block can only be called by the hardware and are safe to call by the hardware
(the DSL ensures that's the case) -- this should be reflected in the signature.
If a user wants to use unsafe code inside any of these functions they should
explicitly use an
unsafe
block instead of usingunsafe fn
as a short-handfor
unsafe fn() { unsafe { .. } }
.Design
The DSL will reject
unsafe fn
s. For example:Drawbacks
Unsafe code will suffer from (even more) rightward drift.
The text was updated successfully, but these errors were encountered: