use alloc::format;
use uefi::boot::{image_handle, load_image, start_image, LoadImageSource};
use uefi::proto::BootPolicy;
use vck_common::{VckError, VckResult};
use crate::provider::DevicePath;
pub fn chainload_next(next_loader: &DevicePath) -> VckResult<()> {
let image = load_image(
image_handle(),
LoadImageSource::FromDevicePath {
device_path: next_loader,
boot_policy: BootPolicy::ExactMatch,
},
)
.map_err(|e| VckError::Io(format!("LoadImage(next loader) failed: {e:?}")))?;
start_image(image)
.map_err(|e| VckError::Io(format!("StartImage(next loader) failed: {e:?}")))?;
Ok(())
}