spl: Refactor spl_load_info->read to use units of bytes

Simplify things a bit for callers of spl_load_info->read by refactoring it
to use units of bytes instead of bl_len. This generally simplifies the
logic, as MMC is the only loader which actually works in sectors. It will
also allow further refactoring to remove the special-case handling of
filename.  spl_load_legacy_img already works in units of bytes (oops) so it
doesn't need to be changed.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Sean Anderson
2023-11-08 11:48:40 -05:00
committed by Tom Rini
parent 33c8d01a4d
commit 73c40fcb73
7 changed files with 82 additions and 93 deletions

View File

@@ -297,10 +297,12 @@ struct spl_load_info {
* read() - Read from device
*
* @load: Information about the load state
* @sector: Sector number to read from (each @load->bl_len bytes)
* @count: Number of sectors to read
* @offset: Offset to read from in bytes. This must be a multiple of
* @load->bl_len.
* @count: Number of bytes to read. This must be a multiple of
* @load->bl_len.
* @buf: Buffer to read into
* @return number of sectors read, 0 on error
* @return number of bytes read, 0 on error
*/
ulong (*read)(struct spl_load_info *load, ulong sector, ulong count,
void *buf);
@@ -368,7 +370,8 @@ void *spl_load_simple_fit_fix_load(const void *fit);
* spl_load_simple_fit() - Loads a fit image from a device.
* @spl_image: Image description to set up
* @info: Structure containing the information required to load data.
* @sector: Sector number where FIT image is located in the device
* @offset: Offset where FIT image is located in the device. Must be aligned
* to the device's bl_len.
* @fdt: Pointer to the copied FIT header.
*
* Reads the FIT image @sector in the device. Loads u-boot image to
@@ -376,7 +379,7 @@ void *spl_load_simple_fit_fix_load(const void *fit);
* Returns 0 on success.
*/
int spl_load_simple_fit(struct spl_image_info *spl_image,
struct spl_load_info *info, ulong sector, void *fdt);
struct spl_load_info *info, ulong offset, void *fdt);
#define SPL_COPY_PAYLOAD_ONLY 1
#define SPL_FIT_FOUND 2
@@ -402,13 +405,14 @@ int spl_load_legacy_img(struct spl_image_info *spl_image,
* spl_load_imx_container() - Loads a imx container image from a device.
* @spl_image: Image description to set up
* @info: Structure containing the information required to load data.
* @sector: Sector number where container image is located in the device
* @sector: Offset where container image is located in the device. Must be
* aligned to the device block size.
*
* Reads the container image @sector in the device. Loads u-boot image to
* specified load address.
*/
int spl_load_imx_container(struct spl_image_info *spl_image,
struct spl_load_info *info, ulong sector);
struct spl_load_info *info, ulong offset);
/* SPL common functions */
void preloader_console_init(void);