message: console: Print a warning if a print is lost
diff: @@ -5,6 +5,7 @@ use crate::result::TockResult;
  use crate::syscalls;
  use core::cell::Cell;
  use core::fmt;
  +use core::fmt::Write;
  use core::mem;
  // Global console
  @@ -41,11 +42,17 @@ pub struct Console {
  allow_buffer: [u8; 64],
  }
  +pub static mut MISSED_PRINT: bool = false;
  +
  pub fn get_global_console() -> Option<Console> {
  unsafe {
  if let Some(con) = CONSOLE.take() {
  Some(con)
  } else {
  + // If we get here then either the console was never initalised
  + // or someone else took it. Set MISSED_PRINT to true so that we
  + // can warn the user.
  + MISSED_PRINT = true;
  None
  }
  }
  @@ -89,8 +96,15 @@ impl Console {
  Ok(())
  }
  - pub fn set_global_console(self) {
  + pub fn set_global_console(mut self) {
  unsafe {
  + if MISSED_PRINT {
  + // Someone tried to print while we were or someone tried
  + // to print before initalisation, print a warning here.
  + let _ = write!(self, "A print was dropped while the console was locked");
  + MISSED_PRINT = false;
  + }
  +
  CONSOLE = Some(self);
  }
  }
  