Skip to content

Commit ac56349

Browse files
boot: Add freestanding version of unload_image
1 parent 7f9d2dd commit ac56349

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
@@ -264,7 +264,7 @@ pub fn open_protocol_exclusive<P: ProtocolPointer + ?Sized>(
264264
/// If the image is successfully loaded, a [`Handle`] supporting the
265265
/// [`LoadedImage`] and [`LoadedImageDevicePath`] protocols is returned. The
266266
/// image can be started with `start_image` and unloaded with
267-
/// `unload_image`.
267+
/// [`unload_image`].
268268
///
269269
/// # Errors
270270
///
@@ -321,6 +321,19 @@ pub fn load_image(parent_image_handle: Handle, source: LoadImageSource) -> Resul
321321
}
322322
}
323323

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

0 commit comments

Comments
 (0)