add efi shell so that chainloading multiple items can be tested

This commit is contained in:
2025-10-02 00:24:19 -07:00
parent b8e1d11bed
commit 6bf745946e
8 changed files with 78 additions and 31 deletions

View File

@@ -1,7 +1,7 @@
use uefi::CString16;
use uefi::fs::{FileSystem, Path};
use uefi::proto::device_path::PoolDevicePath;
use uefi::proto::device_path::text::DevicePathFromText;
use uefi::proto::device_path::text::{AllowShortcuts, DevicePathFromText, DisplayOnly};
use uefi::proto::device_path::{DevicePath, PoolDevicePath};
use uefi::proto::media::fs::SimpleFileSystem;
pub fn text_to_device_path(path: &str) -> PoolDevicePath {
@@ -17,6 +17,26 @@ pub fn text_to_device_path(path: &str) -> PoolDevicePath {
.expect("unable to convert text to device path")
}
pub fn device_path_root(path: &DevicePath) -> String {
let mut path = path
.node_iter()
.filter_map(|item| {
let item = item
.to_string(DisplayOnly(false), AllowShortcuts(false))
.expect("unable to convert device path to string");
if item.to_string().contains("(") {
Some(item)
} else {
None
}
})
.map(|item| item.to_string())
.collect::<Vec<_>>()
.join("/");
path.push('/');
path
}
pub fn read_file_contents(path: &str) -> Vec<u8> {
let fs = uefi::boot::open_protocol_exclusive::<SimpleFileSystem>(
uefi::boot::get_handle_for_protocol::<SimpleFileSystem>().expect("no filesystem protocol"),