Skip to main content

leodos_libcfs/psp/
restart.rs

1//! PSP restart and reset functions.
2
3use crate::cfe::es::system::ResetSubtype;
4pub use crate::cfe::es::system::ResetType;
5use crate::ffi;
6use core::mem::MaybeUninit;
7
8/// Requests the PSP to restart the processor. This function does not return.
9///
10/// # Arguments
11/// * `reset_type`: The type of reset to perform (`PowerOn` or `Processor`).
12pub fn restart(reset_type: ResetType) -> ! {
13    unsafe {
14        ffi::CFE_PSP_Restart(reset_type.into());
15    }
16    // This function never returns.
17    loop {}
18}
19
20/// Returns the last reset type and subtype recorded by the PSP.
21pub fn get_restart_type() -> (ResetType, ResetSubtype) {
22    let mut subtype = MaybeUninit::uninit();
23    let reset_type = unsafe { ffi::CFE_PSP_GetRestartType(subtype.as_mut_ptr()) };
24    (
25        (reset_type as u32).into(),
26        unsafe { subtype.assume_init() }.into(),
27    )
28}