mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-22 09:23:16 +00:00
Merge remote-tracking branch 'origin/main' into bunnie-dev
This commit is contained in:
commit
9eb35ddd49
23 changed files with 926 additions and 523 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
|
@ -1,7 +1,4 @@
|
||||||
/target
|
target
|
||||||
/kernel/target
|
|
||||||
/loader/target
|
|
||||||
/locales/target
|
|
||||||
**/*.rs.bk
|
**/*.rs.bk
|
||||||
/emulation/peripherals.csproj
|
/emulation/peripherals.csproj
|
||||||
/emulation/obj
|
/emulation/obj
|
||||||
|
|
|
||||||
4
API.md
4
API.md
|
|
@ -4,6 +4,10 @@ This document conveys much of the similar information, but in a more monolithic
|
||||||
|
|
||||||
## Xous Messaging API In Practice
|
## Xous Messaging API In Practice
|
||||||
|
|
||||||
|
All Messages passed between Xous Servers undergo serialization and de-serialization.
|
||||||
|
- Internal `struct` are readily serialized with [rkyv](https://docs.rs/rkyv/0.4.3/rkyv/) and `#[derive(Debug, num_derive::FromPrimitive, num_derive::ToPrimitive)]`with manual serialization as an alternative ([example](services/net/src/std_udp.rs))
|
||||||
|
- External `struct` may employ [bincode](https://docs.rs/bincode/latest/bincode/)
|
||||||
|
|
||||||
Here are the idioms for building servers and passing messages.
|
Here are the idioms for building servers and passing messages.
|
||||||
|
|
||||||
### api.rs
|
### api.rs
|
||||||
|
|
|
||||||
16
Cargo.lock
generated
16
Cargo.lock
generated
|
|
@ -395,6 +395,12 @@ version = "1.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "checked_int_cast"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "17cc5e6b5ab06331c33589842070416baa137e8b0eb912b008cfd4a78ada7919"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chrono"
|
name = "chrono"
|
||||||
version = "0.4.19"
|
version = "0.4.19"
|
||||||
|
|
@ -1059,6 +1065,7 @@ dependencies = [
|
||||||
"log-server",
|
"log-server",
|
||||||
"num-derive",
|
"num-derive",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
|
"qrcode",
|
||||||
"rkyv",
|
"rkyv",
|
||||||
"susres",
|
"susres",
|
||||||
"ticktimer-server",
|
"ticktimer-server",
|
||||||
|
|
@ -1944,6 +1951,15 @@ dependencies = [
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "qrcode"
|
||||||
|
version = "0.12.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "16d2f1455f3630c6e5107b4f2b94e74d76dea80736de0981fd27644216cff57f"
|
||||||
|
dependencies = [
|
||||||
|
"checked_int_cast",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quick-error"
|
name = "quick-error"
|
||||||
version = "1.2.3"
|
version = "1.2.3"
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ impl Ball {
|
||||||
keys[0],
|
keys[0],
|
||||||
t!("ballapp.notification_b", xous::LANG),
|
t!("ballapp.notification_b", xous::LANG),
|
||||||
).unwrap();
|
).unwrap();
|
||||||
self.modals.show_notification(¬e).unwrap();
|
self.modals.show_notification(¬e, false).unwrap();
|
||||||
self.modals.add_list_item(t!("ballapp.random", xous::LANG)).unwrap();
|
self.modals.add_list_item(t!("ballapp.random", xous::LANG)).unwrap();
|
||||||
self.modals.add_list_item(t!("ballapp.tilt", xous::LANG)).unwrap();
|
self.modals.add_list_item(t!("ballapp.tilt", xous::LANG)).unwrap();
|
||||||
let mode = self.modals.get_radiobutton(t!("ballapp.mode_prompt", xous::LANG)).unwrap();
|
let mode = self.modals.get_radiobutton(t!("ballapp.mode_prompt", xous::LANG)).unwrap();
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,9 @@ It implements the basic envisioned structure of a Xous application, namely:
|
||||||
- Text input comes via the `ime-frontend`
|
- Text input comes via the `ime-frontend`
|
||||||
- Graphical output is rendered via the `gam`
|
- Graphical output is rendered via the `gam`
|
||||||
|
|
||||||
|
[Push Events and Listeners](../../wiki/Push-Events-and-Listeners) provides an overview of the flow of
|
||||||
|
messages between an Xous application and the Xous Services.
|
||||||
|
|
||||||
The one demo command provisioned in the `repl` app plays a tone via
|
The one demo command provisioned in the `repl` app plays a tone via
|
||||||
the `codec` service. This was chosen because it is about one of the most complicated
|
the `codec` service. This was chosen because it is about one of the most complicated
|
||||||
and comprehensive things you can do in the `repl` environment, as it requires
|
and comprehensive things you can do in the `repl` environment, as it requires
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ Platonic is an ideal system useful for developing an operating system. It does
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
For emulation, you will need to install Renode. Then, run `renode` on `xous-release.resc`. For example:
|
For emulation, you will need to install Renode (use the [nightly](https://dl.antmicro.com/projects/renode/builds/) to get `SPI.NORFlash` peripheral support). Then, run `renode` on `xous-release.resc`. For example:
|
||||||
|
|
||||||
```
|
```
|
||||||
renode emulation/xous-resc.repl
|
renode emulation/xous-resc.repl
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,8 @@ locales = {path = "../../locales"}
|
||||||
|
|
||||||
tts-frontend = {path="../tts"}
|
tts-frontend = {path="../tts"}
|
||||||
|
|
||||||
|
qrcode = { version = "0.12", default-features = false }
|
||||||
|
|
||||||
[target.'cfg(not(any(windows,unix)))'.dependencies]
|
[target.'cfg(not(any(windows,unix)))'.dependencies]
|
||||||
utralib = {path = "../../utralib"}
|
utralib = {path = "../../utralib"}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,19 @@ use graphics_server::api::*;
|
||||||
use locales::t;
|
use locales::t;
|
||||||
use core::fmt::Write;
|
use core::fmt::Write;
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
use qrcode::{Color, QrCode};
|
||||||
|
use std::convert::TryInto;
|
||||||
|
|
||||||
|
pub(crate) const QUIET_MODULES: i16 = 2;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct Notification {
|
pub struct Notification {
|
||||||
pub action_conn: xous::CID,
|
pub action_conn: xous::CID,
|
||||||
pub action_opcode: u32,
|
pub action_opcode: u32,
|
||||||
pub is_password: bool,
|
pub is_password: bool,
|
||||||
pub manual_dismiss: bool,
|
pub manual_dismiss: bool,
|
||||||
|
pub qrcode: Vec<bool>,
|
||||||
|
pub qrwidth: usize,
|
||||||
}
|
}
|
||||||
impl Notification {
|
impl Notification {
|
||||||
pub fn new(action_conn: xous::CID, action_opcode: u32) -> Self {
|
pub fn new(action_conn: xous::CID, action_opcode: u32) -> Self {
|
||||||
|
|
@ -19,6 +26,8 @@ impl Notification {
|
||||||
action_opcode,
|
action_opcode,
|
||||||
is_password: false,
|
is_password: false,
|
||||||
manual_dismiss: true,
|
manual_dismiss: true,
|
||||||
|
qrcode: Vec::new(),
|
||||||
|
qrwidth: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn set_is_password(&mut self, setting: bool) {
|
pub fn set_is_password(&mut self, setting: bool) {
|
||||||
|
|
@ -30,37 +39,48 @@ impl Notification {
|
||||||
pub fn set_manual_dismiss(&mut self, setting: bool) {
|
pub fn set_manual_dismiss(&mut self, setting: bool) {
|
||||||
self.manual_dismiss = setting;
|
self.manual_dismiss = setting;
|
||||||
}
|
}
|
||||||
}
|
pub fn set_as_qrcode(&mut self, setting: Option<&str>) {
|
||||||
impl ActionApi for Notification {
|
match setting {
|
||||||
fn set_action_opcode(&mut self, op: u32) {self.action_opcode = op}
|
Some(setting) => {
|
||||||
fn height(&self, glyph_height: i16, margin: i16) -> i16 {
|
let qrcode = QrCode::new(setting).unwrap();
|
||||||
if self.manual_dismiss {
|
self.qrwidth = qrcode.width();
|
||||||
glyph_height + margin * 2 + 5
|
self.qrcode = Vec::new();
|
||||||
} else {
|
for color in qrcode.to_colors().iter() {
|
||||||
margin + 5
|
match color {
|
||||||
|
Color::Dark => self.qrcode.push(true),
|
||||||
|
Color::Light => self.qrcode.push(false),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn redraw(&self, at_height: i16, modal: &Modal) {
|
},
|
||||||
if self.manual_dismiss {
|
None => {
|
||||||
|
self.qrcode = Vec::new();
|
||||||
|
self.qrwidth = 0;
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn draw_text(&self, at_height: i16, modal: &Modal) {
|
||||||
// prime a textview with the correct general style parameters
|
// prime a textview with the correct general style parameters
|
||||||
let mut tv = TextView::new(
|
let mut tv = TextView::new(
|
||||||
modal.canvas,
|
modal.canvas,
|
||||||
TextBounds::BoundingBox(Rectangle::new_coords(0, 0, 1, 1))
|
TextBounds::BoundingBox(Rectangle::new_coords(0, 0, 1, 1)),
|
||||||
);
|
);
|
||||||
tv.ellipsis = true;
|
tv.ellipsis = true;
|
||||||
tv.style = modal.style;
|
tv.style = modal.style;
|
||||||
tv.invert = self.is_password;
|
tv.invert = self.is_password;
|
||||||
tv.draw_border= false;
|
tv.draw_border = false;
|
||||||
tv.margin = Point::new(0, 0,);
|
tv.margin = Point::new(0, 0);
|
||||||
tv.insertion = None;
|
tv.insertion = None;
|
||||||
|
|
||||||
tv.bounds_computed = None;
|
tv.bounds_computed = None;
|
||||||
tv.bounds_hint = TextBounds::GrowableFromTl(
|
tv.bounds_hint = TextBounds::GrowableFromTl(
|
||||||
Point::new(modal.margin, at_height + modal.margin * 2),
|
Point::new(modal.margin, at_height + modal.margin * 2),
|
||||||
(modal.canvas_width - modal.margin * 2) as u16
|
(modal.canvas_width - modal.margin * 2) as u16,
|
||||||
);
|
);
|
||||||
write!(tv, "{}", t!("notification.dismiss", xous::LANG)).unwrap();
|
write!(tv, "{}", t!("notification.dismiss", xous::LANG)).unwrap();
|
||||||
modal.gam.bounds_compute_textview(&mut tv).expect("couldn't simulate text size");
|
modal
|
||||||
|
.gam
|
||||||
|
.bounds_compute_textview(&mut tv)
|
||||||
|
.expect("couldn't simulate text size");
|
||||||
let textwidth = if let Some(bounds) = tv.bounds_computed {
|
let textwidth = if let Some(bounds) = tv.bounds_computed {
|
||||||
bounds.br.x - bounds.tl.x
|
bounds.br.x - bounds.tl.x
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -70,9 +90,68 @@ impl ActionApi for Notification {
|
||||||
tv.bounds_computed = None;
|
tv.bounds_computed = None;
|
||||||
tv.bounds_hint = TextBounds::BoundingBox(Rectangle::new(
|
tv.bounds_hint = TextBounds::BoundingBox(Rectangle::new(
|
||||||
Point::new(offset, at_height + modal.margin * 2),
|
Point::new(offset, at_height + modal.margin * 2),
|
||||||
Point::new(modal.canvas_width - modal.margin, at_height + modal.line_height + modal.margin * 2)
|
Point::new(
|
||||||
|
modal.canvas_width - modal.margin,
|
||||||
|
at_height + modal.line_height + modal.margin * 2,
|
||||||
|
),
|
||||||
));
|
));
|
||||||
modal.gam.post_textview(&mut tv).expect("couldn't post tv");
|
modal.gam.post_textview(&mut tv).expect("couldn't post tv");
|
||||||
|
}
|
||||||
|
fn draw_qrcode(&self, at_height: i16, modal: &Modal) {
|
||||||
|
// calculate pixel size of each module in the qrcode
|
||||||
|
let qrcode_modules: i16 = self.qrwidth.try_into().unwrap();
|
||||||
|
let modules: i16 = qrcode_modules + 2 * QUIET_MODULES;
|
||||||
|
let canvas_width = modal.canvas_width - 2 * modal.margin;
|
||||||
|
let mod_size_px: i16 = canvas_width / modules;
|
||||||
|
let qrcode_width_px = qrcode_modules * mod_size_px;
|
||||||
|
let quiet_px: i16 = (canvas_width - qrcode_width_px) / 2;
|
||||||
|
|
||||||
|
// Iterate thru qrcode and draw each module as a rectangle (square)
|
||||||
|
let black = DrawStyle::new(PixelColor::Dark, PixelColor::Dark, 1);
|
||||||
|
let top = at_height + 4 * modal.margin + quiet_px;
|
||||||
|
let left = modal.margin + quiet_px;
|
||||||
|
let mut top_left;
|
||||||
|
let mut bot_right;
|
||||||
|
let mut x: i16;
|
||||||
|
let mut y: i16;
|
||||||
|
let mut j: i16;
|
||||||
|
for (i, module) in self.qrcode.iter().enumerate() {
|
||||||
|
j = i.try_into().unwrap();
|
||||||
|
x = left + (j % qrcode_modules) * mod_size_px;
|
||||||
|
y = top + (j / qrcode_modules) * mod_size_px;
|
||||||
|
if *module {
|
||||||
|
top_left = Point::new(x, y);
|
||||||
|
bot_right = Point::new(x + mod_size_px, y + mod_size_px);
|
||||||
|
modal
|
||||||
|
.gam
|
||||||
|
.draw_rectangle(
|
||||||
|
modal.canvas,
|
||||||
|
Rectangle::new_with_style(top_left, bot_right, black),
|
||||||
|
)
|
||||||
|
.expect("couldn't draw qrcode module");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl ActionApi for Notification {
|
||||||
|
fn set_action_opcode(&mut self, op: u32) {
|
||||||
|
self.action_opcode = op
|
||||||
|
}
|
||||||
|
fn height(&self, glyph_height: i16, margin: i16) -> i16 {
|
||||||
|
if self.manual_dismiss {
|
||||||
|
let qr_height = if self.qrwidth > 0 { 300 } else { 0 };
|
||||||
|
glyph_height + margin * 2 + 5 + qr_height
|
||||||
|
} else {
|
||||||
|
margin + 5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn redraw(&self, at_height: i16, modal: &Modal) {
|
||||||
|
if self.manual_dismiss {
|
||||||
|
self.draw_text(at_height, modal);
|
||||||
|
|
||||||
|
if self.qrwidth > 0 {
|
||||||
|
self.draw_qrcode(at_height, modal);
|
||||||
|
}
|
||||||
|
|
||||||
// divider lines
|
// divider lines
|
||||||
let color = if self.is_password {
|
let color = if self.is_password {
|
||||||
|
|
@ -81,11 +160,17 @@ impl ActionApi for Notification {
|
||||||
PixelColor::Dark
|
PixelColor::Dark
|
||||||
};
|
};
|
||||||
|
|
||||||
modal.gam.draw_line(modal.canvas, Line::new_with_style(
|
modal
|
||||||
|
.gam
|
||||||
|
.draw_line(
|
||||||
|
modal.canvas,
|
||||||
|
Line::new_with_style(
|
||||||
Point::new(modal.margin, at_height + modal.margin),
|
Point::new(modal.margin, at_height + modal.margin),
|
||||||
Point::new(modal.canvas_width - modal.margin, at_height + modal.margin),
|
Point::new(modal.canvas_width - modal.margin, at_height + modal.margin),
|
||||||
DrawStyle::new(color, color, 1))
|
DrawStyle::new(color, color, 1),
|
||||||
).expect("couldn't draw entry line");
|
),
|
||||||
|
)
|
||||||
|
.expect("couldn't draw entry line");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn key_action(&mut self, k: char) -> (Option<ValidatorErr>, bool) {
|
fn key_action(&mut self, k: char) -> (Option<ValidatorErr>, bool) {
|
||||||
|
|
@ -96,8 +181,12 @@ impl ActionApi for Notification {
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
if self.manual_dismiss {
|
if self.manual_dismiss {
|
||||||
send_message(self.action_conn, xous::Message::new_scalar(self.action_opcode as usize, 0, 0, 0, 0)).expect("couldn't pass on dismissal");
|
send_message(
|
||||||
return(None, true)
|
self.action_conn,
|
||||||
|
xous::Message::new_scalar(self.action_opcode as usize, 0, 0, 0, 0),
|
||||||
|
)
|
||||||
|
.expect("couldn't pass on dismissal");
|
||||||
|
return (None, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,27 @@ impl XousDisplay {
|
||||||
display
|
display
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// This should only be called to initialize the panic handler with its own
|
||||||
|
/// copy of hardware registers.
|
||||||
|
///
|
||||||
|
/// # Safety
|
||||||
|
///
|
||||||
|
/// The addresses of these structures are passed as `u32` and unsafely cast back
|
||||||
|
/// into pointers on the user's side. We do this because the panic handler is special:
|
||||||
|
/// it grabs ahold of the low-level hardware, yanking control from the higher level
|
||||||
|
/// control functons, without having to map its own separate pages.
|
||||||
|
///
|
||||||
|
/// Of course, "anyone" with a copy of this data can clobber existing graphics operations. Thus,
|
||||||
|
/// any access to these registers have to be protected with a mutex of some form. In the case of
|
||||||
|
/// the panic handler, the `is_panic` `AtomicBool` will suppress graphics loop operation
|
||||||
|
/// in the case of a panic.
|
||||||
|
pub unsafe fn hw_regs(&self) -> (u32, u32) {
|
||||||
|
(
|
||||||
|
self.hwfb.as_mut_ptr() as u32,
|
||||||
|
self.csr.base as u32
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn suspend(&mut self) {
|
pub fn suspend(&mut self) {
|
||||||
while self.busy() {
|
while self.busy() {
|
||||||
// just wait until any pending FB operations are done
|
// just wait until any pending FB operations are done
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,12 @@ use xous_ipc::Buffer;
|
||||||
mod fontmap;
|
mod fontmap;
|
||||||
use api::BulkRead;
|
use api::BulkRead;
|
||||||
|
|
||||||
|
#[cfg(any(target_os = "none", target_os = "xous"))] // only install for hardware targets; hosted mode uses host's panic handler
|
||||||
|
mod panic;
|
||||||
|
|
||||||
|
use core::sync::atomic::{AtomicBool, Ordering};
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::wordwrap::*;
|
use crate::wordwrap::*;
|
||||||
use core::ops::Add;
|
use core::ops::Add;
|
||||||
|
|
||||||
|
|
@ -65,7 +71,6 @@ fn map_fonts() -> MemoryRange {
|
||||||
"mapping regular font to 0x{:08x}",
|
"mapping regular font to 0x{:08x}",
|
||||||
fontregion.as_ptr() as usize + fontmap::REGULAR_OFFSET as usize
|
fontregion.as_ptr() as usize + fontmap::REGULAR_OFFSET as usize
|
||||||
);
|
);
|
||||||
use core::sync::atomic::Ordering;
|
|
||||||
blitstr2::fonts::bold::GLYPH_LOCATION.store((fontregion.as_ptr() as usize + fontmap::BOLD_OFFSET as usize) as u32, Ordering::SeqCst);
|
blitstr2::fonts::bold::GLYPH_LOCATION.store((fontregion.as_ptr() as usize + fontmap::BOLD_OFFSET as usize) as u32, Ordering::SeqCst);
|
||||||
blitstr2::fonts::emoji::GLYPH_LOCATION.store((fontregion.as_ptr() as usize + fontmap::EMOJI_OFFSET as usize) as u32, Ordering::SeqCst);
|
blitstr2::fonts::emoji::GLYPH_LOCATION.store((fontregion.as_ptr() as usize + fontmap::EMOJI_OFFSET as usize) as u32, Ordering::SeqCst);
|
||||||
blitstr2::fonts::ja::GLYPH_LOCATION.store((fontregion.as_ptr() as usize + fontmap::JA_OFFSET as usize) as u32, Ordering::SeqCst);
|
blitstr2::fonts::ja::GLYPH_LOCATION.store((fontregion.as_ptr() as usize + fontmap::JA_OFFSET as usize) as u32, Ordering::SeqCst);
|
||||||
|
|
@ -94,6 +99,21 @@ fn xmain() -> ! {
|
||||||
log::set_max_level(log::LevelFilter::Info);
|
log::set_max_level(log::LevelFilter::Info);
|
||||||
log::info!("my PID is {}", xous::process::id());
|
log::info!("my PID is {}", xous::process::id());
|
||||||
|
|
||||||
|
let mut display = XousDisplay::new();
|
||||||
|
let fontregion = map_fonts();
|
||||||
|
|
||||||
|
// install the graphical panic handler. It won't catch really early panics, or panics in this crate,
|
||||||
|
// but it'll do the job 90% of the time and it's way better than having none at all.
|
||||||
|
let is_panic = Arc::new(AtomicBool::new(false));
|
||||||
|
#[cfg(any(target_os = "none", target_os = "xous"))] // only install for hardware targets; hosted mode uses host's panic handler
|
||||||
|
{
|
||||||
|
let (hwfb, control) = unsafe{
|
||||||
|
// this is safe because we are extracting these for use in a Mutex-protected panic handler
|
||||||
|
display.hw_regs()
|
||||||
|
};
|
||||||
|
panic::panic_handler_thread(is_panic.clone(), hwfb, control);
|
||||||
|
}
|
||||||
|
|
||||||
let xns = xous_names::XousNames::new().unwrap();
|
let xns = xous_names::XousNames::new().unwrap();
|
||||||
// these connections should be established:
|
// these connections should be established:
|
||||||
// - GAM
|
// - GAM
|
||||||
|
|
@ -102,15 +122,8 @@ fn xmain() -> ! {
|
||||||
.register_name(api::SERVER_NAME_GFX, Some(2))
|
.register_name(api::SERVER_NAME_GFX, Some(2))
|
||||||
.expect("can't register server");
|
.expect("can't register server");
|
||||||
|
|
||||||
// Create a new monochrome simulator display.
|
|
||||||
let mut display = XousDisplay::new();
|
|
||||||
//let mut fb = display.native_buffer();
|
|
||||||
//let mut b2cursor = blitstr2::Cursor::new(0, 0, 16);
|
|
||||||
//blitstr2::paint_str(&mut fb, blitstr2::ClipRect::new(0, 0, 100, 100), &mut b2cursor, "test");
|
|
||||||
|
|
||||||
draw_boot_logo(&mut display);
|
draw_boot_logo(&mut display);
|
||||||
|
|
||||||
let fontregion = map_fonts();
|
|
||||||
let screen_clip = Rectangle::new(Point::new(0, 0), display.screen_size());
|
let screen_clip = Rectangle::new(Point::new(0, 0), display.screen_size());
|
||||||
|
|
||||||
display.redraw();
|
display.redraw();
|
||||||
|
|
@ -122,9 +135,12 @@ fn xmain() -> ! {
|
||||||
|
|
||||||
let mut bulkread = BulkRead::default(); // holding buffer for bulk reads; wastes ~8k when not in use, but saves a lot of copy/init for each iteration of the read
|
let mut bulkread = BulkRead::default(); // holding buffer for bulk reads; wastes ~8k when not in use, but saves a lot of copy/init for each iteration of the read
|
||||||
|
|
||||||
|
let ticktimer = ticktimer_server::Ticktimer::new().unwrap();
|
||||||
|
|
||||||
#[cfg(feature = "testing")]
|
#[cfg(feature = "testing")]
|
||||||
testing::tests();
|
testing::tests();
|
||||||
loop {
|
loop {
|
||||||
|
if !is_panic.load(Ordering::Relaxed) { // non-panic graphics operations if we are in a panic situation
|
||||||
let mut msg = xous::receive_message(sid).unwrap();
|
let mut msg = xous::receive_message(sid).unwrap();
|
||||||
log::trace!("Message: {:?}", msg);
|
log::trace!("Message: {:?}", msg);
|
||||||
match FromPrimitive::from_usize(msg.body.id()) {
|
match FromPrimitive::from_usize(msg.body.id()) {
|
||||||
|
|
@ -442,7 +458,6 @@ fn xmain() -> ! {
|
||||||
stash[lines * backend::FB_WIDTH_WORDS + (backend::FB_WIDTH_WORDS - 1)] |= 0x1_0000;
|
stash[lines * backend::FB_WIDTH_WORDS + (backend::FB_WIDTH_WORDS - 1)] |= 0x1_0000;
|
||||||
}
|
}
|
||||||
|
|
||||||
let ticktimer = ticktimer_server::Ticktimer::new().unwrap();
|
|
||||||
let start_time = ticktimer.elapsed_ms();
|
let start_time = ticktimer.elapsed_ms();
|
||||||
let mut testmem = xous::syscall::map_memory(
|
let mut testmem = xous::syscall::map_memory(
|
||||||
None,
|
None,
|
||||||
|
|
@ -537,6 +552,10 @@ fn xmain() -> ! {
|
||||||
log::error!("received opcode scalar that is not handled");
|
log::error!("received opcode scalar that is not handled");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// this is effectively an abort, because this is long enough for the WDT to fire and reboot the system
|
||||||
|
ticktimer.sleep_ms(10_000).unwrap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
log::trace!("main loop exit, destroying servers");
|
log::trace!("main loop exit, destroying servers");
|
||||||
xns.unregister_server(sid).unwrap();
|
xns.unregister_server(sid).unwrap();
|
||||||
|
|
|
||||||
236
services/graphics-server/src/panic.rs
Normal file
236
services/graphics-server/src/panic.rs
Normal file
|
|
@ -0,0 +1,236 @@
|
||||||
|
use std::thread;
|
||||||
|
use core::sync::atomic::{AtomicBool, Ordering};
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use utralib::generated::*;
|
||||||
|
|
||||||
|
const PANIC_STD_SERVER: &[u8; 16] = b"panic-to-screen!";
|
||||||
|
|
||||||
|
/// We can have no allocations inside this, and ideally, it's as minimal as possible.
|
||||||
|
///
|
||||||
|
/// The graphics handler code and font renderer code are duplicated into this module to
|
||||||
|
/// minimize cross-thread dependencies.
|
||||||
|
///
|
||||||
|
/// Some simplifying assumptions include:
|
||||||
|
/// - Only Latin, monospace (16-px wide) characters from the `mono` font set.
|
||||||
|
/// - Panics occupy a fixed area in the center of the screen, that can only hold
|
||||||
|
/// a limited amount of text: 304-px x 384-px text area = 40 char x 24 lines = 960 chars
|
||||||
|
/// - The Panic frame is slightly larger to give a cosmetic border
|
||||||
|
/// - Panics are black background with white text to distinguish them as secured system messages.
|
||||||
|
/// - Panics can't be dismissed, and should persist even if other threads are capable of running.
|
||||||
|
/// - The Panic handler can conflict with the regular display routines because it unsafely
|
||||||
|
/// creates a copy of all the hardware access structures. Thus there is a variable
|
||||||
|
/// shared with the parent thread to stop redraws permanently in the case of a panic.
|
||||||
|
///
|
||||||
|
/// Note that the frame buffer is 336 px wide, which is 10.5 32-bit words.
|
||||||
|
/// The excess 16 bits are the dirty bit field.
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
backend::{FB_WIDTH_PIXELS, FB_WIDTH_WORDS, FB_SIZE},
|
||||||
|
api::{PixelColor, GlyphSprite}, blitstr2::NULL_GLYPH_SPRITE
|
||||||
|
};
|
||||||
|
/// How far down the screen the panic box draws
|
||||||
|
const TOP_OFFSET: usize = 48;
|
||||||
|
/// Width and height of the panic box in characters
|
||||||
|
const WIDTH_CHARS: usize = 40;
|
||||||
|
const HEIGHT_CHARS: usize = 24;
|
||||||
|
/// these are fixed by the monospace font
|
||||||
|
const GLYPH_HEIGHT: usize = 15;
|
||||||
|
const GLYPH_WIDTH: usize = 7;
|
||||||
|
/// this can be adjusted to create more border around the panic box
|
||||||
|
const TEXT_MARGIN: usize = 8;
|
||||||
|
|
||||||
|
/// some derived constants to help with layout
|
||||||
|
const BOTTOM_LINE: usize = TOP_OFFSET + HEIGHT_CHARS * GLYPH_HEIGHT + TEXT_MARGIN * 2;
|
||||||
|
const LEFT_EDGE: usize = (FB_WIDTH_PIXELS - (WIDTH_CHARS * GLYPH_WIDTH + TEXT_MARGIN * 2)) / 2; // 24
|
||||||
|
const RIGHT_EDGE: usize = FB_WIDTH_PIXELS - LEFT_EDGE; // 312
|
||||||
|
|
||||||
|
pub(crate) fn panic_handler_thread(
|
||||||
|
is_panic: Arc::<AtomicBool>,
|
||||||
|
hwfb: u32,
|
||||||
|
control: u32,
|
||||||
|
) {
|
||||||
|
thread::spawn({
|
||||||
|
move || {
|
||||||
|
let panic_server = xous::create_server_with_address(PANIC_STD_SERVER)
|
||||||
|
.expect("Couldn't create panic server");
|
||||||
|
|
||||||
|
let mut display = unsafe { PanicDisplay::new(hwfb, control) };
|
||||||
|
loop {
|
||||||
|
let msg = xous::receive_message(panic_server).unwrap();
|
||||||
|
|
||||||
|
// this will put the graphics renderer in panic mode.
|
||||||
|
if !is_panic.load(Ordering::Relaxed) {
|
||||||
|
// this locks out updates from the main loop
|
||||||
|
is_panic.store(true, Ordering::Relaxed);
|
||||||
|
display.panic_rectangle();
|
||||||
|
display.append_string(" ~~Guru Meditation~~\n\n");
|
||||||
|
}
|
||||||
|
let body = match msg.body.memory_message() {
|
||||||
|
Some(body) => body,
|
||||||
|
None => {
|
||||||
|
log::error!("Incorrect message type to panic renderer");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let len = match body.valid {
|
||||||
|
Some(v) => v,
|
||||||
|
None => continue, // ignore, don't fail
|
||||||
|
}.get();
|
||||||
|
let s = unsafe{core::str::from_utf8_unchecked(
|
||||||
|
&body.buf.as_slice()[..len]
|
||||||
|
)};
|
||||||
|
display.append_string(s);
|
||||||
|
display.update_dirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// All-in-one object to manage a framebuffer and layout text.
|
||||||
|
struct PanicDisplay<'a> {
|
||||||
|
/// hardware framebuffer (no double buffering)
|
||||||
|
fb: &'a mut [u32],
|
||||||
|
/// hardware register copy (very dangerous)
|
||||||
|
csr: CSR::<u32>,
|
||||||
|
/// current x/y position of the latest character to add to the panic box
|
||||||
|
x: usize,
|
||||||
|
y: usize,
|
||||||
|
}
|
||||||
|
impl<'a> PanicDisplay<'a> {
|
||||||
|
/// # Safety
|
||||||
|
///
|
||||||
|
/// This function takes "plain old 32-bit numbers" and transforms them
|
||||||
|
/// into hardware pointers to the frame buffer and CSR offsets. It's meant
|
||||||
|
/// to be pared with the `hw_regs` output from the XousDisplay object, and
|
||||||
|
/// there will be frame buffer conflicts unless some kind of mutex is wrapped
|
||||||
|
/// around any other code that might compete for access to these resources.
|
||||||
|
unsafe fn new(raw_fb: u32, control: u32) -> Self {
|
||||||
|
PanicDisplay {
|
||||||
|
fb: core::slice::from_raw_parts_mut(raw_fb as *mut u32, FB_SIZE),
|
||||||
|
csr: CSR::new(control as *mut u32),
|
||||||
|
// initialize to top left of panic box's margin
|
||||||
|
x: TEXT_MARGIN,
|
||||||
|
y: TEXT_MARGIN,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// commits the data in the framebuffer to the screen
|
||||||
|
fn update_dirty(&mut self) {
|
||||||
|
self.csr.wfo(utra::memlcd::COMMAND_UPDATEDIRTY, 1);
|
||||||
|
while self.busy() {}
|
||||||
|
}
|
||||||
|
/// indicates if a commit is in progress
|
||||||
|
fn busy(&self) -> bool {
|
||||||
|
self.csr.rf(utra::memlcd::BUSY_BUSY) == 1
|
||||||
|
}
|
||||||
|
fn put_pixel(&mut self, x: usize, y: usize, color: PixelColor) {
|
||||||
|
if color == PixelColor::Light {
|
||||||
|
self.fb[(x + y * FB_WIDTH_WORDS * 32) / 32] |= 1 << (x % 32)
|
||||||
|
} else {
|
||||||
|
self.fb[(x + y * FB_WIDTH_WORDS * 32) / 32] &= !(1 << (x % 32))
|
||||||
|
}
|
||||||
|
// set the dirty bit on the line that contains the pixel
|
||||||
|
self.fb[y * FB_WIDTH_WORDS + (FB_WIDTH_WORDS - 1)] |= 0x1_0000;
|
||||||
|
}
|
||||||
|
/// draw a black rectangle into which all the characters are placed. This could
|
||||||
|
/// probably be optimized to do its work in words instead of as pixels, but it works.
|
||||||
|
fn panic_rectangle(&mut self) {
|
||||||
|
for y in TOP_OFFSET..BOTTOM_LINE {
|
||||||
|
for x in LEFT_EDGE..RIGHT_EDGE {
|
||||||
|
self.put_pixel(x, y, PixelColor::Dark);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// Blit a glyph
|
||||||
|
/// Examples of word alignment for destination frame buffer:
|
||||||
|
/// 1. Fits in word: xr:1..7 => (data[0].bit_30)->(data[0].bit_26), mask:0x7c00_0000
|
||||||
|
/// 2. Spans words: xr:30..36 => (data[0].bit_01)->(data[1].bit_29), mask:[0x0000_0003,0xe000_000]
|
||||||
|
///
|
||||||
|
/// This is copied out of the blitstr2 module and adapted for the panic handler.
|
||||||
|
///
|
||||||
|
fn draw_glyph(&mut self, x: usize, y: usize, gs: GlyphSprite) {
|
||||||
|
const SPRITE_PX: i16 = 16;
|
||||||
|
const SPRITE_WORDS: i16 = 8;
|
||||||
|
if gs.glyph.len() < SPRITE_WORDS as usize {
|
||||||
|
// Fail silently if the glyph slice was too small
|
||||||
|
// TODO: Maybe return an error? Not sure which way is better.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let high = gs.high as i16;
|
||||||
|
let wide = gs.wide as i16;
|
||||||
|
if high > SPRITE_PX || wide > SPRITE_PX {
|
||||||
|
// Fail silently if glyph height or width is out of spec
|
||||||
|
// TODO: Maybe return an error?
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Calculate word alignment for destination buffer
|
||||||
|
let x0 = (x + LEFT_EDGE) as i16;
|
||||||
|
let x1 = (x + LEFT_EDGE) as i16 + wide - 1;
|
||||||
|
let dest_low_word = x0 >> 5;
|
||||||
|
let dest_high_word = x1 >> 5;
|
||||||
|
let px_in_dest_low_word = 32 - (x0 & 0x1f);
|
||||||
|
// Blit it (use glyph height to avoid blitting empty rows)
|
||||||
|
let mut row_base = (y + TOP_OFFSET) as i16 * FB_WIDTH_WORDS as i16;
|
||||||
|
let row_upper_limit = BOTTOM_LINE as i16 * FB_WIDTH_WORDS as i16;
|
||||||
|
let row_lower_limit = TOP_OFFSET as i16 * FB_WIDTH_WORDS as i16;
|
||||||
|
let glyph = gs.glyph;
|
||||||
|
for y in 0..high as usize {
|
||||||
|
if row_base >= row_upper_limit {
|
||||||
|
// Clip anything that would run off the end of the frame buffer
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if row_base >= row_lower_limit {
|
||||||
|
// Unpack pixels for this glyph row.
|
||||||
|
// CAUTION: some math magic happening here...
|
||||||
|
// when y==0, this does (glyph[0] >> 0) & mask,
|
||||||
|
// when y==1, this does (glyph[0] >> 16) & mask,
|
||||||
|
// when y==2, this does (glyph[1] >> 0) & mask,
|
||||||
|
// ...
|
||||||
|
let mask = 0x0000ffff as u32;
|
||||||
|
let shift = (y as u32 & 1) << 4;
|
||||||
|
let pattern = (glyph[y >> 1] >> shift) & mask;
|
||||||
|
|
||||||
|
// compute partial masks to prevent glyphs from "spilling over" the clip rectangle
|
||||||
|
let mut partial_mask_lo = 0xffff_ffff;
|
||||||
|
let mut partial_mask_hi = 0xffff_ffff;
|
||||||
|
if x0 < LEFT_EDGE as i16 || x1 >= RIGHT_EDGE as i16 {
|
||||||
|
let x0a = if x0 < LEFT_EDGE as i16 { RIGHT_EDGE as i16 } else { x0 };
|
||||||
|
let x1a = if x1 >= LEFT_EDGE as i16 { RIGHT_EDGE as i16 } else { x1 };
|
||||||
|
let mut ones = (1u64 << ((x1a - x0a) as u64 + 1)) - 1;
|
||||||
|
ones <<= x0a as u64 & 0x1f;
|
||||||
|
partial_mask_lo = ones as u32;
|
||||||
|
partial_mask_hi = (ones >> 32) as u32;
|
||||||
|
}
|
||||||
|
// XOR glyph pixels onto destination buffer. Note that despite the masks above, we will not render
|
||||||
|
// partial glyphs that cross the absolute bounds of the left and right edge of the screen.
|
||||||
|
if x0 >= 0 && x1 < FB_WIDTH_PIXELS as i16 {
|
||||||
|
self.fb[(row_base + dest_low_word) as usize] ^= (pattern << (32 - px_in_dest_low_word)) & partial_mask_lo;
|
||||||
|
if wide > px_in_dest_low_word {
|
||||||
|
self.fb[(row_base + dest_high_word) as usize] ^= (pattern >> px_in_dest_low_word) & partial_mask_hi;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.fb[(row_base as usize + FB_WIDTH_WORDS - 1) as usize] |= 0x1_0000; // set the dirty bit on the line
|
||||||
|
}
|
||||||
|
|
||||||
|
// Advance destination offset using + instead of * to maybe save some CPU cycles
|
||||||
|
row_base += FB_WIDTH_WORDS as i16;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// start laying out the string from the top left and just wrap character by character, considering newlines
|
||||||
|
fn append_string(&mut self, s: &str) {
|
||||||
|
for ch in s.chars() {
|
||||||
|
if ch == '\n' {
|
||||||
|
self.y += GLYPH_HEIGHT;
|
||||||
|
self.x = TEXT_MARGIN;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
self.draw_glyph(self.x, self.y, crate::blitstr2::mono_glyph(ch).unwrap_or(NULL_GLYPH_SPRITE));
|
||||||
|
self.x += GLYPH_WIDTH;
|
||||||
|
if self.x >= WIDTH_CHARS * GLYPH_WIDTH {
|
||||||
|
self.x = TEXT_MARGIN;
|
||||||
|
self.y += GLYPH_HEIGHT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -32,6 +32,7 @@ pub struct ManagedPromptWithTextResponse {
|
||||||
pub struct ManagedNotification {
|
pub struct ManagedNotification {
|
||||||
pub token: [u32; 4],
|
pub token: [u32; 4],
|
||||||
pub message: xous_ipc::String::<1024>,
|
pub message: xous_ipc::String::<1024>,
|
||||||
|
pub as_qrcode: bool,
|
||||||
}
|
}
|
||||||
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Copy, Clone)]
|
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Copy, Clone)]
|
||||||
pub struct ManagedProgress {
|
pub struct ManagedProgress {
|
||||||
|
|
@ -80,7 +81,7 @@ pub(crate) enum Opcode {
|
||||||
/// raise a progress bar
|
/// raise a progress bar
|
||||||
StartProgress,
|
StartProgress,
|
||||||
/// update the progress bar
|
/// update the progress bar
|
||||||
UpdateProgress,
|
DoUpdateProgress,
|
||||||
/// lower a progress bar
|
/// lower a progress bar
|
||||||
StopProgress,
|
StopProgress,
|
||||||
/// update a dynamic notification's text
|
/// update a dynamic notification's text
|
||||||
|
|
@ -98,7 +99,6 @@ pub(crate) enum Opcode {
|
||||||
// box because it's a convenience routine used by "everyone"; password boxes are always handled within
|
// box because it's a convenience routine used by "everyone"; password boxes are always handled within
|
||||||
// a given secured server so that the attack surface for these do not extend into the modals boundary.
|
// a given secured server so that the attack surface for these do not extend into the modals boundary.
|
||||||
InitiateOp,
|
InitiateOp,
|
||||||
DoUpdateProgress,
|
|
||||||
FinishProgress,
|
FinishProgress,
|
||||||
|
|
||||||
TextEntryReturn,
|
TextEntryReturn,
|
||||||
|
|
|
||||||
|
|
@ -80,11 +80,12 @@ impl Modals {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// this blocks until the notification has been acknowledged.
|
/// this blocks until the notification has been acknowledged.
|
||||||
pub fn show_notification(&self, notification: &str) -> Result<(), xous::Error> {
|
pub fn show_notification(&self, notification: &str, as_qrcode: bool) -> Result<(), xous::Error> {
|
||||||
self.lock();
|
self.lock();
|
||||||
let spec = ManagedNotification {
|
let spec = ManagedNotification {
|
||||||
token: self.token,
|
token: self.token,
|
||||||
message: xous_ipc::String::from_str(notification),
|
message: xous_ipc::String::from_str(notification),
|
||||||
|
as_qrcode,
|
||||||
};
|
};
|
||||||
let buf = Buffer::into_buf(spec).or(Err(xous::Error::InternalError))?;
|
let buf = Buffer::into_buf(spec).or(Err(xous::Error::InternalError))?;
|
||||||
buf.lend(self.conn, Opcode::Notification.to_u32().unwrap()).or(Err(xous::Error::InternalError))?;
|
buf.lend(self.conn, Opcode::Notification.to_u32().unwrap()).or(Err(xous::Error::InternalError))?;
|
||||||
|
|
@ -110,9 +111,17 @@ impl Modals {
|
||||||
/// but, progress updates are meant to be fast and frequent, and generally if a progress bar shows
|
/// but, progress updates are meant to be fast and frequent, and generally if a progress bar shows
|
||||||
/// something whacky it's not going to affect a security outcome
|
/// something whacky it's not going to affect a security outcome
|
||||||
pub fn update_progress(&self, current: u32) -> Result<(), xous::Error> {
|
pub fn update_progress(&self, current: u32) -> Result<(), xous::Error> {
|
||||||
send_message(self.conn,
|
match xous::try_send_message(self.conn,
|
||||||
Message::new_scalar(Opcode::UpdateProgress.to_usize().unwrap(), current as usize, 0, 0, 0)
|
Message::new_scalar(Opcode::DoUpdateProgress.to_usize().unwrap(), current as usize, 0, 0, 0)
|
||||||
).expect("couldn't update progress");
|
) {
|
||||||
|
Ok(_) => (),
|
||||||
|
Err(e) => {
|
||||||
|
log::warn!("update_progress failed with {:?}, skipping request", e);
|
||||||
|
// most likely issue is that the server queue is overfull because too many progress updates were sent
|
||||||
|
// sleep the sending thread to rate-limit requests, while discarding the current request.
|
||||||
|
xous::yield_slice()
|
||||||
|
}
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -91,15 +91,6 @@ fn xmain() -> ! {
|
||||||
validator: None,
|
validator: None,
|
||||||
};
|
};
|
||||||
let mut fixed_items = Vec::<ItemName>::new();
|
let mut fixed_items = Vec::<ItemName>::new();
|
||||||
let notification = gam::modal::Notification::new(
|
|
||||||
renderer_cid,
|
|
||||||
Opcode::NotificationReturn.to_u32().unwrap()
|
|
||||||
);
|
|
||||||
let mut gutter = gam::modal::Notification::new(
|
|
||||||
renderer_cid,
|
|
||||||
Opcode::Gutter.to_u32().unwrap()
|
|
||||||
);
|
|
||||||
gutter.set_manual_dismiss(false);
|
|
||||||
let mut progress_action = Slider::new(renderer_cid, Opcode::Gutter.to_u32().unwrap(),
|
let mut progress_action = Slider::new(renderer_cid, Opcode::Gutter.to_u32().unwrap(),
|
||||||
0, 100, 1, Some("%"), 0, true, true
|
0, 100, 1, Some("%"), 0, true, true
|
||||||
);
|
);
|
||||||
|
|
@ -233,12 +224,6 @@ fn xmain() -> ! {
|
||||||
Message::new_scalar(Opcode::InitiateOp.to_usize().unwrap(), 0, 0, 0, 0)
|
Message::new_scalar(Opcode::InitiateOp.to_usize().unwrap(), 0, 0, 0, 0)
|
||||||
).expect("couldn't initiate UX op");
|
).expect("couldn't initiate UX op");
|
||||||
},
|
},
|
||||||
Some(Opcode::UpdateProgress) => msg_scalar_unpack!(msg, current, _, _, _, {
|
|
||||||
send_message(
|
|
||||||
renderer_cid,
|
|
||||||
Message::new_scalar(Opcode::DoUpdateProgress.to_usize().unwrap(), current, 0, 0, 0)
|
|
||||||
).expect("couldn't update progress bar");
|
|
||||||
}),
|
|
||||||
Some(Opcode::StopProgress) => msg_scalar_unpack!(msg, t0, t1, t2, t3, {
|
Some(Opcode::StopProgress) => msg_scalar_unpack!(msg, t0, t1, t2, t3, {
|
||||||
let token = [t0 as u32, t1 as u32, t2 as u32, t3 as u32];
|
let token = [t0 as u32, t1 as u32, t2 as u32, t3 as u32];
|
||||||
if token != token_lock.unwrap_or(default_nonce) {
|
if token != token_lock.unwrap_or(default_nonce) {
|
||||||
|
|
@ -298,6 +283,30 @@ fn xmain() -> ! {
|
||||||
Message::new_scalar(Opcode::DoCloseDynamicNotification.to_usize().unwrap(), 0, 0, 0, 0)
|
Message::new_scalar(Opcode::DoCloseDynamicNotification.to_usize().unwrap(), 0, 0, 0, 0)
|
||||||
).expect("couldn't close dynamic notification");
|
).expect("couldn't close dynamic notification");
|
||||||
}),
|
}),
|
||||||
|
// this got promoted to an external API during the deferred response refactor to eliminate an intermediate state
|
||||||
|
Some(Opcode::DoUpdateProgress) => msg_scalar_unpack!(msg, current, _, _, _, {
|
||||||
|
let new_percentage = compute_checked_percentage(
|
||||||
|
current as u32, start_work, end_work);
|
||||||
|
log::trace!("percentage: {}, current: {}, start: {}, end: {}", new_percentage, current, start_work, end_work);
|
||||||
|
if new_percentage != last_percentage {
|
||||||
|
last_percentage = new_percentage;
|
||||||
|
progress_action.set_state(last_percentage);
|
||||||
|
#[cfg(feature="tts")]
|
||||||
|
{
|
||||||
|
if tt.elapsed_ms() - last_tick > TICK_INTERVAL {
|
||||||
|
tts.tts_blocking(t!("progress.increment", xous::LANG)).unwrap();
|
||||||
|
last_tick = tt.elapsed_ms();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
renderer_modal.modify(
|
||||||
|
Some(ActionType::Slider(progress_action)),
|
||||||
|
None, false,
|
||||||
|
None, false, None
|
||||||
|
);
|
||||||
|
renderer_modal.redraw();
|
||||||
|
xous::yield_slice(); // give time for the GAM to redraw
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
|
||||||
// ------------------ INTERNAL APIS --------------------
|
// ------------------ INTERNAL APIS --------------------
|
||||||
Some(Opcode::InitiateOp) => {
|
Some(Opcode::InitiateOp) => {
|
||||||
|
|
@ -316,11 +325,19 @@ fn xmain() -> ! {
|
||||||
log::debug!("should be active!");
|
log::debug!("should be active!");
|
||||||
},
|
},
|
||||||
RendererState::RunNotification(config) => {
|
RendererState::RunNotification(config) => {
|
||||||
|
let mut notification = gam::modal::Notification::new(
|
||||||
|
renderer_cid,
|
||||||
|
Opcode::NotificationReturn.to_u32().unwrap()
|
||||||
|
);
|
||||||
|
let text = config.message.as_str().unwrap();
|
||||||
|
if config.as_qrcode {
|
||||||
|
notification.set_as_qrcode(Some(text));
|
||||||
|
}
|
||||||
#[cfg(feature="tts")]
|
#[cfg(feature="tts")]
|
||||||
tts.tts_simple(config.message.as_str().unwrap()).unwrap();
|
tts.tts_simple(config.message.as_str().unwrap()).unwrap();
|
||||||
renderer_modal.modify(
|
renderer_modal.modify(
|
||||||
Some(ActionType::Notification(notification)),
|
Some(ActionType::Notification(notification)),
|
||||||
Some(config.message.as_str().unwrap()), false,
|
Some(text), false,
|
||||||
None, true, None
|
None, true, None
|
||||||
);
|
);
|
||||||
renderer_modal.activate();
|
renderer_modal.activate();
|
||||||
|
|
@ -396,6 +413,11 @@ fn xmain() -> ! {
|
||||||
tts.tts_simple(text.as_str().unwrap()).unwrap();
|
tts.tts_simple(text.as_str().unwrap()).unwrap();
|
||||||
bot_text.push_str(text.as_str().unwrap());
|
bot_text.push_str(text.as_str().unwrap());
|
||||||
}
|
}
|
||||||
|
let mut gutter = gam::modal::Notification::new(
|
||||||
|
renderer_cid,
|
||||||
|
Opcode::Gutter.to_u32().unwrap()
|
||||||
|
);
|
||||||
|
gutter.set_manual_dismiss(false);
|
||||||
renderer_modal.modify(
|
renderer_modal.modify(
|
||||||
Some(ActionType::Notification(gutter)),
|
Some(ActionType::Notification(gutter)),
|
||||||
Some(&top_text), config.title.is_none(),
|
Some(&top_text), config.title.is_none(),
|
||||||
|
|
@ -410,29 +432,6 @@ fn xmain() -> ! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Some(Opcode::DoUpdateProgress) => msg_scalar_unpack!(msg, current, _, _, _, {
|
|
||||||
let new_percentage = compute_checked_percentage(
|
|
||||||
current as u32, start_work, end_work);
|
|
||||||
log::trace!("percentage: {}, current: {}, start: {}, end: {}", new_percentage, current, start_work, end_work);
|
|
||||||
if new_percentage != last_percentage {
|
|
||||||
last_percentage = new_percentage;
|
|
||||||
progress_action.set_state(last_percentage);
|
|
||||||
#[cfg(feature="tts")]
|
|
||||||
{
|
|
||||||
if tt.elapsed_ms() - last_tick > TICK_INTERVAL {
|
|
||||||
tts.tts_blocking(t!("progress.increment", xous::LANG)).unwrap();
|
|
||||||
last_tick = tt.elapsed_ms();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
renderer_modal.modify(
|
|
||||||
Some(ActionType::Slider(progress_action)),
|
|
||||||
None, false,
|
|
||||||
None, false, None
|
|
||||||
);
|
|
||||||
renderer_modal.redraw();
|
|
||||||
xous::yield_slice(); // give time for the GAM to redraw
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
Some(Opcode::FinishProgress) => {
|
Some(Opcode::FinishProgress) => {
|
||||||
renderer_modal.gam.relinquish_focus().unwrap();
|
renderer_modal.gam.relinquish_focus().unwrap();
|
||||||
op = RendererState::None;
|
op = RendererState::None;
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ pub(crate) fn spawn_test() {
|
||||||
|
|
||||||
// 3. test notificatons
|
// 3. test notificatons
|
||||||
log::info!("testing notification");
|
log::info!("testing notification");
|
||||||
modals.show_notification("This is a test!").expect("notification failed");
|
modals.show_notification("This is a test!", false).expect("notification failed");
|
||||||
log::info!("notification test done");
|
log::info!("notification test done");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -93,8 +93,13 @@ pub(crate) fn spawn_test() {
|
||||||
|
|
||||||
// 3. test notificatons
|
// 3. test notificatons
|
||||||
log::info!("testing notification");
|
log::info!("testing notification");
|
||||||
modals.show_notification("这是一个测验!").expect("notification failed");
|
modals.show_notification("这是一个测验!", true).expect("notification failed");
|
||||||
log::info!("notification test done");
|
log::info!("notification test done");
|
||||||
|
|
||||||
|
// 4. test qrcode
|
||||||
|
log::info!("testing qrcode");
|
||||||
|
modals.show_notification("https://github.com/betrusted-io/xous-core", true).expect("qrcode failed");
|
||||||
|
log::info!("qrcode test done");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ pub(crate) fn connection_manager(sid: xous::SID, activity_interval: Arc<AtomicU3
|
||||||
log::warn!("EC firmware is too old to interoperate with the connec tion manager.");
|
log::warn!("EC firmware is too old to interoperate with the connec tion manager.");
|
||||||
let mut note = String::from(t!("net.ec_rev_old", xous::LANG));
|
let mut note = String::from(t!("net.ec_rev_old", xous::LANG));
|
||||||
note.push_str(&format!("\n\n{}{}.{}.{}+{}", t!("net.ec_current_rev", xous::LANG), maj, min, rev, commits));
|
note.push_str(&format!("\n\n{}{}.{}.{}+{}", t!("net.ec_current_rev", xous::LANG), maj, min, rev, commits));
|
||||||
modals.show_notification(¬e).unwrap();
|
modals.show_notification(¬e, false).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
let run = Arc::new(AtomicBool::new(rev_ok));
|
let run = Arc::new(AtomicBool::new(rev_ok));
|
||||||
|
|
|
||||||
|
|
@ -523,7 +523,7 @@ impl PddbOs {
|
||||||
self.clear_password(); // clear the bad password entry
|
self.clear_password(); // clear the bad password entry
|
||||||
let xns = xous_names::XousNames::new().unwrap();
|
let xns = xous_names::XousNames::new().unwrap();
|
||||||
let modals = modals::Modals::new(&xns).expect("can't connect to Modals server");
|
let modals = modals::Modals::new(&xns).expect("can't connect to Modals server");
|
||||||
modals.show_notification(t!("pddb.badpass_infallible", xous::LANG)).expect("notification failed");
|
modals.show_notification(t!("pddb.badpass_infallible", xous::LANG), false).expect("notification failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1367,7 +1367,7 @@ impl PddbOs {
|
||||||
self.rootkeys.decrypt_block(GenericArray::from_mut_slice(&mut checkblock_a));
|
self.rootkeys.decrypt_block(GenericArray::from_mut_slice(&mut checkblock_a));
|
||||||
|
|
||||||
#[cfg(any(target_os = "none", target_os = "xous"))] // skip this dialog in hosted mode
|
#[cfg(any(target_os = "none", target_os = "xous"))] // skip this dialog in hosted mode
|
||||||
modals.show_notification(t!("pddb.checkpass", xous::LANG)).expect("notification failed");
|
modals.show_notification(t!("pddb.checkpass", xous::LANG), false).expect("notification failed");
|
||||||
|
|
||||||
self.clear_password();
|
self.clear_password();
|
||||||
let mut checkblock_b = [0u8; BLOCK_SIZE];
|
let mut checkblock_b = [0u8; BLOCK_SIZE];
|
||||||
|
|
@ -1376,7 +1376,7 @@ impl PddbOs {
|
||||||
if checkblock_a == checkblock_b {
|
if checkblock_a == checkblock_b {
|
||||||
success = true;
|
success = true;
|
||||||
} else {
|
} else {
|
||||||
modals.show_notification(t!("pddb.checkpass_fail", xous::LANG)).expect("notification failed");
|
modals.show_notification(t!("pddb.checkpass_fail", xous::LANG), false).expect("notification failed");
|
||||||
self.clear_password();
|
self.clear_password();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1132,7 +1132,7 @@ fn xmain() -> ! {
|
||||||
for basis in bases.iter() {
|
for basis in bases.iter() {
|
||||||
note.push_str(basis);
|
note.push_str(basis);
|
||||||
}
|
}
|
||||||
modals.show_notification(¬e).expect("couldn't show basis list");
|
modals.show_notification(¬e, false).expect("couldn't show basis list");
|
||||||
},
|
},
|
||||||
#[cfg(not(any(target_os = "none", target_os = "xous")))]
|
#[cfg(not(any(target_os = "none", target_os = "xous")))]
|
||||||
Some(Opcode::DangerousDebug) => {
|
Some(Opcode::DangerousDebug) => {
|
||||||
|
|
@ -1281,7 +1281,7 @@ fn try_mount_or_format(modals: &modals::Modals, pddb_os: &mut PddbOs, basis_cach
|
||||||
log::error!("Despite formatting, no PDDB was found!");
|
log::error!("Despite formatting, no PDDB was found!");
|
||||||
let mut err = String::from(t!("pddb.internalerror", xous::LANG));
|
let mut err = String::from(t!("pddb.internalerror", xous::LANG));
|
||||||
err.push_str(" #1"); // punt and leave an error code, because this "should" be rare
|
err.push_str(" #1"); // punt and leave an error code, because this "should" be rare
|
||||||
modals.show_notification(err.as_str()).expect("notification failed");
|
modals.show_notification(err.as_str(), false).expect("notification failed");
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1306,7 +1306,7 @@ fn try_mount_or_format(modals: &modals::Modals, pddb_os: &mut PddbOs, basis_cach
|
||||||
log::error!("Despite formatting, no PDDB was found!");
|
log::error!("Despite formatting, no PDDB was found!");
|
||||||
let mut err = String::from(t!("pddb.internalerror", xous::LANG));
|
let mut err = String::from(t!("pddb.internalerror", xous::LANG));
|
||||||
err.push_str(" #1"); // punt and leave an error code, because this "should" be rare
|
err.push_str(" #1"); // punt and leave an error code, because this "should" be rare
|
||||||
modals.show_notification(err.as_str()).expect("notification failed");
|
modals.show_notification(err.as_str(), false).expect("notification failed");
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -463,7 +463,7 @@ fn xmain() -> ! {
|
||||||
// - pepper
|
// - pepper
|
||||||
|
|
||||||
if keys.is_initialized() {
|
if keys.is_initialized() {
|
||||||
modals.show_notification(t!("rootkeys.already_init", xous::LANG)).expect("modals error");
|
modals.show_notification(t!("rootkeys.already_init", xous::LANG), false).expect("modals error");
|
||||||
#[cfg(feature="tts")]
|
#[cfg(feature="tts")]
|
||||||
tts.tts_blocking(t!("rootkeys.already_init", xous::LANG)).unwrap();
|
tts.tts_blocking(t!("rootkeys.already_init", xous::LANG)).unwrap();
|
||||||
keys.set_ux_password_type(None);
|
keys.set_ux_password_type(None);
|
||||||
|
|
@ -552,16 +552,16 @@ fn xmain() -> ! {
|
||||||
).expect("couldn't initiate dialog box");
|
).expect("couldn't initiate dialog box");
|
||||||
}
|
}
|
||||||
Err(RootkeyResult::AlignmentError) => {
|
Err(RootkeyResult::AlignmentError) => {
|
||||||
modals.show_notification(t!("rootkeys.init.fail_alignment", xous::LANG)).expect("modals error");
|
modals.show_notification(t!("rootkeys.init.fail_alignment", xous::LANG), false).expect("modals error");
|
||||||
}
|
}
|
||||||
Err(RootkeyResult::KeyError) => {
|
Err(RootkeyResult::KeyError) => {
|
||||||
modals.show_notification(t!("rootkeys.init.fail_key", xous::LANG)).expect("modals error");
|
modals.show_notification(t!("rootkeys.init.fail_key", xous::LANG), false).expect("modals error");
|
||||||
}
|
}
|
||||||
Err(RootkeyResult::IntegrityError) => {
|
Err(RootkeyResult::IntegrityError) => {
|
||||||
modals.show_notification(t!("rootkeys.init.fail_verify", xous::LANG)).expect("modals error");
|
modals.show_notification(t!("rootkeys.init.fail_verify", xous::LANG), false).expect("modals error");
|
||||||
}
|
}
|
||||||
Err(RootkeyResult::FlashError) => {
|
Err(RootkeyResult::FlashError) => {
|
||||||
modals.show_notification(t!("rootkeys.init.fail_burn", xous::LANG)).expect("modals error");
|
modals.show_notification(t!("rootkeys.init.fail_burn", xous::LANG), false).expect("modals error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -576,7 +576,7 @@ fn xmain() -> ! {
|
||||||
log::info!("Vbus is: {:.3}V", vbus);
|
log::info!("Vbus is: {:.3}V", vbus);
|
||||||
if vbus > 1.5 {
|
if vbus > 1.5 {
|
||||||
// if power is plugged in, request that it be removed
|
// if power is plugged in, request that it be removed
|
||||||
modals.show_notification(t!("rootkeys.init.unplug_power", xous::LANG)).expect("modals error");
|
modals.show_notification(t!("rootkeys.init.unplug_power", xous::LANG), false).expect("modals error");
|
||||||
log::info!("vbus is high, holding off on reboot");
|
log::info!("vbus is high, holding off on reboot");
|
||||||
send_message(main_cid,
|
send_message(main_cid,
|
||||||
xous::Message::new_scalar(Opcode::UxTryReboot.to_usize().unwrap(), 0, 0, 0, 0)
|
xous::Message::new_scalar(Opcode::UxTryReboot.to_usize().unwrap(), 0, 0, 0, 0)
|
||||||
|
|
@ -629,7 +629,7 @@ fn xmain() -> ! {
|
||||||
SignatureResult::DevKeyOk => t!("rootkeys.gwup.viewinfo_dk", xous::LANG),
|
SignatureResult::DevKeyOk => t!("rootkeys.gwup.viewinfo_dk", xous::LANG),
|
||||||
_ => {
|
_ => {
|
||||||
modals.dynamic_notification_close().expect("modals error");
|
modals.dynamic_notification_close().expect("modals error");
|
||||||
modals.show_notification(t!("rootkeys.gwup.no_update_found", xous::LANG)).expect("modals error");
|
modals.show_notification(t!("rootkeys.gwup.no_update_found", xous::LANG), false).expect("modals error");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -659,18 +659,18 @@ fn xmain() -> ! {
|
||||||
match modals.get_radiobutton(prompt) {
|
match modals.get_radiobutton(prompt) {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
if response == t!("rootkeys.gwup.short", xous::LANG) {
|
if response == t!("rootkeys.gwup.short", xous::LANG) {
|
||||||
modals.show_notification(info.as_str()).expect("modals error");
|
modals.show_notification(info.as_str(), false).expect("modals error");
|
||||||
} else if response == t!("rootkeys.gwup.details", xous::LANG) {
|
} else if response == t!("rootkeys.gwup.details", xous::LANG) {
|
||||||
modals.show_notification(info.as_str()).expect("modals error");
|
modals.show_notification(info.as_str(), false).expect("modals error");
|
||||||
let gw_info = keys.fetch_gw_metadata(GatewareRegion::Staging);
|
let gw_info = keys.fetch_gw_metadata(GatewareRegion::Staging);
|
||||||
// truncate the message to better fit in the rendering box
|
// truncate the message to better fit in the rendering box
|
||||||
let info_len = if gw_info.log_len > 256 { 256 } else {gw_info.log_len};
|
let info_len = if gw_info.log_len > 256 { 256 } else {gw_info.log_len};
|
||||||
let info = format!("{}", str::from_utf8(&gw_info.log_str[..info_len as usize]).unwrap());
|
let info = format!("{}", str::from_utf8(&gw_info.log_str[..info_len as usize]).unwrap());
|
||||||
modals.show_notification(info.as_str()).expect("modals error");
|
modals.show_notification(info.as_str(), false).expect("modals error");
|
||||||
// truncate the message to better fit in the rendering box
|
// truncate the message to better fit in the rendering box
|
||||||
let status_len = if gw_info.status_len > 256 { 256 } else {gw_info.status_len};
|
let status_len = if gw_info.status_len > 256 { 256 } else {gw_info.status_len};
|
||||||
let info = format!("{}", str::from_utf8(&gw_info.status_str[..status_len as usize]).unwrap());
|
let info = format!("{}", str::from_utf8(&gw_info.status_str[..status_len as usize]).unwrap());
|
||||||
modals.show_notification(info.as_str()).expect("modals error");
|
modals.show_notification(info.as_str(), false).expect("modals error");
|
||||||
} else {
|
} else {
|
||||||
skip_confirmation = true;
|
skip_confirmation = true;
|
||||||
}
|
}
|
||||||
|
|
@ -760,21 +760,21 @@ fn xmain() -> ! {
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
modals.show_notification(t!("rootkeys.gwup.finished", xous::LANG)).expect("modals error");
|
modals.show_notification(t!("rootkeys.gwup.finished", xous::LANG), false).expect("modals error");
|
||||||
}
|
}
|
||||||
Err(RootkeyResult::AlignmentError) => {
|
Err(RootkeyResult::AlignmentError) => {
|
||||||
modals.show_notification(t!("rootkeys.init.fail_alignment", xous::LANG)).expect("modals error");
|
modals.show_notification(t!("rootkeys.init.fail_alignment", xous::LANG), false).expect("modals error");
|
||||||
}
|
}
|
||||||
Err(RootkeyResult::KeyError) => {
|
Err(RootkeyResult::KeyError) => {
|
||||||
// probably a bad password, purge it, so the user can try again
|
// probably a bad password, purge it, so the user can try again
|
||||||
keys.purge_password(PasswordType::Update);
|
keys.purge_password(PasswordType::Update);
|
||||||
modals.show_notification(t!("rootkeys.init.fail_key", xous::LANG)).expect("modals error");
|
modals.show_notification(t!("rootkeys.init.fail_key", xous::LANG), false).expect("modals error");
|
||||||
}
|
}
|
||||||
Err(RootkeyResult::IntegrityError) => {
|
Err(RootkeyResult::IntegrityError) => {
|
||||||
modals.show_notification(t!("rootkeys.init.fail_verify", xous::LANG)).expect("modals error");
|
modals.show_notification(t!("rootkeys.init.fail_verify", xous::LANG), false).expect("modals error");
|
||||||
}
|
}
|
||||||
Err(RootkeyResult::FlashError) => {
|
Err(RootkeyResult::FlashError) => {
|
||||||
modals.show_notification(t!("rootkeys.init.fail_burn", xous::LANG)).expect("modals error");
|
modals.show_notification(t!("rootkeys.init.fail_burn", xous::LANG), false).expect("modals error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -834,21 +834,21 @@ fn xmain() -> ! {
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
modals.show_notification(t!("rootkeys.signxous.finished", xous::LANG)).expect("modals error");
|
modals.show_notification(t!("rootkeys.signxous.finished", xous::LANG), false).expect("modals error");
|
||||||
}
|
}
|
||||||
Err(RootkeyResult::AlignmentError) => {
|
Err(RootkeyResult::AlignmentError) => {
|
||||||
modals.show_notification(t!("rootkeys.init.fail_alignment", xous::LANG)).expect("modals error");
|
modals.show_notification(t!("rootkeys.init.fail_alignment", xous::LANG), false).expect("modals error");
|
||||||
}
|
}
|
||||||
Err(RootkeyResult::KeyError) => {
|
Err(RootkeyResult::KeyError) => {
|
||||||
// probably a bad password, purge it, so the user can try again
|
// probably a bad password, purge it, so the user can try again
|
||||||
keys.purge_password(PasswordType::Update);
|
keys.purge_password(PasswordType::Update);
|
||||||
modals.show_notification(t!("rootkeys.init.fail_key", xous::LANG)).expect("modals error");
|
modals.show_notification(t!("rootkeys.init.fail_key", xous::LANG), false).expect("modals error");
|
||||||
}
|
}
|
||||||
Err(RootkeyResult::IntegrityError) => {
|
Err(RootkeyResult::IntegrityError) => {
|
||||||
modals.show_notification(t!("rootkeys.init.fail_verify", xous::LANG)).expect("modals error");
|
modals.show_notification(t!("rootkeys.init.fail_verify", xous::LANG), false).expect("modals error");
|
||||||
}
|
}
|
||||||
Err(RootkeyResult::FlashError) => {
|
Err(RootkeyResult::FlashError) => {
|
||||||
modals.show_notification(t!("rootkeys.init.fail_burn", xous::LANG)).expect("modals error");
|
modals.show_notification(t!("rootkeys.init.fail_burn", xous::LANG), false).expect("modals error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -885,7 +885,7 @@ fn xmain() -> ! {
|
||||||
// more keys with more passwords, this policy may need to become markedly more complicated!
|
// more keys with more passwords, this policy may need to become markedly more complicated!
|
||||||
|
|
||||||
// otherwise, an invalid password request
|
// otherwise, an invalid password request
|
||||||
modals.show_notification(t!("rootkeys.bad_password_request", xous::LANG)).expect("modals error");
|
modals.show_notification(t!("rootkeys.bad_password_request", xous::LANG), false).expect("modals error");
|
||||||
|
|
||||||
xous::return_scalar(msg.sender, 0).unwrap();
|
xous::return_scalar(msg.sender, 0).unwrap();
|
||||||
}
|
}
|
||||||
|
|
@ -978,7 +978,7 @@ fn xmain() -> ! {
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(Opcode::BbramProvision) => {
|
Some(Opcode::BbramProvision) => {
|
||||||
modals.show_notification(t!("rootkeys.bbram.confirm", xous::LANG)).expect("modals error");
|
modals.show_notification(t!("rootkeys.bbram.confirm", xous::LANG), false).expect("modals error");
|
||||||
let console_input = gam::modal::ConsoleInput::new(
|
let console_input = gam::modal::ConsoleInput::new(
|
||||||
main_cid,
|
main_cid,
|
||||||
Opcode::UxBbramCheckReturn.to_u32().unwrap()
|
Opcode::UxBbramCheckReturn.to_u32().unwrap()
|
||||||
|
|
@ -1016,7 +1016,7 @@ fn xmain() -> ! {
|
||||||
rootkeys_modal.activate();
|
rootkeys_modal.activate();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
modals.show_notification(t!("rootkeys.bbram.no_helper", xous::LANG)).expect("modals error");
|
modals.show_notification(t!("rootkeys.bbram.no_helper", xous::LANG), false).expect("modals error");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1039,21 +1039,21 @@ fn xmain() -> ! {
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
modals.show_notification(t!("rootkeys.bbram.finished", xous::LANG)).expect("modals error");
|
modals.show_notification(t!("rootkeys.bbram.finished", xous::LANG), false).expect("modals error");
|
||||||
}
|
}
|
||||||
Err(RootkeyResult::AlignmentError) => {
|
Err(RootkeyResult::AlignmentError) => {
|
||||||
modals.show_notification(t!("rootkeys.init.fail_alignment", xous::LANG)).expect("modals error");
|
modals.show_notification(t!("rootkeys.init.fail_alignment", xous::LANG), false).expect("modals error");
|
||||||
}
|
}
|
||||||
Err(RootkeyResult::KeyError) => {
|
Err(RootkeyResult::KeyError) => {
|
||||||
// probably a bad password, purge it, so the user can try again
|
// probably a bad password, purge it, so the user can try again
|
||||||
keys.purge_password(PasswordType::Update);
|
keys.purge_password(PasswordType::Update);
|
||||||
modals.show_notification(t!("rootkeys.init.fail_key", xous::LANG)).expect("modals error");
|
modals.show_notification(t!("rootkeys.init.fail_key", xous::LANG), false).expect("modals error");
|
||||||
}
|
}
|
||||||
Err(RootkeyResult::IntegrityError) => {
|
Err(RootkeyResult::IntegrityError) => {
|
||||||
modals.show_notification(t!("rootkeys.init.fail_verify", xous::LANG)).expect("modals error");
|
modals.show_notification(t!("rootkeys.init.fail_verify", xous::LANG), false).expect("modals error");
|
||||||
}
|
}
|
||||||
Err(RootkeyResult::FlashError) => {
|
Err(RootkeyResult::FlashError) => {
|
||||||
modals.show_notification(t!("rootkeys.init.fail_burn", xous::LANG)).expect("modals error");
|
modals.show_notification(t!("rootkeys.init.fail_burn", xous::LANG), false).expect("modals error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,9 @@ impl<'a> ShellCmdApi<'a> for Test {
|
||||||
|
|
||||||
if let Some(sub_cmd) = tokens.next() {
|
if let Some(sub_cmd) = tokens.next() {
|
||||||
match sub_cmd {
|
match sub_cmd {
|
||||||
|
"panic" => {
|
||||||
|
assert!(1 == 0, "Panic test: 1 == 0 failure!");
|
||||||
|
}
|
||||||
"instant" => {
|
"instant" => {
|
||||||
write!(ret, "start elapsed_ms {}\n", env.ticktimer.elapsed_ms()).unwrap();
|
write!(ret, "start elapsed_ms {}\n", env.ticktimer.elapsed_ms()).unwrap();
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
|
|
|
||||||
|
|
@ -639,14 +639,14 @@ fn xmain() -> ! {
|
||||||
}),
|
}),
|
||||||
Some(StatusOpcode::TrySuspend) => {
|
Some(StatusOpcode::TrySuspend) => {
|
||||||
if ((llio.adc_vbus().unwrap() as f64) * 0.005033) > 1.5 {
|
if ((llio.adc_vbus().unwrap() as f64) * 0.005033) > 1.5 {
|
||||||
modals.show_notification(t!("mainmenu.cant_sleep", xous::LANG)).expect("couldn't notify that power is plugged in");
|
modals.show_notification(t!("mainmenu.cant_sleep", xous::LANG), false).expect("couldn't notify that power is plugged in");
|
||||||
} else {
|
} else {
|
||||||
susres.initiate_suspend().expect("couldn't initiate suspend op");
|
susres.initiate_suspend().expect("couldn't initiate suspend op");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Some(StatusOpcode::BatteryDisconnect) => {
|
Some(StatusOpcode::BatteryDisconnect) => {
|
||||||
if ((llio.adc_vbus().unwrap() as f64) * 0.005033) > 1.5 {
|
if ((llio.adc_vbus().unwrap() as f64) * 0.005033) > 1.5 {
|
||||||
modals.show_notification(t!("mainmenu.cant_sleep", xous::LANG)).expect("couldn't notify that power is plugged in");
|
modals.show_notification(t!("mainmenu.cant_sleep", xous::LANG), false).expect("couldn't notify that power is plugged in");
|
||||||
} else {
|
} else {
|
||||||
gam.shipmode_blank_request().ok();
|
gam.shipmode_blank_request().ok();
|
||||||
ticktimer.sleep_ms(500).unwrap();
|
ticktimer.sleep_ms(500).unwrap();
|
||||||
|
|
|
||||||
|
|
@ -493,7 +493,7 @@ pub fn start_time_ux(sid: xous::SID) {
|
||||||
match FromPrimitive::from_usize(msg.body.id()) {
|
match FromPrimitive::from_usize(msg.body.id()) {
|
||||||
Some(TimeUxOp::SetTime) => xous::msg_scalar_unpack!(msg, _, _, _, _, {
|
Some(TimeUxOp::SetTime) => xous::msg_scalar_unpack!(msg, _, _, _, _, {
|
||||||
if !pddb_poller.is_mounted_nonblocking() {
|
if !pddb_poller.is_mounted_nonblocking() {
|
||||||
modals.show_notification(t!("stats.please_mount", xous::LANG)).expect("couldn't show notification");
|
modals.show_notification(t!("stats.please_mount", xous::LANG), false).expect("couldn't show notification");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let mut tz_set_handle = pddb::Pddb::new();
|
let mut tz_set_handle = pddb::Pddb::new();
|
||||||
|
|
@ -573,7 +573,7 @@ pub fn start_time_ux(sid: xous::SID) {
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
log::info!("Err: {:?}", err);
|
log::info!("Err: {:?}", err);
|
||||||
modals.show_notification(t!("rtc.ntp_fail", xous::LANG)).expect("couldn't show NTP error");
|
modals.show_notification(t!("rtc.ntp_fail", xous::LANG), false).expect("couldn't show NTP error");
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -641,7 +641,7 @@ pub fn start_time_ux(sid: xous::SID) {
|
||||||
}),
|
}),
|
||||||
Some(TimeUxOp::SetTimeZone) => xous::msg_scalar_unpack!(msg, _, _, _, _, {
|
Some(TimeUxOp::SetTimeZone) => xous::msg_scalar_unpack!(msg, _, _, _, _, {
|
||||||
if !pddb_poller.is_mounted_nonblocking() {
|
if !pddb_poller.is_mounted_nonblocking() {
|
||||||
modals.show_notification(t!("stats.please_mount", xous::LANG)).expect("couldn't show notification");
|
modals.show_notification(t!("stats.please_mount", xous::LANG), false).expect("couldn't show notification");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let tz = modals.get_text(
|
let tz = modals.get_text(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue