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>
This commit is contained in:
Martyn Welch
2024-10-09 14:15:39 +01:00
committed by Tom Rini
parent d2faad3ff3
commit 8ba82a91b3
6 changed files with 27 additions and 7 deletions

View File

@@ -96,6 +96,8 @@ typedef int (*pxe_getfile_func)(struct pxe_context *ctx, const char *file_path,
* allocated
* @pxe_file_size: Size of the PXE file
* @use_ipv6: TRUE : use IPv6 addressing, FALSE : use IPv4 addressing
* @use_fallback: TRUE : use "fallback" option as default, FALSE : use
* "default" option as default
*/
struct pxe_context {
struct cmd_tbl *cmdtp;
@@ -116,6 +118,7 @@ struct pxe_context {
char *bootdir;
ulong pxe_file_size;
bool use_ipv6;
bool use_fallback;
};
/**
@@ -215,12 +218,17 @@ int format_mac_pxe(char *outbuf, size_t outbuf_len);
* none
* @use_ipv6: TRUE : use IPv6 addressing
* FALSE : use IPv4 addressing
* @use_fallback: TRUE : Use "fallback" option instead of "default" should no
* other choice be selected
* FALSE : Use "default" option should no other choice be
* selected
* Return: 0 if OK, -ENOMEM if out of memory, -E2BIG if bootfile is larger than
* MAX_TFTP_PATH_LEN bytes
*/
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);
/**
* pxe_destroy_ctx() - Destroy a PXE context