Skip to content

Commit 6a1db3b

Browse files
boot: Add freestanding version of unload_image
1 parent 5ce8d88 commit 6a1db3b

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

uefi/src/boot.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ pub fn open_protocol_exclusive<P: ProtocolPointer + ?Sized>(
265265
/// If the image is successfully loaded, a [`Handle`] supporting the
266266
/// [`LoadedImage`] and [`LoadedImageDevicePath`] protocols is returned. The
267267
/// image can be started with `start_image` and unloaded with
268-
/// `unload_image`.
268+
/// [`unload_image`].
269269
///
270270
/// # Errors
271271
///
@@ -322,6 +322,19 @@ pub fn load_image(parent_image_handle: Handle, source: LoadImageSource) -> Resul
322322
}
323323
}
324324

325+
/// Unloads a UEFI image.
326+
///
327+
/// # Errors
328+
///
329+
/// * [`Status::UNSUPPORTED`]: the image has been started, and does not support unload.
330+
/// * [`Status::INVALID_PARAMETER`]: `image_handle` is not valid.
331+
pub fn unload_image(image_handle: Handle) -> Result {
332+
let bt = boot_services_raw_panicking();
333+
let bt = unsafe { bt.as_ref() };
334+
335+
unsafe { (bt.unload_image)(image_handle.as_ptr()) }.to_result()
336+
}
337+
325338
/// A buffer returned by [`locate_handle_buffer`] that contains an array of
326339
/// [`Handle`]s that support the requested protocol.
327340
#[derive(Debug, Eq, PartialEq)]

0 commit comments

Comments
 (0)