mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
add a command to reset RTC after a PDDB format
This commit is contained in:
parent
2751aa03d3
commit
fc4a598a9b
1 changed files with 18 additions and 3 deletions
|
|
@ -514,6 +514,10 @@ fn xmain() -> ! {
|
||||||
let mut dict_list = Vec::<String>::new(); // storage for dict lists
|
let mut dict_list = Vec::<String>::new(); // storage for dict lists
|
||||||
let mut dict_token: Option<[u32; 4]> = None;
|
let mut dict_token: Option<[u32; 4]> = None;
|
||||||
|
|
||||||
|
// the PDDB resets the hardware RTC to a new random starting point every time it is reformatted
|
||||||
|
// it is the only server capable of doing this.
|
||||||
|
let time_resetter = xns.request_connection_blocking(crate::TIME_SERVER_PDDB).unwrap();
|
||||||
|
|
||||||
// register a suspend/resume listener
|
// register a suspend/resume listener
|
||||||
let mut susres = susres::Susres::new(Some(susres::SuspendOrder::Early), &xns,
|
let mut susres = susres::Susres::new(Some(susres::SuspendOrder::Early), &xns,
|
||||||
Opcode::SuspendResume as u32, my_cid).expect("couldn't create suspend/resume object");
|
Opcode::SuspendResume as u32, my_cid).expect("couldn't create suspend/resume object");
|
||||||
|
|
@ -541,7 +545,7 @@ fn xmain() -> ! {
|
||||||
} else {
|
} else {
|
||||||
match ensure_password(&modals, &mut pddb_os) {
|
match ensure_password(&modals, &mut pddb_os) {
|
||||||
PasswordState::Correct => {
|
PasswordState::Correct => {
|
||||||
if try_mount_or_format(&modals, &mut pddb_os, &mut basis_cache, PasswordState::Correct) {
|
if try_mount_or_format(&modals, &mut pddb_os, &mut basis_cache, PasswordState::Correct, time_resetter) {
|
||||||
is_mounted.store(true, Ordering::SeqCst);
|
is_mounted.store(true, Ordering::SeqCst);
|
||||||
xous::return_scalar(msg.sender, 1).expect("couldn't return scalar");
|
xous::return_scalar(msg.sender, 1).expect("couldn't return scalar");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -549,7 +553,7 @@ fn xmain() -> ! {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
PasswordState::Uninit => {
|
PasswordState::Uninit => {
|
||||||
if try_mount_or_format(&modals, &mut pddb_os, &mut basis_cache, PasswordState::Uninit) {
|
if try_mount_or_format(&modals, &mut pddb_os, &mut basis_cache, PasswordState::Uninit, time_resetter) {
|
||||||
is_mounted.store(true, Ordering::SeqCst);
|
is_mounted.store(true, Ordering::SeqCst);
|
||||||
xous::return_scalar(msg.sender, 1).expect("couldn't return scalar");
|
xous::return_scalar(msg.sender, 1).expect("couldn't return scalar");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1137,7 +1141,7 @@ fn ensure_password(modals: &modals::Modals, pddb_os: &mut PddbOs) -> PasswordSta
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn try_mount_or_format(modals: &modals::Modals, pddb_os: &mut PddbOs, basis_cache: &mut BasisCache, pw_state: PasswordState) -> bool {
|
fn try_mount_or_format(modals: &modals::Modals, pddb_os: &mut PddbOs, basis_cache: &mut BasisCache, pw_state: PasswordState, time_resetter: xous::CID) -> bool {
|
||||||
log::info!("Attempting to mount the PDDB");
|
log::info!("Attempting to mount the PDDB");
|
||||||
if pw_state == PasswordState::Correct {
|
if pw_state == PasswordState::Correct {
|
||||||
if let Some(sys_basis) = pddb_os.pddb_mount() {
|
if let Some(sys_basis) = pddb_os.pddb_mount() {
|
||||||
|
|
@ -1190,6 +1194,17 @@ fn try_mount_or_format(modals: &modals::Modals, pddb_os: &mut PddbOs, basis_cach
|
||||||
|
|
||||||
pddb_os.pddb_format(fast, Some(&modals)).expect("couldn't format PDDB");
|
pddb_os.pddb_format(fast, Some(&modals)).expect("couldn't format PDDB");
|
||||||
|
|
||||||
|
// reset the RTC at the point of PDDB format. It is done now because at this point we know that
|
||||||
|
// no time offset keys can exist in the PDDB, and as a measure of good hygeine we want to restart
|
||||||
|
// our RTC counter from a random duration between epoch and 10 years to give some deniability about
|
||||||
|
// how long the device has been in use.
|
||||||
|
let _ = xous::send_message(time_resetter,
|
||||||
|
xous::Message::new_blocking_scalar(
|
||||||
|
0, // the ID is "hard coded" using enumerated discriminants
|
||||||
|
0, 0, 0, 0
|
||||||
|
)
|
||||||
|
).expect("couldn't reset time");
|
||||||
|
|
||||||
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