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 <sjg@chromium.org>
This commit is contained in:
@@ -251,17 +251,24 @@ static void scan_next_in_uclass(struct udevice **devp)
|
|||||||
* bootmeth_glob_allowed() - Check if a global bootmeth is usable at this point
|
* bootmeth_glob_allowed() - Check if a global bootmeth is usable at this point
|
||||||
*
|
*
|
||||||
* @iter: Bootflow iterator being used
|
* @iter: Bootflow iterator being used
|
||||||
* Return: true if the global bootmeth has not already been used
|
* Return: true if the global bootmeth has a suitable priority and has not
|
||||||
|
* already been used
|
||||||
*/
|
*/
|
||||||
static bool bootmeth_glob_allowed(struct bootflow_iter *iter, int meth_seq)
|
static bool bootmeth_glob_allowed(struct bootflow_iter *iter, int meth_seq)
|
||||||
{
|
{
|
||||||
struct udevice *meth = iter->method_order[meth_seq];
|
struct udevice *meth = iter->method_order[meth_seq];
|
||||||
bool done = iter->methods_done & BIT(meth_seq);
|
bool done = iter->methods_done & BIT(meth_seq);
|
||||||
|
struct bootmeth_uc_plat *ucp;
|
||||||
|
|
||||||
log_debug("considering glob '%s': done %d\n", meth->name, done);
|
ucp = dev_get_uclass_plat(meth);
|
||||||
|
log_debug("considering glob '%s': done %d glob_prio %d\n", meth->name,
|
||||||
|
done, ucp->glob_prio);
|
||||||
|
|
||||||
/* if this one has already been used, try the next */
|
/*
|
||||||
if (done)
|
* if this one has already been used, or its priority is too low, try
|
||||||
|
* the next
|
||||||
|
*/
|
||||||
|
if (done || ucp->glob_prio > iter->cur_prio)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -275,7 +275,7 @@ enum {
|
|||||||
* appear first, then the global ones, if any
|
* appear first, then the global ones, if any
|
||||||
* @have_global: true if we have global bootmeths in @method_order[]
|
* @have_global: true if we have global bootmeths in @method_order[]
|
||||||
* @doing_global: true if we are iterating through the global bootmeths (which
|
* @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
|
* @method_flags: flags controlling which methods should be used for this @dev
|
||||||
* (enum bootflow_meth_flags_t)
|
* (enum bootflow_meth_flags_t)
|
||||||
* @methods_done: indicates which methods have been processed, one bit for
|
* @methods_done: indicates which methods have been processed, one bit for
|
||||||
|
|||||||
@@ -30,10 +30,14 @@ enum bootmeth_flags {
|
|||||||
*
|
*
|
||||||
* @desc: A long description of the bootmeth
|
* @desc: A long description of the bootmeth
|
||||||
* @flags: Flags for this bootmeth (enum bootmeth_flags)
|
* @flags: Flags for this bootmeth (enum bootmeth_flags)
|
||||||
|
* @glob_prio: Priority for this bootmeth. If unset (0) the bootmeth is started
|
||||||
|
* before all other bootmeths. Otherwise it is started before the iteration
|
||||||
|
* reaches the given priority.
|
||||||
*/
|
*/
|
||||||
struct bootmeth_uc_plat {
|
struct bootmeth_uc_plat {
|
||||||
const char *desc;
|
const char *desc;
|
||||||
int flags;
|
int flags;
|
||||||
|
enum bootdev_prio_t glob_prio;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** struct bootmeth_ops - Operations for boot methods */
|
/** struct bootmeth_ops - Operations for boot methods */
|
||||||
|
|||||||
Reference in New Issue
Block a user