[PATCH 24/34] bootstd: Update bootmeth_alloc_file() to record images
Simon Glass
sjg at chromium.org
Fri Oct 18 01:24:03 CEST 2024
As a first step to recording images and where they came from, update
this function to do so, since it is used by two bootmeths
Signed-off-by: Simon Glass <sjg at chromium.org>
---
boot/bootmeth-uclass.c | 17 ++++++++++++++++-
boot/bootmeth_extlinux.c | 2 +-
boot/bootmeth_script.c | 3 ++-
include/bootmeth.h | 5 ++++-
4 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/boot/bootmeth-uclass.c b/boot/bootmeth-uclass.c
index 5b5fea39b3b..34fff004b43 100644
--- a/boot/bootmeth-uclass.c
+++ b/boot/bootmeth-uclass.c
@@ -6,6 +6,7 @@
#define LOG_CATEGORY UCLASS_BOOTSTD
+#include <alist.h>
#include <blk.h>
#include <bootflow.h>
#include <bootmeth.h>
@@ -326,8 +327,11 @@ int bootmeth_try_file(struct bootflow *bflow, struct blk_desc *desc,
return 0;
}
-int bootmeth_alloc_file(struct bootflow *bflow, uint size_limit, uint align)
+int bootmeth_alloc_file(struct bootflow *bflow, uint size_limit, uint align,
+ enum image_type_t type)
{
+ struct bootflow_img *img;
+ char *fname;
void *buf;
uint size;
int ret;
@@ -344,6 +348,17 @@ int bootmeth_alloc_file(struct bootflow *bflow, uint size_limit, uint align)
bflow->state = BOOTFLOWST_READY;
bflow->buf = buf;
+ fname = strdup(bflow->fname);
+ if (!fname)
+ return log_msg_ret("alf", -ENOMEM);
+ img = alist_add_placeholder(&bflow->images);
+ if (!img)
+ return log_msg_ret("als", -ENOMEM);
+ img->fname = fname;
+ img->type = type;
+ img->addr = map_to_sysmem(buf);
+ img->size = size;
+
return 0;
}
diff --git a/boot/bootmeth_extlinux.c b/boot/bootmeth_extlinux.c
index be8fbf4df63..755a80350d9 100644
--- a/boot/bootmeth_extlinux.c
+++ b/boot/bootmeth_extlinux.c
@@ -159,7 +159,7 @@ static int extlinux_read_bootflow(struct udevice *dev, struct bootflow *bflow)
return log_msg_ret("try", ret);
size = bflow->size;
- ret = bootmeth_alloc_file(bflow, 0x10000, 1);
+ ret = bootmeth_alloc_file(bflow, 0x10000, 1, IH_TYPE_EXTLINUX_CFG);
if (ret)
return log_msg_ret("read", ret);
diff --git a/boot/bootmeth_script.c b/boot/bootmeth_script.c
index c5cbf18c2e6..f01b22b064d 100644
--- a/boot/bootmeth_script.c
+++ b/boot/bootmeth_script.c
@@ -98,7 +98,8 @@ static int script_read_bootflow_file(struct udevice *bootstd,
if (!bflow->subdir)
return log_msg_ret("prefix", -ENOMEM);
- ret = bootmeth_alloc_file(bflow, 0x10000, ARCH_DMA_MINALIGN);
+ ret = bootmeth_alloc_file(bflow, 0x10000, ARCH_DMA_MINALIGN,
+ IH_TYPE_SCRIPT);
if (ret)
return log_msg_ret("read", ret);
diff --git a/include/bootmeth.h b/include/bootmeth.h
index a08ebf005ad..322169c6b2e 100644
--- a/include/bootmeth.h
+++ b/include/bootmeth.h
@@ -7,6 +7,7 @@
#ifndef __bootmeth_h
#define __bootmeth_h
+#include <image.h>
#include <linux/bitops.h>
struct blk_desc;
@@ -365,10 +366,12 @@ int bootmeth_try_file(struct bootflow *bflow, struct blk_desc *desc,
* @bflow: Information about file to read
* @size_limit: Maximum file size to permit
* @align: Allocation alignment (1 for unaligned)
+ * @type: File type (IH_TYPE_...)
* Return: 0 if OK, -E2BIG if file is too large, -ENOMEM if out of memory,
* other -ve on other error
*/
-int bootmeth_alloc_file(struct bootflow *bflow, uint size_limit, uint align);
+int bootmeth_alloc_file(struct bootflow *bflow, uint size_limit, uint align,
+ enum image_type_t type);
/**
* bootmeth_alloc_other() - Allocate and read a file for a bootflow
--
2.34.1
More information about the U-Boot
mailing list