From: Simon Glass <sjg@chromium.org>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Tom Rini <trini@konsulko.com>, Simon Glass <sjg@chromium.org>
Subject: [PATCH 15/15] vbe: Update simple-fw to support using the SPL loader
Date: Thu, 9 Jan 2025 05:30:10 -0700 [thread overview]
Message-ID: <20250109123010.4005298-16-sjg@chromium.org> (raw)
In-Reply-To: <20250109123010.4005298-1-sjg@chromium.org>
For a sandbox implementation, where code size is no object, it makes sense
to use the full bootstd drivers to load images.
For real boards, running from SRAM, this adds quite a bit of overhead.
Add a way to load the next phase using just the underlying storage
driver, to reduce code size. For now, only MMC is supported.
Change the log_debug() to show the load address and size in a more
neutral way, rather than suggesting that the load has already happened.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
boot/vbe_common.c | 2 +-
boot/vbe_simple_fw.c | 112 +++++++++++++++++++++++++++++--------------
2 files changed, 77 insertions(+), 37 deletions(-)
diff --git a/boot/vbe_common.c b/boot/vbe_common.c
index 799f33d9ffa..549a3f955d1 100644
--- a/boot/vbe_common.c
+++ b/boot/vbe_common.c
@@ -152,7 +152,7 @@ int vbe_read_fit(struct udevice *blk, ulong area_offset, ulong area_size,
if (ret < 0)
return log_msg_ret("ld", ret);
node = ret;
- log_debug("loaded to %lx\n", load_addr);
+ log_debug("load %lx size %lx\n", load_addr, len);
fdt_load_addr = 0;
fdt_size = 0;
diff --git a/boot/vbe_simple_fw.c b/boot/vbe_simple_fw.c
index 9da3e49a66e..cb5534fc731 100644
--- a/boot/vbe_simple_fw.c
+++ b/boot/vbe_simple_fw.c
@@ -8,6 +8,7 @@
#define LOG_CATEGORY LOGC_BOOT
+#include <binman_sym.h>
#include <bloblist.h>
#include <bootdev.h>
#include <bootflow.h>
@@ -17,13 +18,24 @@
#include <image.h>
#include <log.h>
#include <mapmem.h>
-#include <memalign.h>
#include <mmc.h>
#include <spl.h>
#include <vbe.h>
#include <dm/device-internal.h>
+#include "vbe_common.h"
#include "vbe_simple.h"
+#ifdef CONFIG_BOOTMETH_VBE_SIMPLE
+binman_sym_extern(ulong, vbe_a, image_pos);
+binman_sym_extern(ulong, vbe_a, size);
+#else
+binman_sym_declare(ulong, vbe_a, image_pos);
+binman_sym_declare(ulong, vbe_a, size);
+#endif
+
+binman_sym_declare(ulong, vpl, image_pos);
+binman_sym_declare(ulong, vpl, size);
+
/**
* vbe_simple_read_bootflow_fw() - Create a bootflow for firmware
*
@@ -54,6 +66,8 @@ int vbe_simple_read_bootflow_fw(struct udevice *dev, struct bootflow *bflow)
ret = vbe_read_fit(blk, priv->area_start + priv->skip_offset,
priv->area_size, NULL, &load_addr, &len,
&bflow->name);
+ if (ret)
+ return log_msg_ret("vbe", ret);
/* set up the bootflow with the info we obtained */
bflow->blk = blk;
@@ -63,16 +77,14 @@ int vbe_simple_read_bootflow_fw(struct udevice *dev, struct bootflow *bflow)
return 0;
}
-static int simple_load_from_image(struct spl_image_info *spl_image,
+static int simple_load_from_image(struct spl_image_info *image,
struct spl_boot_device *bootdev)
{
- struct udevice *meth, *bdev;
- struct simple_priv *priv;
- struct bootflow bflow;
struct vbe_handoff *handoff;
int ret;
- if (xpl_phase() != PHASE_VPL && xpl_phase() != PHASE_SPL)
+ if (xpl_phase() != PHASE_VPL && xpl_phase() != PHASE_SPL &&
+ xpl_phase() != PHASE_TPL)
return -ENOENT;
ret = bloblist_ensure_size(BLOBLISTT_VBE, sizeof(struct vbe_handoff),
@@ -80,36 +92,64 @@ static int simple_load_from_image(struct spl_image_info *spl_image,
if (ret)
return log_msg_ret("ro", ret);
- vbe_find_first_device(&meth);
- if (!meth)
- return log_msg_ret("vd", -ENODEV);
- log_debug("vbe dev %s\n", meth->name);
- ret = device_probe(meth);
- if (ret)
- return log_msg_ret("probe", ret);
-
- priv = dev_get_priv(meth);
- log_debug("simple %s\n", priv->storage);
- ret = bootdev_find_by_label(priv->storage, &bdev, NULL);
- if (ret)
- return log_msg_ret("bd", ret);
- log_debug("bootdev %s\n", bdev->name);
-
- bootflow_init(&bflow, bdev, meth);
- ret = bootmeth_read_bootflow(meth, &bflow);
- log_debug("\nfw ret=%d\n", ret);
- if (ret)
- return log_msg_ret("rd", ret);
-
- /* jump to the image */
- spl_image->flags = SPL_SANDBOXF_ARG_IS_BUF;
- spl_image->arg = bflow.buf;
- spl_image->size = bflow.size;
- log_debug("Image: %s at %p size %x\n", bflow.name, bflow.buf,
- bflow.size);
-
- /* this is not used from now on, so free it */
- bootflow_free(&bflow);
+ if (USE_BOOTMETH) {
+ struct udevice *meth, *bdev;
+ struct simple_priv *priv;
+ struct bootflow bflow;
+
+ vbe_find_first_device(&meth);
+ if (!meth)
+ return log_msg_ret("vd", -ENODEV);
+ log_debug("vbe dev %s\n", meth->name);
+ ret = device_probe(meth);
+ if (ret)
+ return log_msg_ret("probe", ret);
+
+ priv = dev_get_priv(meth);
+ log_debug("simple %s\n", priv->storage);
+ ret = bootdev_find_by_label(priv->storage, &bdev, NULL);
+ if (ret)
+ return log_msg_ret("bd", ret);
+ log_debug("bootdev %s\n", bdev->name);
+
+ bootflow_init(&bflow, bdev, meth);
+ ret = bootmeth_read_bootflow(meth, &bflow);
+ log_debug("\nfw ret=%d\n", ret);
+ if (ret)
+ return log_msg_ret("rd", ret);
+
+ /* jump to the image */
+ image->flags = SPL_SANDBOXF_ARG_IS_BUF;
+ image->arg = bflow.buf;
+ image->size = bflow.size;
+ log_debug("Image: %s at %p size %x\n", bflow.name, bflow.buf,
+ bflow.size);
+
+ /* this is not used from now on, so free it */
+ bootflow_free(&bflow);
+ } else {
+ struct udevice *media, *blk;
+ ulong offset, size;
+
+ ret = uclass_get_device_by_seq(UCLASS_MMC, 1, &media);
+ if (ret)
+ return log_msg_ret("vdv", ret);
+ ret = blk_get_from_parent(media, &blk);
+ if (ret)
+ return log_msg_ret("med", ret);
+ if (xpl_phase() == PHASE_TPL) {
+ offset = binman_sym(ulong, vpl, image_pos);
+ size = binman_sym(ulong, vpl, size);
+ } else {
+ offset = binman_sym(ulong, vbe_a, image_pos);
+ size = binman_sym(ulong, vbe_a, size);
+ printf("offset=%lx\n", offset);
+ }
+
+ ret = vbe_read_fit(blk, offset, size, image, NULL, NULL, NULL);
+ if (ret)
+ return log_msg_ret("vbe", ret);
+ }
/* Record that VBE was used in this phase */
handoff->phases |= 1 << xpl_phase();
--
2.34.1
prev parent reply other threads:[~2025-01-09 12:32 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-09 12:29 [PATCH 00/15] vbe: Series part F Simon Glass
2025-01-09 12:29 ` [PATCH 01/15] vbe: Split out some VBE code into a common file Simon Glass
2025-01-14 1:22 ` Tom Rini
2025-01-14 12:58 ` Simon Glass
2025-01-14 13:26 ` Simon Glass
2025-01-14 16:58 ` Tom Rini
2025-01-14 17:33 ` Tom Rini
2025-01-15 1:18 ` Simon Glass
2025-01-15 1:41 ` Tom Rini
2025-01-15 2:48 ` Simon Glass
2025-01-15 14:10 ` Simon Glass
2025-01-09 12:29 ` [PATCH 02/15] vbe: Split out reading a FIT " Simon Glass
2025-01-11 22:54 ` Tom Rini
2025-01-13 20:03 ` Simon Glass
2025-01-13 20:44 ` Tom Rini
2025-01-14 0:13 ` Simon Glass
2025-01-14 1:22 ` Tom Rini
2025-01-15 14:43 ` Tom Rini
2025-01-15 23:21 ` Simon Glass
2025-01-09 12:29 ` [PATCH 03/15] vbe: Allocate space for the FIT header Simon Glass
2025-01-09 12:29 ` [PATCH 04/15] vbe: Allow VBE to load FITs on any architecture Simon Glass
2025-01-09 12:30 ` [PATCH 05/15] vbe: Tidy up error checking with blk_read() Simon Glass
2025-01-09 12:30 ` [PATCH 06/15] vbe: Handle loading from an unaligned offset Simon Glass
2025-01-09 12:30 ` [PATCH 07/15] vbe: Allow loading loadables if there is no firmware Simon Glass
2025-01-09 12:30 ` [PATCH 08/15] vbe: Support loading an FDT from the FIT Simon Glass
2025-01-09 12:30 ` [PATCH 09/15] spl: Add fields for VBE Simon Glass
2025-01-09 12:30 ` [PATCH 10/15] spl: Add a type for the jumper function Simon Glass
2025-01-09 12:30 ` [PATCH 11/15] spl: Add support for a relocating jump to the next phase Simon Glass
2025-01-09 12:30 ` [PATCH 12/15] spl: Plumb in the relocating loader Simon Glass
2025-01-09 12:30 ` [PATCH 13/15] vbe: Support loading an FDT with " Simon Glass
2025-01-09 12:30 ` [PATCH 14/15] vbe: Support loading SPL images Simon Glass
2025-01-09 12:30 ` Simon Glass [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250109123010.4005298-16-sjg@chromium.org \
--to=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.