Consider adding `uefi::boot::open_protocol_nonexclusive`

Open
#1,892 0 comments 2 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust

Research direction

Start by comparing the existing open_protocol and open_protocol_exclusive APIs and the call site in uefi-test-runner/src/proto/media.rs. Read the related interface discussion in issue 1867, then verify that the proposed unsafe helper uses GetProtocol semantics and provides the intended ScopedProtocol result without requiring the verbose parameter setup.

Written by the indexing model from the issue text.

Description

Splitting this out of https://github.com/rust-osdev/uefi-rs/issues/1733.

Right now, the two primary ways of opening a protocol are open_protocol and open_protocol_exclusive.

open_protocol_exclusive is simple to use, but is often not the right choice because UEFI kinda tacked on exclusive access late in the game and bad things can happen with some protocols when opened in exclusive mode.

open_protocol offers much more flexibility, but it's quite verbose; you have to import OpenProtocolAttributes and OpenProtocolParams, and each call site ends up being eight or so lines.

It might be a good idea to add something like:

unsafe fn open_protocol_nonexclusive<P: ProtocolPointer + ?Sized>(
    handle: Handle,
) -> Result<ScopedProtocol<P>>

This would be essentially the same as implementation as open_protocol_exclusive, except using OpenProtocolAttributes::GetProtocol, and of course the function is unsafe. This would probably replace most real-world uses of open_protocol.

See also https://github.com/rust-osdev/uefi-rs/issues/1867, since that is related to changing the open-protocol interface.

Dominant language
Rust
Stars
1.7k
Forks
205
Avg merge
1d 20h
Merged PRs (30d)
15

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rust-osdev/uefi-rs

All issues in rust-osdev/uefi-rs

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.