[Concept,10/19] bootctl: Provide an extra poll between select and booting
Commit Message
From: Simon Glass <simon.glass@canonical.com>
Selecting an OS may cause the UI to change, so give it a chance to show
those changes before booting.
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---
boot/bootctl/logic.c | 14 ++++++++++++++
include/bootctl/logic.h | 6 ++++--
2 files changed, 18 insertions(+), 2 deletions(-)
@@ -242,8 +242,22 @@ static int logic_poll(struct udevice *dev)
struct osinfo *os;
os = alist_getw(&priv->osinfo, seq, struct osinfo);
+ if (!os)
+ return log_msg_ret("gos", -ENOENT);
+ priv->ready_to_boot = false;
+ priv->selected_seq = seq;
+ }
+
+ if (priv->ready_to_boot) {
+ struct osinfo *os;
+
+ seq = priv->selected_seq;
+ os = alist_getw(&priv->osinfo, seq, struct osinfo);
+ if (!os)
+ return log_msg_ret("gbo", -ENOENT);
log_info("Selected %d: %s\n", seq, os->bflow.os_name);
+ priv->ready_to_boot = false;
/*
* try to read the images first; some methods don't support
* this
@@ -37,10 +37,10 @@ struct udevice;
* @default_os: name of the default OS to boot
* @osinfo: List of OSes to show
* @refresh: true if we need to refresh the UI because something has changed
+ * @selected_seq: sequence number of OS waiting for passphrase, or -1 if none
+ * @ready_to_boot: true if success message shown, ready to boot on next poll
*
* @iter: oslist iterator, used to find new OSes
- * @selected: index of selected OS in osinfo alist, or -1 if none has been
- * selected yet
* @meas: TPM-measurement device
* @oslist: provides OSes to boot; we iterate through each osinfo driver to find
* all OSes
@@ -68,6 +68,8 @@ struct logic_priv {
const char *default_os;
struct alist osinfo;
bool refresh;
+ int selected_seq;
+ bool ready_to_boot;
struct oslist_iter iter;
struct udevice *meas;