summaryrefslogtreecommitdiff
path: root/boot/bootmeth_cros.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-08-10 19:33:18 -0600
committerSimon Glass <sjg@chromium.org>2023-08-11 07:33:38 -0600
commitc279224ea6686a992b258b01e07fcadb7f0c7ecb (patch)
tree48273b66cf481b328b6a8871e14cafaedaf87123 /boot/bootmeth_cros.c
parentcbb607d2d9be44a5ded7a652e8e7646925adc1e0 (diff)
bootstd: Add a command to read all files for a bootflow
Some bootflows (such as EFI and ChromiumOS) delay reading the kernel until it is needed to boot. This saves time when scanning and avoids needing to allocate memory for something that may never be used. To permit reading of these files, add a new 'bootflow read' command. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'boot/bootmeth_cros.c')
-rw-r--r--boot/bootmeth_cros.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/boot/bootmeth_cros.c b/boot/bootmeth_cros.c
index 06709dd9171..6c28feb34fe 100644
--- a/boot/bootmeth_cros.c
+++ b/boot/bootmeth_cros.c
@@ -395,13 +395,30 @@ static int cros_read_file(struct udevice *dev, struct bootflow *bflow,
return -ENOSYS;
}
-static int cros_boot(struct udevice *dev, struct bootflow *bflow)
+#if CONFIG_IS_ENABLED(BOOSTD_FULL)
+static int cros_read_all(struct udevice *dev, struct bootflow *bflow)
{
int ret;
+ if (bflow->buf)
+ return log_msg_ret("ld", -EALREADY);
ret = cros_read_kernel(bflow);
if (ret)
return log_msg_ret("rd", ret);
+
+ return 0;
+}
+#endif /* BOOSTD_FULL */
+
+static int cros_boot(struct udevice *dev, struct bootflow *bflow)
+{
+ int ret;
+
+ if (!bflow->buf) {
+ ret = cros_read_kernel(bflow);
+ if (ret)
+ return log_msg_ret("rd", ret);
+ }
#ifdef CONFIG_X86
zboot_start(map_to_sysmem(bflow->buf), bflow->size, 0, 0,
map_to_sysmem(bflow->x86_setup),
@@ -425,6 +442,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)
+ .read_all = cros_read_all,
+#endif /* BOOSTD_FULL */
};
static const struct udevice_id cros_bootmeth_ids[] = {