feat(eficore): find the extended boot loader partition on the disk of a partition

Look for a filesystem on the same disk whose GPT partition type is the
XBOOTLDR type, using the partition info protocol. open_shared moves to
the handle module so the graphical menu and the discovery share it.
This commit is contained in:
alex authored and Alex Zenla committed 2026-10-03 20:23:57 -07:00
1 parent d41bcaa292
commit 5b345c82d1
4 files changed
+109 -23

No files matched your search

+20 -1
View File
@@ -1,5 +1,6 @@
use anyhow::{Context, Result};
use uefi::boot::SearchType;
use uefi::boot::{OpenProtocolAttributes, OpenProtocolParams, ScopedProtocol, SearchType};
use uefi::proto::ProtocolPointer;
use uefi::{Guid, Handle};
use uefi_raw::Status;
@@ -24,3 +25,21 @@ pub fn find_handle(protocol: &Guid) -> Result<Option<Handle>> {
}
}
}
/// Open the protocol `P` on `handle` without taking it from the firmware.
/// An exclusive open makes the firmware disconnect every driver that is using the protocol,
/// which for a disk or a partition would remove the filesystem Sprout is running from.
pub fn open_shared<P: ProtocolPointer + ?Sized>(handle: Handle) -> uefi::Result<ScopedProtocol<P>> {
// SAFETY: The protocols opened this way are only used from this thread, and the firmware
// keeps them installed for as long as they are open.
unsafe {
uefi::boot::open_protocol::<P>(
OpenProtocolParams {
handle,
agent: uefi::boot::image_handle(),
controller: None,
},
OpenProtocolAttributes::GetProtocol,
)
}
}