Skip to content

Commit 50fc455

Browse files
authored
Merge pull request #1258 from nicholasbishop/bishop-freestanding-reset
runtime: Add uefi::runtime::reset
2 parents 64c26a4 + 2e4d899 commit 50fc455

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
@@ -443,3 +443,27 @@ pub fn query_capsule_capabilities(capsule_header_array: &[&CapsuleHeader]) -> Re
443443
.to_result_with_val(|| info)
444444
}
445445
}
446+
447+
/// Resets the computer.
448+
///
449+
/// See [`ResetType`] for details of the various reset types.
450+
///
451+
/// For a normal reset the value of `status` should be
452+
/// [`Status::SUCCESS`]. Otherwise, an error code can be used.
453+
///
454+
/// The `data` arg is usually `None`. Otherwise, it must contain a UCS-2
455+
/// null-terminated string followed by additional binary data. For
456+
/// [`ResetType::PLATFORM_SPECIFIC`], the binary data must be a vendor-specific
457+
/// [`Guid`] that indicates the type of reset to perform.
458+
///
459+
/// This function never returns.
460+
pub fn reset(reset_type: ResetType, status: Status, data: Option<&[u8]>) -> ! {
461+
let rt = runtime_services_raw_panicking();
462+
let rt = unsafe { rt.as_ref() };
463+
464+
let (size, data) = data
465+
.map(|data| (data.len(), data.as_ptr()))
466+
.unwrap_or((0, ptr::null()));
467+
468+
unsafe { (rt.reset_system)(reset_type, status, size, data) }
469+
}

0 commit comments

Comments
 (0)