[PATCH 31/34] Update bootmeth_alloc_other() to record images
Simon Glass
sjg at chromium.org
Fri Oct 18 01:24:10 CEST 2024
Update this function to add the image to the list.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
boot/bootmeth-uclass.c | 15 ++++++++++++++-
boot/bootmeth_script.c | 4 ++--
include/bootmeth.h | 3 ++-
3 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/boot/bootmeth-uclass.c b/boot/bootmeth-uclass.c
index 726393e20b8..fcfffa41533 100644
--- a/boot/bootmeth-uclass.c
+++ b/boot/bootmeth-uclass.c
@@ -364,9 +364,11 @@ int bootmeth_alloc_file(struct bootflow *bflow, uint size_limit, uint align,
}
int bootmeth_alloc_other(struct bootflow *bflow, const char *fname,
- void **bufp, uint *sizep)
+ enum image_type_t type, void **bufp, uint *sizep)
{
struct blk_desc *desc = NULL;
+ struct bootflow_img *img;
+ char *img_fname;
char path[200];
loff_t size;
void *buf;
@@ -393,6 +395,17 @@ int bootmeth_alloc_other(struct bootflow *bflow, const char *fname,
if (ret)
return log_msg_ret("all", ret);
+ img_fname = strdup(fname);
+ if (!img_fname)
+ return log_msg_ret("alf", -ENOMEM);
+ img = alist_add_placeholder(&bflow->images);
+ if (!img)
+ return log_msg_ret("als", -ENOMEM);
+ img->fname = img_fname;
+ img->type = type;
+ img->addr = map_to_sysmem(buf);
+ img->size = size;
+
*bufp = buf;
*sizep = size;
diff --git a/boot/bootmeth_script.c b/boot/bootmeth_script.c
index f01b22b064d..e648e42a24e 100644
--- a/boot/bootmeth_script.c
+++ b/boot/bootmeth_script.c
@@ -107,8 +107,8 @@ static int script_read_bootflow_file(struct udevice *bootstd,
if (ret)
return log_msg_ret("inf", ret);
- ret = bootmeth_alloc_other(bflow, "boot.bmp", &bflow->logo,
- &bflow->logo_size);
+ ret = bootmeth_alloc_other(bflow, "boot.bmp", IH_TYPE_LOGO,
+ &bflow->logo, &bflow->logo_size);
/* ignore error */
return 0;
diff --git a/include/bootmeth.h b/include/bootmeth.h
index 78b2ce4123b..7382f76c0b8 100644
--- a/include/bootmeth.h
+++ b/include/bootmeth.h
@@ -386,12 +386,13 @@ int bootmeth_alloc_file(struct bootflow *bflow, uint size_limit, uint align,
*
* @bflow: Information about file to read
* @fname: Filename to read from (within bootflow->subdir)
+ * @type: File type (IH_TYPE_...)
* @bufp: Returns a pointer to the allocated buffer
* @sizep: Returns the size of the buffer
* Return: 0 if OK, -ENOMEM if out of memory, other -ve on other error
*/
int bootmeth_alloc_other(struct bootflow *bflow, const char *fname,
- void **bufp, uint *sizep);
+ enum image_type_t type, void **bufp, uint *sizep);
/**
* bootmeth_common_read_file() - Common handler for reading a file
--
2.34.1
More information about the U-Boot
mailing list