[PATCH 23/34] bootstd: Maintain a list of images
Simon Glass
sjg at chromium.org
Fri Oct 18 17:01:03 CEST 2024
Hi Heinrich,
On Thu, 17 Oct 2024 at 22:07, Heinrich Schuchardt <xypron.glpk at gmx.de> wrote:
>
>
>
> Am 18. Oktober 2024 01:24:02 MESZ schrieb Simon Glass <sjg at chromium.org>:
> >We want to keep track of images which are loaded, or those which could
> >perhaps be loaded. This will make it easier to manage memory allocation,
> >as well as permit removal of the EFI set_efi_bootdev() hack.
I'll change this 'hack' to 'feature'.
>
> Please, keep in mind that files can be loaded manually, e.g. via the dhcp, the wget, and the loady commands. These are outside bootflows.
Yes, this series is only going to help if bootstd is used. For ad-hoc
use, EFI will need to rely on the above feature, at least until
someone can think of another solution.
>
> No matter how an EFI binary is loaded, we have to create the matching device path. This requires knowledge of the source device and the filepath or URL. Please, ensure that you gather all necessary information.
OK I'll send a little series which shows how this can work. I had
thought it was understood already, but your comment helps explain why
no one has done it yet. In brief, the main advantage of bootstd over
the scripts is that it has a full understanding of what is going on.
>
> Best regards
>
> Heinrich
>
> >
> >Add a list of these, attached to the bootflow. For now the list is
> >empty.
> >
> >Signed-off-by: Simon Glass <sjg at chromium.org>
> >---
> >
> > boot/bootflow.c | 7 +++++++
> > include/bootflow.h | 21 +++++++++++++++++++++
> > 2 files changed, 28 insertions(+)
> >
> >diff --git a/boot/bootflow.c b/boot/bootflow.c
> >index 72b51ebd49b..10bda8eac79 100644
> >--- a/boot/bootflow.c
> >+++ b/boot/bootflow.c
> >@@ -455,10 +455,13 @@ void bootflow_init(struct bootflow *bflow, struct udevice *bootdev,
> > bflow->dev = bootdev;
> > bflow->method = meth;
> > bflow->state = BOOTFLOWST_BASE;
> >+ alist_init_struct(&bflow->images, struct bootflow_img);
> > }
> >
> > void bootflow_free(struct bootflow *bflow)
> > {
> >+ struct bootflow_img *img;
> >+
> > free(bflow->name);
> > free(bflow->subdir);
> > free(bflow->fname);
> >@@ -467,6 +470,10 @@ void bootflow_free(struct bootflow *bflow)
> > free(bflow->os_name);
> > free(bflow->fdt_fname);
> > free(bflow->bootmeth_priv);
> >+
> >+ alist_for_each(img, &bflow->images)
> >+ free(img->fname);
> >+ alist_empty(&bflow->images);
> > }
> >
> > void bootflow_remove(struct bootflow *bflow)
> >diff --git a/include/bootflow.h b/include/bootflow.h
> >index 9b24fb5c3eb..3d9a9e2025a 100644
> >--- a/include/bootflow.h
> >+++ b/include/bootflow.h
> >@@ -7,7 +7,9 @@
> > #ifndef __bootflow_h
> > #define __bootflow_h
> >
> >+#include <alist.h>
> > #include <bootdev.h>
> >+#include <image.h>
> > #include <dm/ofnode_decl.h>
> > #include <linux/list.h>
> >
> >@@ -85,6 +87,7 @@ enum bootflow_flags_t {
> > * @cmdline: OS command line, or NULL if not known (allocated)
> > * @x86_setup: Pointer to x86 setup block inside @buf, NULL if not present
> > * @bootmeth_priv: Private data for the bootmeth
> >+ * @images: List of loaded images (struct bootstd_img)
> > */
> > struct bootflow {
> > struct udevice *dev;
> >@@ -109,6 +112,24 @@ struct bootflow {
> > char *cmdline;
> > void *x86_setup;
> > void *bootmeth_priv;
> >+ struct alist images;
> >+};
> >+
> >+/**
> >+ * struct bootflow_img - Information about an image which has been loaded
> >+ *
> >+ * This keeps track of a single, loaded image.
> >+ *
> >+ * @fname: Filename used to load the image (allocated)
> >+ * @type: Image type (IH_TYPE_...)
> >+ * @addr: Address to which the image was loaded, 0 if not yet loaded
> >+ * @size: Size of the image
> >+ */
> >+struct bootflow_img {
> >+ char *fname;
> >+ enum image_type_t type;
> >+ ulong addr;
> >+ ulong size;
> > };
> >
> > /**
Regards,
SImon
More information about the U-Boot
mailing list