From f2bfa0cb17948aa4a0fa20fdf9014296b9c4d9c7 Mon Sep 17 00:00:00 2001 From: Mark Kettenis Date: Sun, 3 Sep 2023 22:40:00 +0200 Subject: bootstd: Make efi_mgr bootmeth work for non-sandbox setups Enable the bootflow based on this bootmeth if the BootOrder EFI variable is set. Signed-off-by: Mark Kettenis Reviewed-by: Simon Glass --- boot/bootmeth_efi_mgr.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'boot') diff --git a/boot/bootmeth_efi_mgr.c b/boot/bootmeth_efi_mgr.c index e9d973429f7..e6c42d41fb8 100644 --- a/boot/bootmeth_efi_mgr.c +++ b/boot/bootmeth_efi_mgr.c @@ -14,6 +14,8 @@ #include #include #include +#include +#include /** * struct efi_mgr_priv - private info for the efi-mgr driver @@ -46,13 +48,26 @@ static int efi_mgr_check(struct udevice *dev, struct bootflow_iter *iter) static int efi_mgr_read_bootflow(struct udevice *dev, struct bootflow *bflow) { struct efi_mgr_priv *priv = dev_get_priv(dev); + efi_status_t ret; + efi_uintn_t size; + u16 *bootorder; if (priv->fake_dev) { bflow->state = BOOTFLOWST_READY; return 0; } - /* To be implemented */ + ret = efi_init_obj_list(); + if (ret) + return log_msg_ret("init", ret); + + /* Enable this method if the "BootOrder" UEFI exists. */ + bootorder = efi_get_var(u"BootOrder", &efi_global_variable_guid, + &size); + if (bootorder) { + bflow->state = BOOTFLOWST_READY; + return 0; + } return -EINVAL; } -- cgit v1.2.3 From 19248dcec53d19184ce1207962edd54109d28b01 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 25 Oct 2023 07:17:36 +1300 Subject: bootstd: Handle a few special cases in cmdline_set_arg() Two bugs have appeared: - arguments can have an equals sign embedded in them, which must be considered part of the value - arguments must fully match the name; partial matches should be ignored Fix these and add a test to cover both. Signed-off-by: Simon Glass --- boot/bootflow.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'boot') diff --git a/boot/bootflow.c b/boot/bootflow.c index be543c8588c..6922e7e0c4e 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -752,7 +752,7 @@ int cmdline_set_arg(char *buf, int maxlen, const char *cmdline, in_quote = false; continue; } - if (*p == '=') { + if (*p == '=' && !arg_end) { arg_end = p; val = p + 1; } else if (*p == '"') { @@ -788,7 +788,8 @@ int cmdline_set_arg(char *buf, int maxlen, const char *cmdline, } /* if this is the target arg, update it */ - if (!strncmp(from, set_arg, arg_end - from)) { + if (arg_end - from == set_arg_len && + !strncmp(from, set_arg, set_arg_len)) { if (!buf) { bool has_quote = val_end[-1] == '"'; -- cgit v1.2.3 From a831d1137845732db68ac80edf15bfe4a68d0c8f Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 25 Oct 2023 07:17:37 +1300 Subject: bootstd: cros: Correct condition for read method This has a typo which makes the method inoperable. Correct it so that 'bootflow read' works correctly for ChromeOS. Signed-off-by: Simon Glass --- boot/bootmeth_cros.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'boot') diff --git a/boot/bootmeth_cros.c b/boot/bootmeth_cros.c index 20e0b1e89c3..cd72db8250c 100644 --- a/boot/bootmeth_cros.c +++ b/boot/bootmeth_cros.c @@ -406,7 +406,7 @@ static int cros_read_file(struct udevice *dev, struct bootflow *bflow, return -ENOSYS; } -#if CONFIG_IS_ENABLED(BOOSTD_FULL) +#if CONFIG_IS_ENABLED(BOOTSTD_FULL) static int cros_read_all(struct udevice *dev, struct bootflow *bflow) { int ret; @@ -419,7 +419,7 @@ static int cros_read_all(struct udevice *dev, struct bootflow *bflow) return 0; } -#endif /* BOOSTD_FULL */ +#endif /* BOOTSTD_FULL */ static int cros_boot(struct udevice *dev, struct bootflow *bflow) { @@ -458,9 +458,9 @@ static struct bootmeth_ops cros_bootmeth_ops = { .read_bootflow = cros_read_bootflow, .read_file = cros_read_file, .boot = cros_boot, -#if CONFIG_IS_ENABLED(BOOSTD_FULL) +#if CONFIG_IS_ENABLED(BOOTSTD_FULL) .read_all = cros_read_all, -#endif /* BOOSTD_FULL */ +#endif /* BOOTSTD_FULL */ }; static const struct udevice_id cros_bootmeth_ids[] = { -- cgit v1.2.3