Skip to content

accessors everywhere (breaking) #692

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

Merged
merged 7 commits into from
Nov 23, 2023
Merged

accessors everywhere (breaking) #692

merged 7 commits into from
Nov 23, 2023

Conversation

burrbull
Copy link
Member

@burrbull burrbull commented Oct 30, 2022

All register/cluster access through methods. RegisterBlock fields are private

To access register or cluster instead of:

per.reg.write(...)
per.regarray[2].write(...)
per.altreg().write(...)

use

per.reg().write(...)
per.regarray(2).write(...)
per.altreg().write(...)

@rust-highfive
Copy link

r? @adamgreig

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-tools labels Oct 30, 2022
@duskmoon314
Copy link
Contributor

What will it be like after this PR? From the brief intro, I imagine this:

// error
uart.thr.write(...);

// correct
uart.thr().write(...);

Is this the expected behavior?

@burrbull
Copy link
Member Author

Yes

@luojia65
Copy link
Contributor

Should we keep register blocks public under some feature gate? Rust kernel developers may still reuse this structure when writing drivers, as in this purpose the base address of peripherals are not fixed as bare metal when MMU comes in.

@duskmoon314
Copy link
Contributor

Should we keep register blocks public under some feature gate? Rust kernel developers may still reuse this structure when writing drivers, as in this purpose the base address of peripherals are not fixed as bare metal when MMU comes in.

It seems this PR only makes the fields private and leaves RegisterBlock as it is. If so, I think there is no problem to use with a virtual address.

@burrbull
Copy link
Member Author

I don't insist on this PR. It is just concept for discuss.

@burrbull burrbull marked this pull request as ready for review November 20, 2023 19:35
@burrbull burrbull requested a review from a team as a code owner November 20, 2023 19:35
@burrbull
Copy link
Member Author

cc @rust-embedded/tools

Copy link
Member

@adamgreig adamgreig left a comment

Choose a reason for hiding this comment

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

It's a big breaking change to the syntax, but I think it should be a fairly easy change for users to make in their code, and importantly it moves us to the syntax we'll need to get rid of memory-mapped structs. I can't see any way to keep the current syntax but not have memory-mapped structs.

I guess if someone needs a pointer to a field, they can still call as_ptr() on what the accessor returns?

@burrbull
Copy link
Member Author

burrbull commented Nov 23, 2023

I guess if someone needs a pointer to a field, they can still call as_ptr() on what the accessor returns?

Should be same as before.

@burrbull burrbull added this pull request to the merge queue Nov 23, 2023
Merged via the queue into master with commit d79beda Nov 23, 2023
@burrbull burrbull deleted the parens branch November 23, 2023 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-tools
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants