doc/wg/core/notes/core-notes-2021-05-07.md
Amit: Leon has submitted a PR (https://github.com/tock/tock/pull/2517) that makes some large scale changes to the tock registers crate. I want to discuss them
Leon: Basically, until now it has not been easy to re-use the register code for things like the RISCV CSRs or in-memory registers. To get there, this PR creates some Register traits that are shared by CPU registers and things like CSRs, which allows for a shared implementation of all the helper methods and lets us abstract all of the differences between the underlying hardware behind this trait.
Leon: The main downside here is that we now have to import a bunch of traits into a bunch of files just so we can use the methods defined in those traits. Notably, Guillaume and Andre Richter both had similar ideas about how to do this, so I think a lot of users of tock registers see the benefit of this change.
Pat: I put this on the agenda, because this changes an interface that is used by some people outside of Tock. I also think this represent a good opportunity to publish tock-registers as a versioned external crate. But if we want to do that I think we may want to seek more public feedback.
Pat: This would mean we basically "redo" what Andre has already done with registers-rs, and would mean we have an external dependency in Tock, but its exactly the kind of external dependency we have said we would be OK with (no dependencies in that external crate, it is audited and trusted)
Amit: My sense is that we could still have this be a submodule in Tock, or a vendor dependency, or we could pin a particular git version in our Cargo.toml. From a safety / auditability perspective this is basically as strong as having it in the repository.
Amit: This is also not code that is used in capsules, which is reassuring. Nonetheless it feels like this can open a Pandora's box
Johnathan: Pinning to a git commit in Cargo.toml is problematic for our code-auditing practices.
Amit: This would not happen in the kernel crate, but in the chips crate
Leon: Currently we actually reexport all those types in the kernel crate
Amit: Ah right...that is mostly historical so we didn't have to change so many files when the implementation moved to libraries
Leon: I kinda like this approach though.
Hudson: One other note is this would probably also be used in arch/ for risc-v CSRs
Leon: Also, potentially for networking code? So maybe in capsules?
Amit: Not so sure about that because of how this crate uses unsafe.
Leon: My next step after this PR would be a feature flag to disable the register types and only export the interfaces
Leon: Note that currently capsules already have access to this code because of how kernel/ reexports it
Alexandru: I have wanted to use these types in capsules for sensors that have register types
Amit: What is the downside to just keeping this in the Tock repo?
Leon: I think these two changes are orthogonal
Leon: It would probably just be more elegant not to have it coupled to Tock versioning and so on
Amit: So it does not seem as if this PR is blocking on that decision
Pat: Yeah I expected to merge this PR on the call, but wanted to use it as a launching off point for this discussion
Amit: Let's survey the room
Amit: What is the specific issue with pinning to a commit?
Johnathan: We have to either vendor in deps or use cargo audit. Cargo audit uses crate hash from cargo metadata which is not a git ID. This will make it hard to use automated tools for auditing.
Amit: So a crate from crates.io with a particular version would be fine?
Johnathan: Correct. It's possible a git repo would be okay but I would have to look into that.
Amit: Another approach would be we pull in Andre's changes
Leon: They are the exact same
Amit: Cool, so we would combine forces but Andre's crate would just live in our repo basically
Leon: Andre has said he would be open to just having the crate in our repo obsolete his crate
Amit: Seems like we are gonna kick the can down the road. But does sound like eventually it might make sense to externalize some stuff in a thoughtful way.
pub mod?