Skip to content

Commit 450c4e6

Browse files
boot: Add freestanding version of start_image
1 parent ac56349 commit 450c4e6

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
@@ -263,7 +263,7 @@ pub fn open_protocol_exclusive<P: ProtocolPointer + ?Sized>(
263263
///
264264
/// If the image is successfully loaded, a [`Handle`] supporting the
265265
/// [`LoadedImage`] and [`LoadedImageDevicePath`] protocols is returned. The
266-
/// image can be started with `start_image` and unloaded with
266+
/// image can be started with [`start_image`] and unloaded with
267267
/// [`unload_image`].
268268
///
269269
/// # Errors
@@ -334,6 +334,27 @@ pub fn unload_image(image_handle: Handle) -> Result {
334334
unsafe { (bt.unload_image)(image_handle.as_ptr()) }.to_result()
335335
}
336336

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

0 commit comments

Comments
 (0)