summaryrefslogtreecommitdiff
path: root/boot/bootflow_menu.c
diff options
context:
space:
mode:
authorSimon Glass <[email protected]>2025-05-02 08:46:27 -0600
committerSimon Glass <[email protected]>2025-05-30 09:49:32 +0100
commitb991a0c8bf30095837b096acd691e0d2add07b8c (patch)
treec747f676d09bc5838476b82cd30f613163d1529b /boot/bootflow_menu.c
parent509852111422454117561c3d4aa4827270ca68d4 (diff)
expo: Split bootflow_menu_run() into two pieces
Split the starting piece of this function into bootflow_menu_start() and the polling part into bootflow_menu_poll() so that it is possible for the caller to be in control of the event loop. Move the expo_destroy() call into the caller. Signed-off-by: Simon Glass <[email protected]>
Diffstat (limited to 'boot/bootflow_menu.c')
-rw-r--r--boot/bootflow_menu.c89
1 files changed, 41 insertions, 48 deletions
diff --git a/boot/bootflow_menu.c b/boot/bootflow_menu.c
index f9ebc526200..ed7c0768c7b 100644
--- a/boot/bootflow_menu.c
+++ b/boot/bootflow_menu.c
@@ -175,20 +175,13 @@ int bootflow_menu_apply_theme(struct expo *exp, ofnode node)
return 0;
}
-int bootflow_menu_run(struct bootstd_priv *std, bool text_mode,
- struct bootflow **bflowp)
+int bootflow_menu_start(struct bootstd_priv *std, bool text_mode,
+ struct expo **expp)
{
- struct bootflow *sel_bflow;
struct udevice *dev;
- struct scene *scn;
struct expo *exp;
- uint sel_id;
- bool done;
int ret;
- sel_bflow = NULL;
- *bflowp = NULL;
-
ret = bootflow_menu_new(&exp);
if (ret)
return log_msg_ret("exp", ret);
@@ -210,58 +203,58 @@ int bootflow_menu_run(struct bootstd_priv *std, bool text_mode,
ret = expo_set_scene_id(exp, MAIN);
if (ret)
return log_msg_ret("scn", ret);
- scn = expo_lookup_scene_id(exp, MAIN);
- if (!scn)
- return log_msg_ret("scn", -ENOENT);
if (text_mode)
expo_set_text_mode(exp, text_mode);
- done = false;
- do {
- struct expo_action act;
-
- ret = expo_poll(exp, &act);
- if (!ret) {
- switch (act.type) {
- case EXPOACT_SELECT:
- sel_id = act.select.id;
- done = true;
- break;
- case EXPOACT_POINT_ITEM:
- ret = scene_menu_select_item(scn,
- OBJ_MENU, act.select.id);
- if (ret)
- return log_msg_ret("bmp", ret);
- break;
- case EXPOACT_QUIT:
- return -EPIPE;
- default:
- break;
- }
- } else if (ret != -EPIPE && ret != -EAGAIN) {
- return log_msg_ret("bmr", ret);
- }
- } while (!done);
+ *expp = exp;
+
+ return 0;
+}
- if (sel_id) {
+int bootflow_menu_poll(struct expo *exp, struct bootflow **bflowp)
+{
+ struct bootflow *sel_bflow;
+ struct expo_action act;
+ int ret;
+
+ sel_bflow = NULL;
+ *bflowp = NULL;
+
+ ret = expo_poll(exp, &act);
+ if (ret)
+ return log_msg_ret("bmp", ret);
+
+ switch (act.type) {
+ case EXPOACT_SELECT: {
struct bootflow *bflow;
int i;
for (ret = bootflow_first_glob(&bflow), i = 0; !ret && i < 36;
ret = bootflow_next_glob(&bflow), i++) {
- if (i == sel_id - ITEM) {
- sel_bflow = bflow;
- break;
+ if (i == act.select.id - ITEM) {
+ *bflowp = bflow;
+ // printf("found %p\n", bflow);
+ return 0;
}
}
+ break;
}
+ case EXPOACT_POINT_ITEM: {
+ struct scene *scn = expo_lookup_scene_id(exp, MAIN);
- expo_destroy(exp);
-
- if (!sel_bflow)
- return -EAGAIN;
- *bflowp = sel_bflow;
+ if (!scn)
+ return log_msg_ret("bms", -ENOENT);
+ ret = scene_menu_select_item(scn, OBJ_MENU, act.select.id);
+ if (ret)
+ return log_msg_ret("bmp", ret);
+ break;
+ }
+ case EXPOACT_QUIT:
+ return -EPIPE;
+ default:
+ break;
+ }
- return 0;
+ return -EAGAIN;
}