diff --git a/loader/src/main.rs b/loader/src/main.rs index 19f68d083..d92daed8f 100644 --- a/loader/src/main.rs +++ b/loader/src/main.rs @@ -1228,6 +1228,11 @@ fn boot_sequence(args: KernelArguments, _signature: u32) -> ! { } else { // resume path use utralib::generated::*; + // flip my self-power-on switch: otherwise, I might turn off before the whole sequence is finished. + let mut power_csr = CSR::new(utra::power::HW_POWER_BASE as *mut u32); + power_csr.rmwf(utra::power::POWER_STATE, 1); + power_csr.rmwf(utra::power::POWER_SELF, 1); + // TRNG virtual memory mapping already set up, but we pump values out just to make sure // the pipeline is fresh. Simulations show this isn't necessary, but I feel paranoid; // I worry a subtle bug in the reset logic could leave deterministic values in the pipeline. diff --git a/services/llio/src/main.rs b/services/llio/src/main.rs index 8bd3c5441..9331bdd5c 100644 --- a/services/llio/src/main.rs +++ b/services/llio/src/main.rs @@ -242,6 +242,9 @@ mod implementation { } pub fn resume(&mut self) { self.power_susres.resume(); + // reset these to "on" in case the "off" value was captured and stored on suspend + self.power_csr.rmwf(utra::power::POWER_SELF, 1); + self.power_csr.rmwf(utra::power::POWER_STATE, 1); self.event_susres.resume(); self.gpio_susres.resume(); // restore the UART mux setting after resume diff --git a/services/susres/src/main.rs b/services/susres/src/main.rs index 30050e9ef..96c991d1d 100644 --- a/services/susres/src/main.rs +++ b/services/susres/src/main.rs @@ -87,8 +87,12 @@ mod implementation { } } + // prevent re-ordering + core::sync::atomic::compiler_fence(core::sync::atomic::Ordering::Acquire); // power the system down - this should result in an almost immediate loss of power sr.csr.wfo(utra::susres::POWERDOWN_POWERDOWN, 1); + // prevent re-ordering + core::sync::atomic::compiler_fence(core::sync::atomic::Ordering::Acquire); loop {} // block forever here } else {