diff options
author | Tom Rini <trini@konsulko.com> | 2022-05-04 15:44:11 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-05-04 15:44:11 -0400 |
commit | b4da738152a0cf3cec5bd4649e21aece6d4292d6 (patch) | |
tree | 0fcc837c96bc237a0e7cc05d658e60f2d0db3350 /include/spl.h | |
parent | 1739a6db5403d187902dcebca548de0644c8078f (diff) | |
parent | 064334e21dde2d38a2f3535ddd593dc4b2dc4674 (diff) | |
download | u-boot-WIP/04May2022.zip u-boot-WIP/04May2022.tar.gz u-boot-WIP/04May2022.tar.bz2 |
Merge branch '2022-05-04-spl-use-common-function-for-loading-and-parsing-images'WIP/04May2022
To quote the author:
This series adds support for loading all image types (Legacy, FIT (with
and without LOAD_FIT_FULL), and i.MX) to the MMC, SPI, NOR, NET, FAT,
and EXT load methods. It does this by introducing a helper function
which handles the minutiae of invoking the proper parsing function, and
reading the rest of the image.
Hopefully, this will make it easier for load methods to support all
image types that U-Boot supports, without having undocumented
unsupported image types. I applied this to several loaders which were
invoking spl_load_simple_fit and/or spl_parse_image_header, but I did
not use it with others (e.g. DFU/RAM) which had complications in the
mix.
Diffstat (limited to 'include/spl.h')
-rw-r--r-- | include/spl.h | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/include/spl.h b/include/spl.h index 83ac583..47a35ff 100644 --- a/include/spl.h +++ b/include/spl.h @@ -253,7 +253,7 @@ struct spl_image_info { * * @dev: Pointer to the device, e.g. struct mmc * * @priv: Private data for the device - * @bl_len: Block length for reading in bytes + * @bl_len: Block length for reading in bytes; must be a power of 2 * @filename: Name of the fit image file. * @read: Function to call to read from the device */ @@ -626,6 +626,34 @@ int spl_load_image_ext_os(struct spl_image_info *spl_image, struct blk_desc *block_dev, int partition); /** + * spl_load() - Parse a header and load the image + * @spl_image: Image data which will be filled in by this function + * @bootdev: The device to load from + * @info: Describes how to load additional information from @bootdev. At the + * minimum, read() and bl_len must be populated. + * @header: The image header. This should already have been loaded. It may be + * clobbered by the load process (if e.g. the load address overlaps). + * @size: The size of the image, if it is known in advance. Some boot devices + * (such as filesystems) know how big an image is before parsing the + * header. If this information is unknown, then the size will be + * determined from the header. + * @sectors: The offset from the start if @bootdev, in units of @info->bl_len. + * This should have the offset @header was loaded from. It will be + * added to any offsets passed to @info->read(). + * + * This function determines the image type (FIT, legacy, i.MX, raw, etc), calls + * the appropriate parsing function, determines the load address, and the loads + * the image from storage. It is designed to replace ad-hoc image loading which + * may not support all image types (especially when config options are + * involved). + * + * Return: 0 on success, or a negative error on failure + */ +int spl_load(struct spl_image_info *spl_image, + const struct spl_boot_device *bootdev, struct spl_load_info *info, + struct image_header *header, size_t size, size_t sector); + +/** * spl_early_init() - Set up device tree and driver model in SPL if enabled * * Call this function in board_init_f() if you want to use device tree and |