Skip to content

Commit b818186

Browse files
boot: Add freestanding version of start_image
1 parent 5189347 commit b818186

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

uefi/src/boot.rs

+21
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,27 @@ pub fn unload_image(image_handle: Handle) -> Result {
332332
unsafe { (bt.unload_image)(image_handle.as_ptr()) }.to_result()
333333
}
334334

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

0 commit comments

Comments
 (0)