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

arm: Use FullyQualifiedApAddresses rather than GenericAp or MemoryAp #2706

Merged

Conversation

ithinuel
Copy link
Contributor

@ithinuel ithinuel commented Jul 25, 2024

  • Those two type do not provide much value beyond being attached to a set
    of registers.
  • GenericAp can be converted to MemoryAp without checks.

Follows:

@ithinuel ithinuel force-pushed the use-fqaa-instead-of-genap-and-memap branch 5 times, most recently from 31186fc to f78b33e Compare July 26, 2024 07:44
- Those two type do not provide much value beyond being attached to a set
  of registers.
- GenericAp can be converted to MemoryAp without checks.
@ithinuel ithinuel force-pushed the use-fqaa-instead-of-genap-and-memap branch from f78b33e to 795cfd9 Compare July 27, 2024 22:07
Copy link
Contributor

@bugadani bugadani left a comment

Choose a reason for hiding this comment

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

I'm not quite sold on the unnecessary import grouping changes. I think we should set up rustfmt to enforce an import style that avoids some rebase headaches in the future.

@bugadani bugadani added this pull request to the merge queue Jul 28, 2024
Merged via the queue into probe-rs:master with commit 89c0cbd Jul 28, 2024
20 checks passed
@Tiwalun
Copy link
Member

Tiwalun commented Jul 28, 2024

GenericAp can be converted to MemoryAp without checks.

Not all APs are memory APs, so I don't understand why no check is necessary here. Shouldn't the type be checked?

@bugadani
Copy link
Contributor

I only checked ArmCommunicationInterface<Initialized>::memory_interface and it had a runtime check. I'm not sure about other places, but if the caller is free to convert one AP type into another, then we need these checks anyway and we don't lose much on types, except for maybe a bit of API clarity.

@Tiwalun
Copy link
Member

Tiwalun commented Jul 28, 2024

Now we should check the type of the AP in every function which takes an AP address, which seems more cumbersome than using a specific type to indicate that we know it is a memory AP.

It might reflect the case that we didn't do that check before, so it's probably not worse now, but I would have preferred to keep different types to represent the reality that not all AP addresses point to memory APs.

@bugadani
Copy link
Contributor

I would agree if constructing a MemoryAp type included checking whether the AP is actually a memory AP. If we don't do this check at construction time, then it doesn't matter what type our API takes, there's opportunity for misuse.

Anyway, feel free to revert this PR if you feel that we should try another approach.

@ithinuel
Copy link
Contributor Author

ithinuel commented Jul 28, 2024

Actually please do not revert. The types and checks are added in the following pr.

EDIT: Give me a little moment, I’ll rebase #2683 and add links to the relevant parts for the types and the checks.

EDIT2: And for my humble opinion, as much as I’d like to avoid doing those checks several times at run time, this only happen when a new memory_interface is obtained, so it is not as bad as it looks.
Also, I’d like to have them cached somewhere so as not to have to do that check again but the complexity cost seemed to outweigh the simple check at instanciation time.

EDIT3:
@bugadani with regards to the grouping of imports, this is to (IMHO) simplify their readability.
There modules where things are imported from the same module by relative and absolute path. Considering that some module name appear several times in the tree (like memory) it becomes harder to figure where are things comming from.
Compounded whith re-exports (pub use) I pulled my hair a few times on this.
So definite +1 on defining 1 style and sticking with it. I didn’t know rustfmt could do that. If it does that’d be fantastic to enable (and limiting re-export but that’s yet another story).

EDIT4:
The link to the check done on MemoryAp instanciation: https://github.com/ithinuel/probe-rs/blob/add-adiv6-support-step-2/probe-rs/src/architecture/arm/ap/memory_ap/mod.rs#L179-L193

@ithinuel ithinuel deleted the use-fqaa-instead-of-genap-and-memap branch July 28, 2024 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants