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

Add Security Attribution Unit support #180

Merged
merged 1 commit into from
Apr 15, 2020
Merged

Conversation

hug-dev
Copy link
Contributor

@hug-dev hug-dev commented Dec 18, 2019

The SAU is a Armv8-M core peripheral that, alongside the Implementation
Defined Attribution Unit, manages the security attribution of the memory
zones.
This driver provides abstraction to help setting the SAU up.

This pull-request adds a new dependency, bitfield which provides a really nice way to describe bit fields in registers with methods to access them. It makes it really easier to use/write rather than having to manually declare the shift number and mask constants.
Although bitfield does not have any dependency, I am well aware of the increased cost of memory its addition could cause to embedded targets.
I am really open to criticism about its use, if you would prefer me not to use it, or if you would like to see benchmarks of memory usage for some reference targets of embedded Rust 😃

The SAU is a Armv8-M core peripheral that, alongside the Implementation
Defined Attribution Unit, manages the security attribution of the memory
zones.
This driver provides abstraction to help setting the SAU up.

Signed-off-by: Hugues de Valon <hugues.devalon@arm.com>
@hug-dev hug-dev requested a review from a team as a code owner December 18, 2019 22:06
@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @ithinuel (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-cortex-m labels Dec 18, 2019
@thejpster
Copy link
Contributor

bitfield ... provides a really nice way to describe bit fields in registers

I think the medium-term plan was to find/write an SVD file for the Cortex-M core peripherals, so we could use svd2rust and generate a cortex-m-pac (which this high-level crate would then use). But I think this is a good interim step.

@@ -130,6 +131,9 @@ pub struct Peripherals {
/// Nested Vector Interrupt Controller
pub NVIC: NVIC,

/// Security Attribution Unit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change. Adding a field to a structure that only has public fields is a breaking change.

"Why?" Because of destructuring syntax:

fn foo(a: A) {
    let A { b, c } = a;
}

struct A {
    pub b: u8,
    pub c: u16,
    // pub d: u32, // adding this breaks the above `let` statement
}

@hug-dev
Copy link
Contributor Author

hug-dev commented Jan 11, 2020

Maybe it is better to wait that the cortex-m-pac crate is available to remove the bitfields dependency and use that.

@hug-dev
Copy link
Contributor Author

hug-dev commented Feb 28, 2020

Assuming that #193 is merged I guess this would not be a breaking change anymore and hence be merged more easily?
It could use the bitfield crate for now and I can switch to using the cortex-m-pac crate in a future PR when it is available.

Copy link
Contributor

@thejpster thejpster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get this in. We can reduce the impact of any breaking changes subsequently if we want to.

@thejpster
Copy link
Contributor

bors r+

@bors
Copy link
Contributor

bors bot commented Apr 15, 2020

Build succeeded:

@bors bors bot merged commit f2a56ec into rust-embedded:master Apr 15, 2020
@hug-dev hug-dev deleted the sau branch April 15, 2020 08:20
@adamgreig adamgreig mentioned this pull request Jul 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-cortex-m
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants