diff --git a/apps/vault/src/ux/icontray.rs b/apps/vault/src/ux/icontray.rs index 7f802211e..cbb915dbd 100644 --- a/apps/vault/src/ux/icontray.rs +++ b/apps/vault/src/ux/icontray.rs @@ -17,7 +17,7 @@ pub(crate) fn icontray_server() { // one connection only, should be the GAM // however, because the predictor is connected only on demand -- we leave this as open-ended, which // means anyone could send something to this server if they knew the name of it. - let ime_sh_sid = xns.register_name(SERVER_NAME_ICONTRAY, None).expect("can't register server"); + let ime_sh_sid = xns.register_name(SERVER_NAME_ICONTRAY, None /*Some(1)*/).expect("can't register server"); let mytriggers = PredictionTriggers { newline: false, diff --git a/services/graphics-server/src/main.rs b/services/graphics-server/src/main.rs index 53132f4ca..f587b2a82 100644 --- a/services/graphics-server/src/main.rs +++ b/services/graphics-server/src/main.rs @@ -128,9 +128,14 @@ fn wrapped_main() -> ! { // these connections should be established: // - GAM // - keyrom (for verifying font maps) + #[cfg(any(target_os = "none", target_os = "xous"))] let sid = xns .register_name(api::SERVER_NAME_GFX, Some(2)) .expect("can't register server"); + #[cfg(not(any(target_os = "none", target_os = "xous")))] + let sid = xns + .register_name(api::SERVER_NAME_GFX, Some(1)) + .expect("can't register server"); draw_boot_logo(&mut display); diff --git a/services/jtag/src/main.rs b/services/jtag/src/main.rs index ca27dc505..85ad1aa76 100644 --- a/services/jtag/src/main.rs +++ b/services/jtag/src/main.rs @@ -510,7 +510,10 @@ fn main() -> ! { // - one connection from the key server // - one connection from shellchat for command line // - another connection from shellchat for oqc testing + #[cfg(any(target_os = "none", target_os = "xous"))] let jtag_sid = xns.register_name(api::SERVER_NAME_JTAG, Some(3)).expect("can't register server"); + #[cfg(not(any(target_os = "none", target_os = "xous")))] + let jtag_sid = xns.register_name(api::SERVER_NAME_JTAG, Some(2)).expect("can't register server"); log::trace!("registered with NS -- {:?}", jtag_sid); let mut jtag = JtagMach::new(); diff --git a/services/keyboard/src/main.rs b/services/keyboard/src/main.rs index 0fa47cfbe..96c7d3386 100644 --- a/services/keyboard/src/main.rs +++ b/services/keyboard/src/main.rs @@ -743,7 +743,7 @@ fn main() -> ! { #[cfg(any(target_os = "none", target_os = "xous"))] let kbd_sid = xns.register_name(api::SERVER_NAME_KBD, Some(4)).expect("can't register server"); #[cfg(not(any(target_os = "none", target_os = "xous")))] - let kbd_sid = xns.register_name(api::SERVER_NAME_KBD, Some(5)).expect("can't register server"); + let kbd_sid = xns.register_name(api::SERVER_NAME_KBD, Some(4)).expect("can't register server"); log::trace!("registered with NS -- {:?}", kbd_sid); // Create a new kbd object diff --git a/services/llio/src/main.rs b/services/llio/src/main.rs index 1c6c54c35..0dab187ec 100644 --- a/services/llio/src/main.rs +++ b/services/llio/src/main.rs @@ -125,7 +125,10 @@ fn main() -> ! { // - time server // - llio // I2C can be used to set time, which can have security implications; we are more strict on counting who can have access to this resource. + #[cfg(any(target_os = "none", target_os = "xous"))] let i2c_sid = xns.register_name(api::SERVER_NAME_I2C, Some(3)).expect("can't register I2C thread"); + #[cfg(not(any(target_os = "none", target_os = "xous")))] + let i2c_sid = xns.register_name(api::SERVER_NAME_I2C, Some(1)).expect("can't register I2C thread"); log::trace!("registered I2C thread with NS -- {:?}", i2c_sid); let _ = thread::spawn({ let i2c_sid = i2c_sid.clone(); diff --git a/services/root-keys/src/main.rs b/services/root-keys/src/main.rs index eb3aa97d5..f1b8c6410 100644 --- a/services/root-keys/src/main.rs +++ b/services/root-keys/src/main.rs @@ -109,6 +109,7 @@ mod implementation { jtag: jtag::Jtag, xns: xous_names::XousNames, ticktimer: ticktimer_server::Ticktimer, + gam: gam::Gam, } #[allow(dead_code)] @@ -118,10 +119,11 @@ mod implementation { let jtag = jtag::Jtag::new(&xns).expect("couldn't connect to jtag server"); RootKeys { password_type: None, - xns, // must occupy tihs connection for the system to boot properly jtag, ticktimer: ticktimer_server::Ticktimer::new().unwrap(), + gam: gam::Gam::new(&xns).expect("couldn't connect to GAM"), + xns, } } pub fn suspend(&self) { @@ -165,12 +167,15 @@ mod implementation { Ok(()) } pub fn do_key_init(&mut self, rootkeys_modal: &mut Modal, main_cid: xous::CID) -> Result<(), RootkeyResult> { + self.xous_init_interlock(); self.fake_progress(rootkeys_modal, main_cid, t!("rootkeys.setup_wait", xous::LANG)) } pub fn do_gateware_update(&mut self, rootkeys_modal: &mut Modal, main_cid: xous::CID, _provision_bbram: bool) -> Result<(), RootkeyResult> { + self.xous_init_interlock(); self.fake_progress(rootkeys_modal, main_cid, t!("rootkeys.gwup_starting", xous::LANG)) } pub fn do_sign_xous(&mut self, rootkeys_modal: &mut Modal, main_cid: xous::CID) -> Result<(), RootkeyResult> { + self.xous_init_interlock(); self.fake_progress(rootkeys_modal, main_cid, t!("rootkeys.init.signing_kernel", xous::LANG)) } pub fn purge_password(&mut self, _ptype: PasswordType) {} @@ -293,6 +298,24 @@ mod implementation { } } } + fn xous_init_interlock(&self) { + loop { + if self.xns.trusted_init_done().expect("couldn't query init done status on xous-names") { + break; + } else { + log::warn!("trusted init of xous-names not finished, rootkeys is holding off on sensitive operations"); + self.ticktimer.sleep_ms(650).expect("couldn't sleep"); + } + } + loop { + if self.gam.trusted_init_done().expect("couldn't query init done status on GAM") { + break; + } else { + log::warn!("trusted init of GAM not finished, rootkeys is holding off on sensitive operations"); + self.ticktimer.sleep_ms(650).expect("couldn't sleep"); + } + } + } } } diff --git a/services/spinor/src/main.rs b/services/spinor/src/main.rs index a980d38d2..029e0c81e 100644 --- a/services/spinor/src/main.rs +++ b/services/spinor/src/main.rs @@ -609,7 +609,10 @@ fn main() -> ! { - PDDB - keyboard (for updating the key map setting, which needs to be loaded upstream of the PDDB) */ + #[cfg(any(target_os = "none", target_os = "xous"))] let spinor_sid = xns.register_name(api::SERVER_NAME_SPINOR, Some(5)).expect("can't register server"); + #[cfg(not(any(target_os = "none", target_os = "xous")))] + let spinor_sid = xns.register_name(api::SERVER_NAME_SPINOR, Some(2)).expect("can't register server"); log::trace!("registered with NS -- {:?}", spinor_sid); let handler_conn = xous::connect(spinor_sid).expect("couldn't create interrupt handler callback connection");