Skip to content

runtime: Add uefi::runtime::reset #1258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions uefi/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,3 +443,27 @@ pub fn query_capsule_capabilities(capsule_header_array: &[&CapsuleHeader]) -> Re
.to_result_with_val(|| info)
}
}

/// Resets the computer.
///
/// See [`ResetType`] for details of the various reset types.
///
/// For a normal reset the value of `status` should be
/// [`Status::SUCCESS`]. Otherwise, an error code can be used.
///
/// The `data` arg is usually `None`. Otherwise, it must contain a UCS-2
/// null-terminated string followed by additional binary data. For
/// [`ResetType::PLATFORM_SPECIFIC`], the binary data must be a vendor-specific
/// [`Guid`] that indicates the type of reset to perform.
///
/// This function never returns.
pub fn reset(reset_type: ResetType, status: Status, data: Option<&[u8]>) -> ! {
let rt = runtime_services_raw_panicking();
let rt = unsafe { rt.as_ref() };

let (size, data) = data
.map(|data| (data.len(), data.as_ptr()))
.unwrap_or((0, ptr::null()));

unsafe { (rt.reset_system)(reset_type, status, size, data) }
}