Skip to content

Commit 0646ec2

Browse files
committed
track "attempted" mounts in PDDB
this is to allow a UX process to clear the "waiting for boot" indicator once an attempt has completed. right now, it responds *after* the mount process is done, so the "please waiting" text persists even doing a format. I think that is...appropriate?
1 parent 93dcfb7 commit 0646ec2

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

services/pddb/src/api.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,9 @@ pub(crate) enum Opcode {
236236
/// Bulk read of a dictionary
237237
DictBulkRead = 52,
238238

239+
/// Mount was attempted
240+
MountAttempted = 53,
241+
239242
/// This key type could not be decoded
240243
InvalidOpcode = u32::MAX as _,
241244
}

services/pddb/src/lib.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,20 @@ impl Pddb {
164164
}
165165
}
166166
}
167+
pub fn mount_attempted_blocking(&self) {
168+
loop {
169+
let ret = send_message(self.conn, Message::new_blocking_scalar(
170+
Opcode::MountAttempted.to_usize().unwrap(), 0, 0, 0, 0)).expect("couldn't execute IsMounted query");
171+
match ret {
172+
xous::Result::Scalar2(code, _count) => {
173+
if code == 0 { // mounted successfully
174+
break;
175+
}
176+
},
177+
_ => panic!("Internal error"),
178+
}
179+
}
180+
}
167181
/// Attempts to mount the system basis. Returns `true` on success, `false` on failure.
168182
/// This call may cause a password request box to pop up, in the case that the boot PIN is not currently cached.
169183
///

services/pddb/src/main.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,7 @@ fn wrapped_main() -> ! {
590590

591591
// track processes that want a notification of a mount event
592592
let mut mount_notifications = Vec::<xous::MessageSender>::new();
593+
let mut attempt_notifications = Vec::<xous::MessageSender>::new();
593594

594595
// track heap usage
595596
let mut initial_heap: usize = 0;
@@ -649,6 +650,17 @@ fn wrapped_main() -> ! {
649650
mount_notifications.push(msg.sender); // defer response until later
650651
}
651652
}),
653+
Opcode::MountAttempted => xous::msg_blocking_scalar_unpack!(msg, _, _, _, _, {
654+
#[cfg(not(target_os = "xous"))] // hosted mode always passes
655+
xous::return_scalar2(msg.sender, 0, 0).expect("couldn't return scalar");
656+
657+
#[cfg(target_os = "xous")]
658+
if basis_cache.basis_count() > 0 { // if there's anything in the cache, we're mounted; by definition it was attempted
659+
xous::return_scalar2(msg.sender, 0, 0).expect("couldn't return scalar");
660+
} else {
661+
attempt_notifications.push(msg.sender); // defer response until later
662+
}
663+
}),
652664
// The return code from this is a scalar2 with the following meanings:
653665
// (code, count):
654666
// - code = 0 -> successful mount
@@ -717,6 +729,11 @@ fn wrapped_main() -> ! {
717729
profiling::do_query_work();
718730
}
719731
}
732+
// this is so that the UX can drop the initial "waiting for boot" message
733+
// the attempt is credited even if it was aborted or failed.
734+
for requester in attempt_notifications.drain(..) {
735+
xous::return_scalar2(requester, 0, 0).expect("couldn't return scalar");
736+
}
720737
}),
721738
Opcode::PeriodicScrub => {
722739
let current_heap = heap_usage();

0 commit comments

Comments
 (0)