-
-
Notifications
You must be signed in to change notification settings - Fork 173
Implement rest of PCI Root Bridge I/O protocol #1705
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
base: main
Are you sure you want to change the base?
Conversation
Currently |
I switched to GhostCell and finally got rid of that weird design where the self parameter can only be |
This allows PciRootBridgeIo to be used as `protocol.copy_mem` instead of `PciRootBridgeIo::copy_mem(protocol, ...)`
Well that was very messy but I finally cleaned out the git history. I think I'm ready for review. |
Hey! I have working (& tested 😄 ) code to recursively scan the bus for pci devices. Maybe the code snipped can be of use to you, or maybe you succeed in converting it to something upstreamable even. Entry-Point is |
I decided to implement missing features of PCI Root Bridge I/O protocol. It's not complete yet and I'm opening this PR beforehand to get a review.
Protocols to implement
Design Questions
All design questions are resolved as of now
I had to use RefCell for allocate, free, map, unmap and copy because I wanted allocated buffer and mapped region to clean themselves after they're dropped by calling free/unmap, and track their lifetimes so that they do not outlive protocol which allocated them (as it's required to free themselves), and for map function, do not outlive region they map.I couldn't just use normal reference because copy method requires mutable pointer. I wasn't sure if I can turn this into const pointer because some other functions inPciRootBridgeIoProtocol
struct takes in const pointer, so the original author for it must considered implications of this and I figured I should follow it.However it's quite ugly now and users must use these functions likePciRootBridgeIo::map
instead ofprotocol.map
Ideally it should work like this:
Fixed by switching to GhostCell
Does using GhostCell feel good?Currently the test methods are written as such:Now all methods ofPciRootBridgeIo
only needs shared reference to itself but all of them also take in either shared or mutable reference toGhostToken
And theGhostToken
is wrapped inRefCell
as some types likePciMappedRegion
orPciBuffer
needs mutable reference toGhostToken
but I don't want these to block others from using it either.Fixed by switching everything to shared reference. mutable reference is no longer needed.
Checklist