disable suspend/resume support in hosted mode

hosted mode doesn't have suspend/resume support, and it's
not worth debugging subtle issues on that side of the fence
that seem to be OS-dependent.
This commit is contained in:
bunnie 2021-05-02 16:10:51 +08:00
parent 0621fed5d6
commit 05df98d1c1
6 changed files with 24 additions and 4 deletions

View file

@ -117,7 +117,7 @@ pub fn status_thread(canvas_gid_0: usize, canvas_gid_1: usize, canvas_gid_2: usi
let mut rtc = rtc::Rtc::new(&xns).unwrap();
// TODO: debug why this is unreliable
rtc.clear_wakeup_alarm().unwrap(); // clear any wakeup alarm state, if it was set
//rtc.clear_wakeup_alarm().unwrap(); // clear any wakeup alarm state, if it was set
rtc.hook_rtc_callback(dt_callback).unwrap();
let mut datetime: Option<rtc::DateTime> = None;

View file

@ -91,13 +91,14 @@ fn xmain() -> ! {
op::rounded_rectangle(display.native_buffer(), rr, None);
}
let screen_clip = Rectangle::new(Point::new(0,0), display.screen_size());
display.redraw();
// register a suspend/resume listener
let sr_cid = xous::connect(sid).expect("couldn't create suspend callback connection");
let mut susres = susres::Susres::new(&xns, Opcode::SuspendResume as u32, sr_cid).expect("couldn't create suspend/resume object");
let screen_clip = Rectangle::new(Point::new(0,0), display.screen_size());
display.redraw();
loop {
let mut msg = xous::receive_message(sid).unwrap();
log::trace!("Message: {:?}", msg);

View file

@ -230,6 +230,7 @@ fn handle_scalar(
}
1200 => writeln!(output, "Terminating process").unwrap(),
2000 => {
#[cfg(target_os = "none")]
crate::debug::DEFAULT.enable_rx();
writeln!(output, "Resuming logger").unwrap();
},

View file

@ -174,12 +174,14 @@ impl<const N: usize> SuspendResume for RegManager<N> {
// because the volatile memory regions can be potentially large (128kiB), but fewer (maybe 5-6 total in the system),
// we allocate these as stand-alone structures and manage them explicitly.
#[derive(Debug)]
#[cfg(target_os = "none")]
pub struct ManagedMem<const N: usize> {
pub mem: xous::MemoryRange,
pub backing: [u32; N],
}
#[allow(dead_code)]
#[cfg(target_os = "none")]
impl<const N: usize> ManagedMem<N> {
pub fn new(src: xous::MemoryRange) -> Self {
ManagedMem {

View file

@ -14,6 +14,7 @@ pub struct Susres {
execution_gate_conn: CID,
}
impl Susres {
#[cfg(target_os = "none")]
pub fn new(xns: &xous_names::XousNames, cb_discriminant: u32, cid: CID) -> Result<Self, xous::Error> {
let conn = xns.request_connection_blocking(api::SERVER_NAME_SUSRES).expect("Can't connect to SUSRES");
let execution_gate_conn = xns.request_connection_blocking(api::SERVER_NAME_EXEC_GATE).expect("Can't connect to the execution gate");
@ -35,6 +36,20 @@ impl Susres {
execution_gate_conn,
})
}
// suspend/resume is not implemented in hosted mode, and will break if you try to do it.
// the main reason this was doen is actually it seems hosted mode can't handle the level
// of concurrency introduced by suspend/resume, as its underlying IPC mechanisms are quite
// different and have a lot of overhead; it seems like the system goes into a form of deadlock
// during boot when all the hosted mode servers try to connect. This isn't an issue on real hardware.
#[cfg(not(target_os = "none"))]
pub fn new(xns: &xous_names::XousNames, cb_discriminant: u32, cid: CID) -> Result<Self, xous::Error> {
Ok(Susres {
conn: 0,
suspend_cb_sid: None,
execution_gate_conn: 0,
})
}
pub fn new_without_hook(xns: &xous_names::XousNames) -> Result<Self, xous::Error> {
let conn = xns.request_connection_blocking(api::SERVER_NAME_SUSRES)?;
Ok(Susres {

View file

@ -81,6 +81,7 @@ impl XousNames {
Err(xous::Error::AccessDenied) => return Err(xous::Error::AccessDenied),
_ => (),
}
log::info!("connection to {} could not be established, retrying", name);
xous::yield_slice();
}
}