Skip to content

Enable access to hidden RAII guard components #1635

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

Merged
merged 3 commits into from
Apr 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions uefi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
- Added `proto::scsi::pass_thru::ExtScsiPassThru`.
- Added `proto::nvme::pass_thru::NvmePassThru`.
- Added `proto::ata::pass_thru::AtaPassThru`.
- Added `boot::ScopedProtocol::open_params()`.
- Added `boot::TplGuard::old_tpl()`.

## Changed
- **Breaking:** Removed `BootPolicyError` as `BootPolicy` construction is no
Expand Down
18 changes: 17 additions & 1 deletion uefi/src/boot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1536,6 +1536,14 @@ pub struct ScopedProtocol<P: Protocol + ?Sized> {
open_params: OpenProtocolParams,
}

impl<P: Protocol + ?Sized> ScopedProtocol<P> {
/// Returns the [`OpenProtocolParams`] used to open the [`ScopedProtocol`].
#[must_use]
pub const fn open_params(&self) -> OpenProtocolParams {
self.open_params
}
}

impl<P: Protocol + ?Sized> Drop for ScopedProtocol<P> {
fn drop(&mut self) {
let bt = boot_services_raw_panicking();
Expand Down Expand Up @@ -1598,6 +1606,14 @@ pub struct TplGuard {
old_tpl: Tpl,
}

impl TplGuard {
/// Returns the previous [`Tpl`].
#[must_use]
pub const fn old_tpl(&self) -> Tpl {
self.old_tpl
}
}

impl Drop for TplGuard {
fn drop(&mut self) {
let bt = boot_services_raw_panicking();
Expand Down Expand Up @@ -1659,7 +1675,7 @@ pub enum OpenProtocolAttributes {
}

/// Parameters passed to [`open_protocol`].
#[derive(Debug)]
#[derive(Clone, Copy, Debug)]
pub struct OpenProtocolParams {
/// The handle for the protocol to open.
pub handle: Handle,
Expand Down