From 05df98d1c1b9ef29daa6ea9cc9f7cd9c787a3f93 Mon Sep 17 00:00:00 2001 From: bunnie Date: Sun, 2 May 2021 16:10:51 +0800 Subject: [PATCH] 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. --- services/gam/src/status.rs | 2 +- services/graphics-server/src/main.rs | 7 ++++--- services/log-server/src/main.rs | 1 + services/susres/src/api.rs | 2 ++ services/susres/src/lib.rs | 15 +++++++++++++++ services/xous-names/src/lib.rs | 1 + 6 files changed, 24 insertions(+), 4 deletions(-) diff --git a/services/gam/src/status.rs b/services/gam/src/status.rs index 440ddb32b..49c5b9088 100644 --- a/services/gam/src/status.rs +++ b/services/gam/src/status.rs @@ -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 = None; diff --git a/services/graphics-server/src/main.rs b/services/graphics-server/src/main.rs index b536f9d55..e13a202da 100644 --- a/services/graphics-server/src/main.rs +++ b/services/graphics-server/src/main.rs @@ -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); diff --git a/services/log-server/src/main.rs b/services/log-server/src/main.rs index a98294973..859faf47f 100644 --- a/services/log-server/src/main.rs +++ b/services/log-server/src/main.rs @@ -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(); }, diff --git a/services/susres/src/api.rs b/services/susres/src/api.rs index 28b444d0e..eaff431c2 100644 --- a/services/susres/src/api.rs +++ b/services/susres/src/api.rs @@ -174,12 +174,14 @@ impl SuspendResume for RegManager { // 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 { pub mem: xous::MemoryRange, pub backing: [u32; N], } #[allow(dead_code)] +#[cfg(target_os = "none")] impl ManagedMem { pub fn new(src: xous::MemoryRange) -> Self { ManagedMem { diff --git a/services/susres/src/lib.rs b/services/susres/src/lib.rs index a0237d35c..d53f96673 100644 --- a/services/susres/src/lib.rs +++ b/services/susres/src/lib.rs @@ -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 { 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 { + Ok(Susres { + conn: 0, + suspend_cb_sid: None, + execution_gate_conn: 0, + }) + } + pub fn new_without_hook(xns: &xous_names::XousNames) -> Result { let conn = xns.request_connection_blocking(api::SERVER_NAME_SUSRES)?; Ok(Susres { diff --git a/services/xous-names/src/lib.rs b/services/xous-names/src/lib.rs index 9b21683e9..992922dc5 100644 --- a/services/xous-names/src/lib.rs +++ b/services/xous-names/src/lib.rs @@ -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(); } }