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

Whether a lifecycle container/manager can be provided to store the currently open protocol? #1137

Open
sky5454 opened this issue Apr 15, 2024 · 4 comments

Comments

@sky5454
Copy link
Contributor

sky5454 commented Apr 15, 2024

Whether a lifecycle container/manager can be provided to store the currently open protocol?
https://docs.rs/uefi/latest/uefi/table/boot/enum.OpenProtocolAttributes.html
image

Will you design a object manager which stores opened protocol by Exclusive , then user no need to use the unsafe GetProtocol.

#893

@sky5454
Copy link
Contributor Author

sky5454 commented Apr 15, 2024

That's convenient while get protocol from a object manager for users, may like this:

static mut MYPROTOCOL_RUNNING_ID = 0;

fn efI_main() {
   myprotocol = open_protocol_exclusive();
   MYPROTOCOL_RUNNING_ID = store_opened_protocol_to_hashmap(myprotocol);
}

fn in_other_func() {
  myprotocol  = get_opened_protocol_by_hashmap(MYPROTOCOL_RUNNING_ID)
                  .execpt("The previously opened protocol has been closed");

}

@nicholasbishop
Copy link
Member

I may be misunderstanding you, but I think https://docs.rs/uefi/latest/uefi/table/boot/struct.BootServices.html#method.open_protocol_exclusive and https://docs.rs/uefi/latest/uefi/table/boot/struct.ScopedProtocol.html already handle this. If you call open_protocol_exclusive, you'll get an exclusive and scoped protocol that will be closed on drop. If you tried to call open_protocol_exclusive on that same protocol and handle while it was already opened exclusively, you'd get an error.

@sky5454
Copy link
Contributor Author

sky5454 commented Apr 16, 2024

but the complex rust structure with static pass in stack is inconvenient. and it needs box wrapped, atomic, and no Copy trait.

@nicholasbishop
Copy link
Member

#893 will help with that to some extent, since we'll be able to drop the 'boot lifetime parameter from things like ScopedProtocol. I don't think we'd ever want to support Copy though, I don't see how that would work with an exclusive protocol?

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

No branches or pull requests

2 participants