mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-19 09:00:54 +00:00
clean up hosted mode flow
This commit is contained in:
parent
904847fc89
commit
00ce905088
2 changed files with 51 additions and 30 deletions
|
|
@ -171,7 +171,7 @@ impl PddbOs {
|
||||||
self.pddb_mr.dump_fs(&name);
|
self.pddb_mr.dump_fs(&name);
|
||||||
let mut export = Vec::<KeyExport>::new();
|
let mut export = Vec::<KeyExport>::new();
|
||||||
if let Some(key) = self.system_basis_key {
|
if let Some(key) = self.system_basis_key {
|
||||||
log::info!("written key: {:x?}", key);
|
log::info!("(hosted mode debug) written key: {:x?}", key);
|
||||||
let mut name = [0 as u8; 64];
|
let mut name = [0 as u8; 64];
|
||||||
for (&src, dst) in PDDB_DEFAULT_SYSTEM_BASIS.as_bytes().iter().zip(name.iter_mut()) {
|
for (&src, dst) in PDDB_DEFAULT_SYSTEM_BASIS.as_bytes().iter().zip(name.iter_mut()) {
|
||||||
*dst = src;
|
*dst = src;
|
||||||
|
|
@ -1205,7 +1205,9 @@ impl PddbOs {
|
||||||
let mut checkblock_a = [0u8; BLOCK_SIZE];
|
let mut checkblock_a = [0u8; BLOCK_SIZE];
|
||||||
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
|
||||||
modals.show_notification(t!("pddb.checkpass", xous::LANG)).expect("notification failed");
|
modals.show_notification(t!("pddb.checkpass", xous::LANG)).expect("notification failed");
|
||||||
|
|
||||||
self.clear_password();
|
self.clear_password();
|
||||||
let mut checkblock_b = [0u8; BLOCK_SIZE];
|
let mut checkblock_b = [0u8; BLOCK_SIZE];
|
||||||
self.rootkeys.decrypt_block(GenericArray::from_mut_slice(&mut checkblock_b));
|
self.rootkeys.decrypt_block(GenericArray::from_mut_slice(&mut checkblock_b));
|
||||||
|
|
|
||||||
|
|
@ -486,44 +486,63 @@ fn xmain() -> ! {
|
||||||
log::info!("PDDB mount operation finished successfully");
|
log::info!("PDDB mount operation finished successfully");
|
||||||
basis_cache.basis_add(sys_basis);
|
basis_cache.basis_add(sys_basis);
|
||||||
} else {
|
} else {
|
||||||
log::debug!("PDDB did not mount; requesting format");
|
#[cfg(any(target_os = "none", target_os = "xous"))]
|
||||||
modals.add_list_item(t!("pddb.okay", xous::LANG)).expect("couldn't build radio item list");
|
{
|
||||||
modals.add_list_item(t!("pddb.cancel", xous::LANG)).expect("couldn't build radio item list");
|
log::debug!("PDDB did not mount; requesting format");
|
||||||
let do_format: bool;
|
modals.add_list_item(t!("pddb.okay", xous::LANG)).expect("couldn't build radio item list");
|
||||||
match modals.get_radiobutton(t!("pddb.requestformat", xous::LANG)) {
|
modals.add_list_item(t!("pddb.cancel", xous::LANG)).expect("couldn't build radio item list");
|
||||||
Ok(response) => {
|
let do_format: bool;
|
||||||
if response.as_str() == t!("pddb.okay", xous::LANG) {
|
match modals.get_radiobutton(t!("pddb.requestformat", xous::LANG)) {
|
||||||
do_format = true;
|
|
||||||
} else if response.as_str() == t!("pddb.cancel", xous::LANG) {
|
|
||||||
log::info!("PDDB format aborted by user");
|
|
||||||
do_format = false;
|
|
||||||
} else {
|
|
||||||
panic!("Got unexpected return from radiobutton");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => panic!("get_radiobutton failed"),
|
|
||||||
}
|
|
||||||
if do_format {
|
|
||||||
modals.add_list_item(t!("pddb.no", xous::LANG)).expect("couldn't build radio item list");
|
|
||||||
modals.add_list_item(t!("pddb.yes", xous::LANG)).expect("couldn't build radio item list");
|
|
||||||
let fast: bool;
|
|
||||||
match modals.get_radiobutton(t!("pddb.devbypass", xous::LANG)) {
|
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
if response.as_str() == t!("pddb.yes", xous::LANG) {
|
if response.as_str() == t!("pddb.okay", xous::LANG) {
|
||||||
fast = true;
|
do_format = true;
|
||||||
} else if response.as_str() == t!("pddb.no", xous::LANG) {
|
} else if response.as_str() == t!("pddb.cancel", xous::LANG) {
|
||||||
fast = false;
|
log::info!("PDDB format aborted by user");
|
||||||
|
do_format = false;
|
||||||
} else {
|
} else {
|
||||||
panic!("Got unexpected return from radiobutton");
|
panic!("Got unexpected return from radiobutton");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => panic!("get_radiobutton failed"),
|
_ => panic!("get_radiobutton failed"),
|
||||||
}
|
}
|
||||||
pddb_os.pddb_format(fast, Some(&modals)).expect("couldn't format PDDB");
|
if do_format {
|
||||||
|
let fast: bool;
|
||||||
|
if false {
|
||||||
|
modals.add_list_item(t!("pddb.no", xous::LANG)).expect("couldn't build radio item list");
|
||||||
|
modals.add_list_item(t!("pddb.yes", xous::LANG)).expect("couldn't build radio item list");
|
||||||
|
match modals.get_radiobutton(t!("pddb.devbypass", xous::LANG)) {
|
||||||
|
Ok(response) => {
|
||||||
|
if response.as_str() == t!("pddb.yes", xous::LANG) {
|
||||||
|
fast = true;
|
||||||
|
} else if response.as_str() == t!("pddb.no", xous::LANG) {
|
||||||
|
fast = false;
|
||||||
|
} else {
|
||||||
|
panic!("Got unexpected return from radiobutton");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => panic!("get_radiobutton failed"),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fast = false;
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(not(any(target_os = "none", target_os = "xous")))]
|
pddb_os.pddb_format(fast, Some(&modals)).expect("couldn't format PDDB");
|
||||||
|
|
||||||
|
if let Some(sys_basis) = pddb_os.pddb_mount() {
|
||||||
|
log::info!("PDDB mount operation finished successfully");
|
||||||
|
basis_cache.basis_add(sys_basis);
|
||||||
|
} else {
|
||||||
|
log::error!("Despite formatting, no PDDB was found!");
|
||||||
|
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
|
||||||
|
modals.show_notification(err.as_str()).expect("notification failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[cfg(not(any(target_os = "none", target_os = "xous")))]
|
||||||
|
{
|
||||||
|
pddb_os.pddb_format(false, Some(&modals)).expect("couldn't format PDDB");
|
||||||
pddb_os.dbg_dump(Some("full".to_string()), None);
|
pddb_os.dbg_dump(Some("full".to_string()), None);
|
||||||
|
|
||||||
if let Some(sys_basis) = pddb_os.pddb_mount() {
|
if let Some(sys_basis) = pddb_os.pddb_mount() {
|
||||||
log::info!("PDDB mount operation finished successfully");
|
log::info!("PDDB mount operation finished successfully");
|
||||||
basis_cache.basis_add(sys_basis);
|
basis_cache.basis_add(sys_basis);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue