mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
add routine to poweroff SoC directly via susres mechanism
the llio power-cut mechanism is no longer effective with the power-down sequencing required by susres. use the susres mechanism instead, and depracate the previous method.
This commit is contained in:
parent
d7392d3704
commit
746ab64c2f
3 changed files with 20 additions and 0 deletions
|
|
@ -63,6 +63,9 @@ pub enum Opcode {
|
|||
/// used by processes to indicate they are suspending now; this blocks until resume using the "execution gate"
|
||||
SuspendingNow,
|
||||
|
||||
/// used to power off the system without suspend
|
||||
PowerOff,
|
||||
|
||||
/// exit the server
|
||||
Quit,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -180,6 +180,13 @@ impl Susres {
|
|||
).map(|_|())
|
||||
}
|
||||
}
|
||||
|
||||
/// Pulls power from the SoC without attempting to save state
|
||||
pub fn immediate_poweroff(&self) -> Result<(), xous::Error> {
|
||||
send_message(self.conn,
|
||||
Message::new_scalar(Opcode::PowerOff.to_usize().unwrap(), 0, 0, 0, 0)
|
||||
).map(|_|())
|
||||
}
|
||||
}
|
||||
fn drop_conn(sid: xous::SID) {
|
||||
let cid = xous::connect(sid).unwrap();
|
||||
|
|
|
|||
|
|
@ -212,6 +212,12 @@ mod implementation {
|
|||
pub fn set_reboot_vector(&mut self, vector: u32) {
|
||||
self.reboot_csr.wfo(utra::reboot::ADDR_ADDR, vector);
|
||||
}
|
||||
pub fn force_power_off(&mut self) {
|
||||
loop {
|
||||
self.csr.wfo(utra::susres::POWERDOWN_POWERDOWN, 1);
|
||||
xous::yield_slice();
|
||||
} // block forever here
|
||||
}
|
||||
|
||||
pub fn setup_timeout_csr(&mut self, cid: xous::CID) -> Result<(), xous::Error> {
|
||||
xous::send_message(cid,
|
||||
|
|
@ -444,6 +450,7 @@ mod implementation {
|
|||
}
|
||||
pub fn reboot(&self, _reboot_soc: bool) {}
|
||||
pub fn set_reboot_vector(&self, _vector: u32) {}
|
||||
pub fn force_power_off(&mut self) {}
|
||||
pub fn do_suspend(&mut self, _forced: bool) {
|
||||
}
|
||||
pub fn do_resume(&mut self) -> bool {
|
||||
|
|
@ -808,6 +815,9 @@ fn main() -> ! {
|
|||
Some(Opcode::SuspendDeny) => {
|
||||
allow_suspend = false;
|
||||
},
|
||||
Some(Opcode::PowerOff) => {
|
||||
susres_hw.force_power_off();
|
||||
}
|
||||
Some(Opcode::Quit) => {
|
||||
break
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue