Skip to content

Commit 1f67d02

Browse files
boot: Add freestanding version of start_image
1 parent 6a1db3b commit 1f67d02

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

uefi/src/boot.rs

+22-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ pub fn open_protocol_exclusive<P: ProtocolPointer + ?Sized>(
264264
///
265265
/// If the image is successfully loaded, a [`Handle`] supporting the
266266
/// [`LoadedImage`] and [`LoadedImageDevicePath`] protocols is returned. The
267-
/// image can be started with `start_image` and unloaded with
267+
/// image can be started with [`start_image`] and unloaded with
268268
/// [`unload_image`].
269269
///
270270
/// # Errors
@@ -335,6 +335,27 @@ pub fn unload_image(image_handle: Handle) -> Result {
335335
unsafe { (bt.unload_image)(image_handle.as_ptr()) }.to_result()
336336
}
337337

338+
/// Transfers control to a loaded image's entry point.
339+
///
340+
/// # Errors
341+
///
342+
/// * [`Status::INVALID_PARAMETER`]: `image_handle` is not valid, or the image
343+
/// has already been initialized with `start_image`.
344+
/// * [`Status::SECURITY_VIOLATION`]: a security policy specifies that the image
345+
/// should not be started.
346+
pub fn start_image(image_handle: Handle) -> Result {
347+
let bt = boot_services_raw_panicking();
348+
let bt = unsafe { bt.as_ref() };
349+
350+
// TODO: implement returning exit data to the caller.
351+
let mut exit_data_size: usize = 0;
352+
let mut exit_data: *mut u16 = ptr::null_mut();
353+
354+
unsafe {
355+
(bt.start_image)(image_handle.as_ptr(), &mut exit_data_size, &mut exit_data).to_result()
356+
}
357+
}
358+
338359
/// A buffer returned by [`locate_handle_buffer`] that contains an array of
339360
/// [`Handle`]s that support the requested protocol.
340361
#[derive(Debug, Eq, PartialEq)]

0 commit comments

Comments
 (0)