Skip to content

Implement base for PCI Root bridge io protocols #1724

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

tmvkrpxl0
Copy link

This is continuation of #1705
As requested by @phil-opp I decided to split the pr into multiple.
This one only contains base for the upcoming other PRs.
Specifically, it contains wrapper for pages allocated and regions mapped by the protocol.
and it adds new pci device with big memory for testing memory protocols later.
Since no protocol is submitted yet users wont be able to use this for now.

Checklist

  • Sensible git history (for example, squash "typo" or "fix" commits). See the Rewriting History guide for help.
  • Update the changelog (if necessary)

@tmvkrpxl0 tmvkrpxl0 marked this pull request as ready for review July 18, 2025 01:43

impl Drop for PciMappedRegion<'_, '_> {
fn drop(&mut self) {
let status = unsafe { (self.proto.unmap)(self.proto, self.key) };
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to add a fn unmap(self) -> Result method, so that callers can choose to handle errors from unmapping? The Drop trait doesn't really allow that. I think the drop implementation should probably not panic on errors, and that we should remove the unreachable; UEFI implementations sometimes return additional errors beyond what the spec includes.

Ditto for the PciPage implementation.

Copy link
Author

Choose a reason for hiding this comment

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

True, I initially put unreachable macro there to indicate that "errors that may happen according to spec are all handled and no other error can occur"
But yeah second thought we can never be sure

Copy link
Author

Choose a reason for hiding this comment

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

Tho, what else should it do when an error occurs? Should I make it undroppable(assuming it's possible) so that users must use functions like unmap?

@tmvkrpxl0
Copy link
Author

Well test fails on windows because it can't use new pci memory device

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.

2 participants