diff options
author | Martyn Welch <martyn.welch@collabora.com> | 2024-10-09 14:15:39 +0100 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2024-10-15 10:24:27 -0600 |
commit | 8ba82a91b3aa615fb6148ecfa2af4e91a28659ae (patch) | |
tree | f30cd93609a5ca7daf7b22fde45f26bed5464bba /boot/pxe_utils.c | |
parent | d2faad3ff31f0fab0cf280c05ee333992f7a7d27 (diff) |
boot: Add logic to enable booting from fallback option
The "fallback" extlinux config option allows us to set an alternative
default boot option for when it has been detected that the default is
failing. Implement the logic required to boot from this option when
desired.
Signed-off-by: Martyn Welch <martyn.welch@collabora.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'boot/pxe_utils.c')
-rw-r--r-- | boot/pxe_utils.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index a80119c9a3b..d6a4b2cb859 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -1436,6 +1436,16 @@ struct pxe_menu *parse_pxefile(struct pxe_context *ctx, unsigned long menucfg) buf = map_sysmem(menucfg, 0); r = parse_pxefile_top(ctx, buf, menucfg, cfg, 1); + + if (ctx->use_fallback) { + if (cfg->fallback_label) { + printf("Setting use of fallback\n"); + cfg->default_label = cfg->fallback_label; + } else { + printf("Selected fallback option, but not set\n"); + } + } + unmap_sysmem(buf); if (r < 0) { destroy_pxe_menu(cfg); @@ -1586,7 +1596,8 @@ void handle_pxe_menu(struct pxe_context *ctx, struct pxe_menu *cfg) int pxe_setup_ctx(struct pxe_context *ctx, struct cmd_tbl *cmdtp, pxe_getfile_func getfile, void *userdata, - bool allow_abs_path, const char *bootfile, bool use_ipv6) + bool allow_abs_path, const char *bootfile, bool use_ipv6, + bool use_fallback) { const char *last_slash; size_t path_len = 0; @@ -1597,6 +1608,7 @@ int pxe_setup_ctx(struct pxe_context *ctx, struct cmd_tbl *cmdtp, ctx->userdata = userdata; ctx->allow_abs_path = allow_abs_path; ctx->use_ipv6 = use_ipv6; + ctx->use_fallback = use_fallback; /* figure out the boot directory, if there is one */ if (bootfile && strlen(bootfile) >= MAX_TFTP_PATH_LEN) |