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>,
"AKASHI Takahiro" <akashi.tkhro@gmail.com>,
"Guillaume La Roque" <glaroque@baylibre.com>,
"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
"Ion Agorria" <ion@agorria.com>,
"Julien Masson" <jmasson@baylibre.com>,
"Mark Kettenis" <kettenis@openbsd.org>,
"Martyn Welch" <martyn.welch@collabora.com>,
"Mattijs Korpershoek" <mkorpershoek@baylibre.com>,
"Quentin Schulz" <quentin.schulz@cherry.de>,
"Shantur Rathore" <i@shantur.com>,
"Vincent Stehlé" <vincent.stehle@arm.com>
Subject: [PATCH 27/34] bootmeth: Update the read_file() method to include a type
Date: Thu, 17 Oct 2024 17:24:06 -0600 [thread overview]
Message-ID: <20241017232413.724808-28-sjg@chromium.org> (raw)
In-Reply-To: <20241017232413.724808-1-sjg@chromium.org>
We want to record the type of each file which is loaded. Add an new
parameter for this, to the read_file() method. Update all users.
Make bootmeth_common_read_file() store information about the image that
is read.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
boot/bootmeth-uclass.c | 22 +++++++++++++++++++---
boot/bootmeth_android.c | 3 ++-
boot/bootmeth_cros.c | 3 ++-
boot/bootmeth_efi.c | 5 +++--
boot/bootmeth_efi_mgr.c | 3 ++-
boot/bootmeth_extlinux.c | 2 +-
boot/bootmeth_pxe.c | 6 +++---
boot/bootmeth_qfw.c | 3 ++-
boot/bootmeth_sandbox.c | 3 ++-
boot/vbe_simple.c | 5 +++--
include/bootmeth.h | 12 +++++++++---
11 files changed, 48 insertions(+), 19 deletions(-)
diff --git a/boot/bootmeth-uclass.c b/boot/bootmeth-uclass.c
index 34fff004b43..726393e20b8 100644
--- a/boot/bootmeth-uclass.c
+++ b/boot/bootmeth-uclass.c
@@ -84,14 +84,15 @@ int bootmeth_boot(struct udevice *dev, struct bootflow *bflow)
}
int bootmeth_read_file(struct udevice *dev, struct bootflow *bflow,
- const char *file_path, ulong addr, ulong *sizep)
+ const char *file_path, ulong addr,
+ enum image_type_t type, ulong *sizep)
{
const struct bootmeth_ops *ops = bootmeth_get_ops(dev);
if (!ops->read_file)
return -ENOSYS;
- return ops->read_file(dev, bflow, file_path, addr, sizep);
+ return ops->read_file(dev, bflow, file_path, addr, type, sizep);
}
int bootmeth_get_bootflow(struct udevice *dev, struct bootflow *bflow)
@@ -399,11 +400,14 @@ int bootmeth_alloc_other(struct bootflow *bflow, const char *fname,
}
int bootmeth_common_read_file(struct udevice *dev, struct bootflow *bflow,
- const char *file_path, ulong addr, ulong *sizep)
+ const char *file_path, ulong addr,
+ enum image_type_t type, ulong *sizep)
{
struct blk_desc *desc = NULL;
+ struct bootflow_img *img;
loff_t len_read;
loff_t size;
+ char *fname;
int ret;
if (bflow->blk)
@@ -428,6 +432,18 @@ int bootmeth_common_read_file(struct udevice *dev, struct bootflow *bflow,
return ret;
*sizep = len_read;
+ fname = strdup(bflow->fname);
+ if (!fname)
+ return log_msg_ret("crf", -ENOMEM);
+
+ img = alist_add_placeholder(&bflow->images);
+ if (!img)
+ return log_msg_ret("cri", -ENOMEM);
+ img->fname = fname;
+ img->type = type;
+ img->addr = addr;
+ img->size = len_read;
+
return 0;
}
diff --git a/boot/bootmeth_android.c b/boot/bootmeth_android.c
index 19b1f2c377b..0c7d3449ac7 100644
--- a/boot/bootmeth_android.c
+++ b/boot/bootmeth_android.c
@@ -298,7 +298,8 @@ static int android_read_bootflow(struct udevice *dev, struct bootflow *bflow)
}
static int android_read_file(struct udevice *dev, struct bootflow *bflow,
- const char *file_path, ulong addr, ulong *sizep)
+ const char *file_path, ulong addr,
+ enum image_type_t type, ulong *sizep)
{
/*
* Reading individual files is not supported since we only
diff --git a/boot/bootmeth_cros.c b/boot/bootmeth_cros.c
index 676f550ca25..3e60fd5da07 100644
--- a/boot/bootmeth_cros.c
+++ b/boot/bootmeth_cros.c
@@ -400,7 +400,8 @@ static int cros_read_bootflow(struct udevice *dev, struct bootflow *bflow)
}
static int cros_read_file(struct udevice *dev, struct bootflow *bflow,
- const char *file_path, ulong addr, ulong *sizep)
+ const char *file_path, ulong addr,
+ enum image_type_t type, ulong *sizep)
{
return -ENOSYS;
}
diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c
index f3ddbe71405..e1e378481b9 100644
--- a/boot/bootmeth_efi.c
+++ b/boot/bootmeth_efi.c
@@ -117,7 +117,7 @@ static int efiload_read_file(struct bootflow *bflow, ulong addr)
desc = dev_get_uclass_plat(bflow->blk);
ret = bootmeth_common_read_file(bflow->method, bflow, bflow->fname,
- addr, &size);
+ addr, IH_TYPE_EFI, &size);
set_efi_bootdev(desc, bflow);
@@ -189,7 +189,8 @@ static int distro_efi_try_bootflow_files(struct udevice *dev,
/* Limit FDT files to 4MB */
size = SZ_4M;
ret = bootmeth_common_read_file(dev, bflow, fname,
- fdt_addr, &size);
+ fdt_addr,
+ IH_TYPE_FLATDT, &size);
}
}
diff --git a/boot/bootmeth_efi_mgr.c b/boot/bootmeth_efi_mgr.c
index 23ae1e610ac..b2b235d4915 100644
--- a/boot/bootmeth_efi_mgr.c
+++ b/boot/bootmeth_efi_mgr.c
@@ -74,7 +74,8 @@ static int efi_mgr_read_bootflow(struct udevice *dev, struct bootflow *bflow)
}
static int efi_mgr_read_file(struct udevice *dev, struct bootflow *bflow,
- const char *file_path, ulong addr, ulong *sizep)
+ const char *file_path, ulong addr,
+ enum image_type_t type, ulong *sizep)
{
/* Files are loaded by the 'bootefi bootmgr' command */
diff --git a/boot/bootmeth_extlinux.c b/boot/bootmeth_extlinux.c
index 755a80350d9..085ed9e456f 100644
--- a/boot/bootmeth_extlinux.c
+++ b/boot/bootmeth_extlinux.c
@@ -79,7 +79,7 @@ static int extlinux_getfile(struct pxe_context *ctx, const char *file_path,
/* Allow up to 1GB */
*sizep = 1 << 30;
ret = bootmeth_read_file(info->dev, info->bflow, file_path, addr,
- sizep);
+ IH_TYPE_INVALID, sizep);
if (ret)
return log_msg_ret("read", ret);
diff --git a/boot/bootmeth_pxe.c b/boot/bootmeth_pxe.c
index 05c6bece2c1..74b0ad7d2e9 100644
--- a/boot/bootmeth_pxe.c
+++ b/boot/bootmeth_pxe.c
@@ -23,7 +23,7 @@
#include <pxe_utils.h>
static int extlinux_pxe_getfile(struct pxe_context *ctx, const char *file_path,
- char *file_addr, ulong *sizep)
+ char *file_addr, ulong *sizep)
{
struct extlinux_info *info = ctx->userdata;
ulong addr;
@@ -34,7 +34,7 @@ static int extlinux_pxe_getfile(struct pxe_context *ctx, const char *file_path,
/* Allow up to 1GB */
*sizep = 1 << 30;
ret = bootmeth_read_file(info->dev, info->bflow, file_path, addr,
- sizep);
+ IH_TYPE_INVALID, sizep);
if (ret)
return log_msg_ret("read", ret);
@@ -113,7 +113,7 @@ static int extlinux_pxe_read_bootflow(struct udevice *dev,
static int extlinux_pxe_read_file(struct udevice *dev, struct bootflow *bflow,
const char *file_path, ulong addr,
- ulong *sizep)
+ enum image_type_t type, ulong *sizep)
{
char *tftp_argv[] = {"tftp", NULL, NULL, NULL};
struct pxe_context *ctx = dev_get_priv(dev);
diff --git a/boot/bootmeth_qfw.c b/boot/bootmeth_qfw.c
index 2f8e00cf350..fb3cde4ab4b 100644
--- a/boot/bootmeth_qfw.c
+++ b/boot/bootmeth_qfw.c
@@ -52,7 +52,8 @@ static int qfw_read_bootflow(struct udevice *dev, struct bootflow *bflow)
}
static int qfw_read_file(struct udevice *dev, struct bootflow *bflow,
- const char *file_path, ulong addr, ulong *sizep)
+ const char *file_path, ulong addr,
+ enum image_type_t type, ulong *sizep)
{
return -ENOSYS;
}
diff --git a/boot/bootmeth_sandbox.c b/boot/bootmeth_sandbox.c
index 26c713bb5f3..c40e8ae3304 100644
--- a/boot/bootmeth_sandbox.c
+++ b/boot/bootmeth_sandbox.c
@@ -27,7 +27,8 @@ static int sandbox_read_bootflow(struct udevice *dev, struct bootflow *bflow)
}
static int sandbox_read_file(struct udevice *dev, struct bootflow *bflow,
- const char *file_path, ulong addr, ulong *sizep)
+ const char *file_path, ulong addr,
+ enum image_type_t type, ulong *sizep)
{
return -ENOSYS;
}
diff --git a/boot/vbe_simple.c b/boot/vbe_simple.c
index 189e86d2a22..c51b7d5805b 100644
--- a/boot/vbe_simple.c
+++ b/boot/vbe_simple.c
@@ -160,13 +160,14 @@ static int vbe_simple_read_bootflow(struct udevice *dev, struct bootflow *bflow)
}
static int vbe_simple_read_file(struct udevice *dev, struct bootflow *bflow,
- const char *file_path, ulong addr, ulong *sizep)
+ const char *file_path, ulong addr,
+ enum image_type_t type, ulong *sizep)
{
int ret;
if (vbe_phase() == VBE_PHASE_OS) {
ret = bootmeth_common_read_file(dev, bflow, file_path, addr,
- sizep);
+ type, sizep);
if (ret)
return log_msg_ret("os", ret);
}
diff --git a/include/bootmeth.h b/include/bootmeth.h
index 322169c6b2e..78b2ce4123b 100644
--- a/include/bootmeth.h
+++ b/include/bootmeth.h
@@ -118,13 +118,15 @@ struct bootmeth_ops {
* @bflow: Bootflow providing info on where to read from
* @file_path: Path to file (may be absolute or relative)
* @addr: Address to load file
+ * @type: File type (IH_TYPE_...)
* @sizep: On entry provides the maximum permitted size; on exit
* returns the size of the file
* Return: 0 if OK, -ENOSPC if the file is too large for @sizep, other
* -ve value if something else goes wrong
*/
int (*read_file)(struct udevice *dev, struct bootflow *bflow,
- const char *file_path, ulong addr, ulong *sizep);
+ const char *file_path, ulong addr,
+ enum image_type_t type, ulong *sizep);
#if CONFIG_IS_ENABLED(BOOTSTD_FULL)
/**
* readall() - read all files for a bootflow
@@ -246,13 +248,15 @@ int bootmeth_set_bootflow(struct udevice *dev, struct bootflow *bflow,
* @bflow: Bootflow providing info on where to read from
* @file_path: Path to file (may be absolute or relative)
* @addr: Address to load file
+ * @type: File type (IH_TYPE_...)
* @sizep: On entry provides the maximum permitted size; on exit
* returns the size of the file
* Return: 0 if OK, -ENOSPC if the file is too large for @sizep, other
* -ve value if something else goes wrong
*/
int bootmeth_read_file(struct udevice *dev, struct bootflow *bflow,
- const char *file_path, ulong addr, ulong *sizep);
+ const char *file_path, ulong addr,
+ enum image_type_t type, ulong *sizep);
/**
* bootmeth_read_all() - read all bootflow files
@@ -398,11 +402,13 @@ int bootmeth_alloc_other(struct bootflow *bflow, const char *fname,
* @bflow: Bootflow information
* @file_path: Path to file
* @addr: Address to load file to
+ * @type: File type (IH_TYPE_...)
* @sizep: On entry, the maximum file size to accept, on exit the actual file
* size read
*/
int bootmeth_common_read_file(struct udevice *dev, struct bootflow *bflow,
- const char *file_path, ulong addr, ulong *sizep);
+ const char *file_path, ulong addr,
+ enum image_type_t type, ulong *sizep);
/**
* bootmeth_get_bootflow() - Get a bootflow from a global bootmeth
--
2.34.1
next prev parent reply other threads:[~2024-10-17 23:29 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-17 23:23 [PATCH 00/34] bootstd: Support recording images Simon Glass
2024-10-17 23:23 ` [PATCH 01/34] alist: Mention the error condition in alist_add_placeholder() Simon Glass
2024-10-17 23:23 ` [PATCH 02/34] alist: Add a comment for alist_init_struct() Simon Glass
2024-10-17 23:23 ` [PATCH 03/34] alist: Expand the comment for alist_get() Simon Glass
2024-10-17 23:23 ` [PATCH 04/34] alist: Add a way to get the next element Simon Glass
2024-10-17 23:23 ` [PATCH 05/34] alist: Add for-loop helpers Simon Glass
2024-10-17 23:23 ` [PATCH 06/34] alist: Add a function to empty the list Simon Glass
2024-10-17 23:23 ` [PATCH 07/34] alist: Add a way to efficiently filter an alist Simon Glass
2024-10-17 23:23 ` [PATCH 08/34] dm: core: Add a function to see if a device exists Simon Glass
2024-10-17 23:23 ` [PATCH 09/34] test: boot: Use a consistent name for the script bootmeth Simon Glass
2024-10-17 23:23 ` [PATCH 10/34] bootstd: Move bootflow-adding to bootstd Simon Glass
2024-10-17 23:23 ` [PATCH 11/34] bootstd: Move bootflow-clearing " Simon Glass
2024-10-17 23:23 ` [PATCH 12/34] bootstd: Add a function to get bootstd only if available Simon Glass
2024-10-17 23:23 ` [PATCH 13/34] bootstd: Drop the bootdev-specific list of bootflows Simon Glass
2024-10-17 23:23 ` [PATCH 14/34] bootstd: Move the bootflow list into an alist Simon Glass
2024-10-17 23:23 ` [PATCH 15/34] image: Add a new type for extlinux Simon Glass
2024-10-18 3:14 ` Tom Rini
2024-10-18 14:57 ` Simon Glass
2024-10-18 15:17 ` Tom Rini
2024-10-18 17:20 ` Simon Glass
2024-10-18 17:54 ` Tom Rini
2024-10-18 18:19 ` Simon Glass
2024-10-18 18:31 ` Tom Rini
2024-10-17 23:23 ` [PATCH 16/34] image: Add a new type for EFI apps Simon Glass
2024-10-18 9:03 ` Mark Kettenis
2024-10-18 14:55 ` Simon Glass
2024-10-17 23:23 ` [PATCH 17/34] image: Add a new type for logo images Simon Glass
2024-10-17 23:23 ` [PATCH 18/34] image: Add a new type for a command-line string Simon Glass
2024-10-17 23:23 ` [PATCH 19/34] test: Expand implementation of ut_list_has_dm_tests() Simon Glass
2024-10-17 23:23 ` [PATCH 20/34] test: Drop the duplicate line in setup_bootmenu_image() Simon Glass
2024-10-17 23:24 ` [PATCH 21/34] test: boot: Update bootflow_iter() for console checking Simon Glass
2024-10-17 23:24 ` [PATCH 22/34] bootstd: cros: Correct the x86-setup address Simon Glass
2024-10-17 23:24 ` [PATCH 23/34] bootstd: Maintain a list of images Simon Glass
2024-10-18 3:14 ` Tom Rini
2024-10-18 4:01 ` Heinrich Schuchardt
2024-10-18 15:01 ` Simon Glass
2024-10-18 16:33 ` Tom Rini
2024-10-18 17:20 ` Simon Glass
2024-10-18 18:04 ` Tom Rini
2024-10-18 18:48 ` Simon Glass
2024-10-18 21:30 ` Tom Rini
2024-10-19 11:49 ` Simon Glass
2024-10-19 16:30 ` Tom Rini
2024-10-22 12:16 ` Simon Glass
2024-10-22 15:01 ` Tom Rini
2024-10-22 17:00 ` Simon Glass
2024-10-23 18:41 ` Tom Rini
2024-10-31 18:04 ` Simon Glass
2024-10-17 23:24 ` [PATCH 24/34] bootstd: Update bootmeth_alloc_file() to record images Simon Glass
2024-10-17 23:24 ` [PATCH 25/34] boot: pxe: Drop the duplicate comment on get_pxe_file() Simon Glass
2024-10-17 23:24 ` [PATCH 26/34] efi: Simplify reading files by using the common function Simon Glass
2024-10-18 3:14 ` Tom Rini
2024-10-17 23:24 ` Simon Glass [this message]
2024-10-17 23:24 ` [PATCH 28/34] efi: Check the filename-allocation in the network path Simon Glass
2024-10-17 23:24 ` [PATCH 29/34] boot: Update extlinux pxe_getfile_func() to include type Simon Glass
2024-10-17 23:24 ` [PATCH 30/34] boot: Update pxe bootmeth to record images Simon Glass
2024-10-17 23:24 ` [PATCH 31/34] Update bootmeth_alloc_other() " Simon Glass
2024-10-17 23:24 ` [PATCH 32/34] bootstd: Avoid showing an invalid buffer address Simon Glass
2024-10-17 23:24 ` [PATCH 33/34] bootstd: Update cros bootmeth to record images Simon Glass
2024-10-17 23:24 ` [PATCH 34/34] bootstd: Add a simple command to list images Simon Glass
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=20241017232413.724808-28-sjg@chromium.org \
--to=sjg@chromium.org \
--cc=akashi.tkhro@gmail.com \
--cc=glaroque@baylibre.com \
--cc=i@shantur.com \
--cc=ilias.apalodimas@linaro.org \
--cc=ion@agorria.com \
--cc=jmasson@baylibre.com \
--cc=kettenis@openbsd.org \
--cc=martyn.welch@collabora.com \
--cc=mkorpershoek@baylibre.com \
--cc=quentin.schulz@cherry.de \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=vincent.stehle@arm.com \
--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 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.