bootstd: Update bootmeth_alloc_file() to record images
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
Create a helper function in the bootflow system, since recorded
images are always associated with bootflows.
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/include/bootflow.h b/include/bootflow.h
index f407bb3..e09cff2 100644
--- a/include/bootflow.h
+++ b/include/bootflow.h
@@ -613,4 +613,19 @@
* Return: Image name, or "unknown" if not known
*/
const char *bootflow_img_type_name(enum bootflow_img_t type);
+
+/**
+ * bootflow_img_add() - Add a new image to a bootflow
+ *
+ * @bflow: Bootflow to add to
+ * @fname: Image filename (will be allocated)
+ * @type: Image type
+ * @addr: Address the image was loaded to, or 0 if not loaded
+ * @size: Image size
+ * Return: pointer to the added image, or NULL if out of memory
+ */
+struct bootflow_img *bootflow_img_add(struct bootflow *bflow, const char *fname,
+ enum bootflow_img_t type, ulong addr,
+ ulong size);
+
#endif
diff --git a/include/bootmeth.h b/include/bootmeth.h
index a08ebf0..e812974 100644
--- a/include/bootmeth.h
+++ b/include/bootmeth.h
@@ -7,11 +7,11 @@
#ifndef __bootmeth_h
#define __bootmeth_h
+#include <bootflow.h>
+#include <image.h>
#include <linux/bitops.h>
struct blk_desc;
-struct bootflow;
-struct bootflow_iter;
struct udevice;
/**
@@ -365,10 +365,12 @@
* @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 bootflow_img_t type);
/**
* bootmeth_alloc_other() - Allocate and read a file for a bootflow