From 0fe6de0dc5b137a2def3a8cc0baa2fb73a3f8541 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 15 Oct 2025 16:44:07 +0100 Subject: boot: Add a flag for whether there are global bootmeths The current 'doing_global' refers to being in the state of processing global bootmeths. Since global bootmeths are currently used once at the start, it becomes false once the last global bootmeth has been used. In preparation for allowing bootmeths to run at other points in the bootstd interation, add a new 'have_global' flag which tracks whether there are any global bootmeths in the method_order[] list. It is set up when iteration starts. Unlike doing_global which resets back to false after the global bootmeths have been handled, once have_global is set to true, it remains true for the entire iteration process. This provides a quick check as to whether global-bootmeth processing is needed. Signed-off-by: Simon Glass --- include/bootflow.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/bootflow.h') diff --git a/include/bootflow.h b/include/bootflow.h index 2ef6eb25cf5..b18baebb4ba 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -255,6 +255,7 @@ enum bootflow_meth_flags_t { * @cur_prio: Current priority being scanned * @method_order: List of bootmeth devices to use, in order. The normal methods * appear first, then the global ones, if any + * @have_global: true if we have global bootmeths in @method_order[] * @doing_global: true if we are iterating through the global bootmeths (which * happens before the normal ones) * @method_flags: flags controlling which methods should be used for this @dev @@ -278,6 +279,7 @@ struct bootflow_iter { int first_glob_method; enum bootdev_prio_t cur_prio; struct udevice **method_order; + bool have_global; bool doing_global; int method_flags; }; -- cgit v1.2.3 From bef963cb751049cacc86f2754452efadd03ae2f0 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 15 Oct 2025 16:44:08 +0100 Subject: boot: Keep track of which bootmeths have been used Add a bitfield which tracks when bootmeths have been used. This will be needed when global bootmeths can be used later in the iteration. Fix a missing bootflow_free() while here. Signed-off-by: Simon Glass --- include/bootflow.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'include/bootflow.h') diff --git a/include/bootflow.h b/include/bootflow.h index b18baebb4ba..58a4ab9f811 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -11,7 +11,8 @@ #include #include #include -#include +#include +#include struct bootstd_priv; struct expo; @@ -213,6 +214,10 @@ enum bootflow_meth_flags_t { BOOTFLOW_METHF_SINGLE_UCLASS = 1 << 3, }; +enum { + BOOTMETH_MAX_COUNT = 32, +}; + /** * struct bootflow_iter - state for iterating through bootflows * @@ -260,6 +265,8 @@ enum bootflow_meth_flags_t { * happens before the normal ones) * @method_flags: flags controlling which methods should be used for this @dev * (enum bootflow_meth_flags_t) + * @methods_done: indicates which methods have been processed, one bit for + * each method in @method_order[] */ struct bootflow_iter { int flags; @@ -282,6 +289,7 @@ struct bootflow_iter { bool have_global; bool doing_global; int method_flags; + uint methods_done; }; /** -- cgit v1.2.3 From 8e31093dbce4fb233c6f14520149293b92981b50 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 15 Oct 2025 16:44:09 +0100 Subject: boot: Support rescanning the global bootmeths Add the logic to scan through the global bootmeths for every new bootdev, in preparation for allowing global bootmeths to select where in the hunter ordering they go. Use a new bootmeth_glob_allowed() function to check if a bootmeth is allowed, ensuring that each can run at most once. For now this has no actual effect, since the global bootmeths are unconditionally processed at the start, with iter->methods_done being updated to include all of them. Therefore when scanning again, no unprocessed global bootmeths will be found. Signed-off-by: Simon Glass --- include/bootflow.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include/bootflow.h') diff --git a/include/bootflow.h b/include/bootflow.h index 58a4ab9f811..059d38251b7 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -267,6 +267,9 @@ enum { * (enum bootflow_meth_flags_t) * @methods_done: indicates which methods have been processed, one bit for * each method in @method_order[] + * @pending_bootdev: if non-NULL, bootdev which will be used when the global + * bootmeths are done + * @pending_method_flags: method flags which will be used with @pending_bootdev */ struct bootflow_iter { int flags; @@ -290,6 +293,8 @@ struct bootflow_iter { bool doing_global; int method_flags; uint methods_done; + struct udevice *pending_bootdev; + int pending_method_flags; }; /** -- cgit v1.2.3 From 4ce78089b2a615eab466347e8996fbd54a876234 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 15 Oct 2025 16:44:11 +0100 Subject: boot: Implement a priority for global bootmeths Allow bootmeths to select when they want to run, using the bootdev priority. Provide a new bootmeth_glob_allowed() function which checks if a bootmeth is ready to use. Fix a comment in bootflow_system() which is a test for global bootmeths. Signed-off-by: Simon Glass --- include/bootflow.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/bootflow.h') diff --git a/include/bootflow.h b/include/bootflow.h index 059d38251b7..1cfdda403ac 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -262,7 +262,7 @@ enum { * appear first, then the global ones, if any * @have_global: true if we have global bootmeths in @method_order[] * @doing_global: true if we are iterating through the global bootmeths (which - * happens before the normal ones) + * generally happens before the normal ones) * @method_flags: flags controlling which methods should be used for this @dev * (enum bootflow_meth_flags_t) * @methods_done: indicates which methods have been processed, one bit for -- cgit v1.2.3