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>,
Guillaume La Roque <glaroque@baylibre.com>,
Heinrich Schuchardt <xypron.glpk@gmx.de>,
Igor Opaniuk <igor.opaniuk@gmail.com>,
Julien Masson <jmasson@baylibre.com>,
Mattijs Korpershoek <mkorpershoek@baylibre.com>,
Maximilian Brune <maximilian.brune@9elements.com>,
Nam Cao <namcao@linutronix.de>,
Quentin Schulz <quentin.schulz@cherry.de>,
Shantur Rathore <i@shantur.com>
Subject: [PATCH v3 06/19] bootstd: Maintain a list of images
Date: Mon, 4 Nov 2024 10:50:57 -0700 [thread overview]
Message-ID: <20241104175110.1048449-7-sjg@chromium.org> (raw)
In-Reply-To: <20241104175110.1048449-1-sjg@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() feature.
Add a list of these, attached to the bootflow. For now the list is
empty.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
(no changes since v2)
Changes in v2:
- Add an image type extension in bootflow.h
- Use the word 'feature' instead of 'hack'
boot/bootflow.c | 26 +++++++++++++++++++++++++
include/bootflow.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 74 insertions(+)
diff --git a/boot/bootflow.c b/boot/bootflow.c
index 7ce04fd92cd..94f34dcad0f 100644
--- a/boot/bootflow.c
+++ b/boot/bootflow.c
@@ -23,6 +23,13 @@ enum {
BF_NO_MORE_DEVICES = -ENODEV,
};
+static const char *const bootflow_img[BFI_COUNT - BFI_FIRST] = {
+ "extlinux_cfg",
+ "logo",
+ "efi",
+ "cmdline",
+};
+
/**
* bootflow_state - name for each state
*
@@ -455,10 +462,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 +477,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)
@@ -950,3 +964,15 @@ int bootflow_cmdline_auto(struct bootflow *bflow, const char *arg)
return 0;
}
+
+const char *bootflow_img_type_name(enum bootflow_img_t type)
+{
+ const char *name;
+
+ if (type >= BFI_FIRST && type < BFI_COUNT)
+ name = bootflow_img[type - BFI_FIRST];
+ else
+ name = genimg_get_type_short_name(type);
+
+ return name;
+}
diff --git a/include/bootflow.h b/include/bootflow.h
index 9b24fb5c3eb..f407bb356b4 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,44 @@ struct bootflow {
char *cmdline;
void *x86_setup;
void *bootmeth_priv;
+ struct alist images;
+};
+
+/**
+ * bootflow_img_t: Supported image types
+ *
+ * This uses image_type_t for most types, but extends it
+ *
+ * @BFI_EXTLINUX_CFG: extlinux configuration-file
+ * @BFI_LOGO: logo image
+ * @BFI_EFI: EFI PE image
+ * @BFI_CMDLINE: OS command-line string
+ */
+enum bootflow_img_t {
+ BFI_FIRST = IH_TYPE_COUNT,
+ BFI_EXTLINUX_CFG = BFI_FIRST,
+ BFI_LOGO,
+ BFI_EFI,
+ BFI_CMDLINE,
+
+ BFI_COUNT,
+};
+
+/**
+ * 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 bootflow_img_t type;
+ ulong addr;
+ ulong size;
};
/**
@@ -565,4 +606,11 @@ int bootflow_cmdline_get_arg(struct bootflow *bflow, const char *arg,
*/
int bootflow_cmdline_auto(struct bootflow *bflow, const char *arg);
+/**
+ * bootflow_img_type_name() - Get the name for an image type
+ *
+ * @type: Type to check (either enum bootflow_img_t or enum image_type_t
+ * Return: Image name, or "unknown" if not known
+ */
+const char *bootflow_img_type_name(enum bootflow_img_t type);
#endif
--
2.34.1
next prev parent reply other threads:[~2024-11-04 17:52 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-04 17:50 [PATCH v3 00/19] bootstd: Support recording images Simon Glass
2024-11-04 17:50 ` [PATCH v3 01/19] bootstd: Move bootflow-adding to bootstd Simon Glass
2024-11-04 22:02 ` Heinrich Schuchardt
2024-11-05 15:13 ` Simon Glass
2024-11-05 15:39 ` Tom Rini
2024-11-05 16:07 ` Simon Glass
2024-11-04 17:50 ` [PATCH v3 02/19] bootstd: Move bootflow-clearing " Simon Glass
2024-11-04 22:04 ` Heinrich Schuchardt
2024-11-04 17:50 ` [PATCH v3 03/19] bootstd: Add a function to get bootstd only if available Simon Glass
2024-11-04 17:50 ` [PATCH v3 04/19] bootstd: Drop the bootdev-specific list of bootflows Simon Glass
2024-11-04 17:50 ` [PATCH v3 05/19] bootstd: Move the bootflow list into an alist Simon Glass
2024-11-04 17:50 ` Simon Glass [this message]
2024-11-04 17:50 ` [PATCH v3 07/19] bootstd: Update bootmeth_alloc_file() to record images Simon Glass
2024-11-04 17:50 ` [PATCH v3 08/19] boot: pxe: Drop the duplicate comment on get_pxe_file() Simon Glass
2024-11-04 17:51 ` [PATCH v3 09/19] bootmeth_efi: Simplify reading files by using the common function Simon Glass
2024-11-04 17:51 ` [PATCH v3 10/19] bootmeth: Update the read_file() method to include a type Simon Glass
2024-11-04 17:51 ` [PATCH v3 11/19] bootmeth_efi: Check the filename-allocation in the network path Simon Glass
2024-11-04 21:42 ` Heinrich Schuchardt
2024-11-15 23:19 ` Simon Glass
2024-11-04 17:51 ` [PATCH v3 12/19] boot: Update extlinux pxe_getfile_func() to include type Simon Glass
2024-11-04 17:51 ` [PATCH v3 13/19] boot: Update pxe bootmeth to record images Simon Glass
2024-11-04 17:51 ` [PATCH v3 14/19] Update bootmeth_alloc_other() " Simon Glass
2024-11-04 17:51 ` [PATCH v3 15/19] bootstd: Update cros bootmeth " Simon Glass
2024-11-04 17:51 ` [PATCH v3 16/19] bootstd: Add a simple command to list images Simon Glass
2024-11-04 17:51 ` [PATCH v3 17/19] bootstd: Export bootdev_get_from_blk() Simon Glass
2024-11-04 17:51 ` [PATCH v3 18/19] bootstd: Add the concept of an ad-hoc bootflow Simon Glass
2024-11-04 17:51 ` [PATCH v3 19/19] fs: Record loaded files in " Simon Glass
2025-01-15 13:55 ` [PATCH v3 00/19] bootstd: Support recording images Simon Glass
2025-01-15 21:24 ` Tom Rini
2025-01-15 23:14 ` Simon Glass
2025-01-15 23:31 ` Tom Rini
2025-01-16 15:52 ` Simon Glass
2025-01-16 17:21 ` Tom Rini
2025-01-18 4:32 ` Simon Glass
2025-01-18 5:49 ` Tony Dinh
2025-01-18 14:41 ` Tom Rini
2025-01-18 19:26 ` Tony Dinh
2025-01-23 14:38 ` Simon Glass
2025-01-23 17:17 ` Tom Rini
2025-01-25 17:13 ` Simon Glass
2025-01-25 18:27 ` Tom Rini
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=20241104175110.1048449-7-sjg@chromium.org \
--to=sjg@chromium.org \
--cc=glaroque@baylibre.com \
--cc=i@shantur.com \
--cc=igor.opaniuk@gmail.com \
--cc=jmasson@baylibre.com \
--cc=maximilian.brune@9elements.com \
--cc=mkorpershoek@baylibre.com \
--cc=namcao@linutronix.de \
--cc=quentin.schulz@cherry.de \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox