Skip to content

Commit d6b093b

Browse files
runtime: Add uefi::runtime::reset
No test added for this since our test runner isn't really set up for testing multiple resets.
1 parent b4c9a82 commit d6b093b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

uefi/src/runtime.rs

+24
Original file line numberDiff line numberDiff line change
@@ -378,3 +378,27 @@ pub fn query_variable_info(attributes: VariableAttributes) -> Result<VariableSto
378378
.to_result_with_val(|| info)
379379
}
380380
}
381+
382+
/// Resets the computer.
383+
///
384+
/// See [`ResetType`] for details of the various reset types.
385+
///
386+
/// For a normal reset the value of `status` should be
387+
/// [`Status::SUCCESS`]. Otherwise, an error code can be used.
388+
///
389+
/// The `data` arg is usually `None`. Otherwise, it must contain a UCS-2
390+
/// null-terminated string followed by additional binary data. For
391+
/// [`ResetType::PLATFORM_SPECIFIC`], the binary data must be a vendor-specific
392+
/// [`Guid`] that indicates the type of reset to perform.
393+
///
394+
/// This function never returns.
395+
pub fn reset(reset_type: ResetType, status: Status, data: Option<&[u8]>) -> ! {
396+
let rt = runtime_services_raw_panicking();
397+
let rt = unsafe { rt.as_ref() };
398+
399+
let (size, data) = data
400+
.map(|data| (data.len(), data.as_ptr()))
401+
.unwrap_or((0, ptr::null()));
402+
403+
unsafe { (rt.reset_system)(reset_type, status, size, data) }
404+
}

0 commit comments

Comments
 (0)