On Sun, Aug 23, 2026 at 08:13:55PM +0100, Daniel Golle wrote: > Introduce imagemap, a small layer that reads image data from a storage > device on demand and keeps a translation table of the byte ranges > already loaded into RAM, instead of copying the whole image up front. > > An imagemap device (UCLASS_IMAGEMAP) is created over a partition of a > block device with imagemap_create(); imagemap_map() then returns a RAM > pointer for any byte range, reading it in on first access and reusing > it on later accesses -- so a header probe, verification and the final > load of the same range share a single read. Block devices cover more > than raw disks: an MTD partition is reached through mtdblock and a UBI > volume through ubiblock, each exposed as a named block-device > partition, so imagemap needs no storage-specific code of its own. > > The read path is built on the SPL struct spl_load_info abstraction and > a new spl_load_region() helper (added to spl.h): the block reader > reports the device block length and spl_load_region() performs the > native sector alignment. imagemap_map_to() keeps a payload byte-exact > at a caller's load address, reading the aligned middle straight to the > destination and bouncing only the partial head/tail block. > > Regions that are not placed at a caller-supplied address are allocated > through the LMB allocator and released on cleanup; the translation > table doubles as the registry of those allocations. imagemap is gated > to the full-U-Boot phase, so SPL and TPL carry no new cost. > > Signed-off-by: Daniel Golle <[email protected]> > --- [snip] > diff --git a/include/spl.h b/include/spl.h > index 5078d7525ab..24df44d23e1 100644 > --- a/include/spl.h > +++ b/include/spl.h > @@ -350,10 +350,21 @@ typedef ulong (*spl_load_reader)(struct spl_load_info > *load, ulong sector, > * @phase: Image phase to load > * @no_fdt_update: true to update the FDT with any loadables that are loaded > */ > +/* > + * struct spl_load_info carries a device block length for the SPL block > + * loaders (CONFIG_SPL_LOAD_BLOCK) and, in full U-Boot, for the imagemap > + * on-demand loader (CONFIG_IMAGEMAP);
This part should be made clear in updates to the existing comment block.
> imagemap is gated out of the xpl
> + * phases so SPL and TPL carry no new cost.
This doesn't need to be noted I think because..
> + */
> +#if IS_ENABLED(CONFIG_SPL_LOAD_BLOCK) || \
> + (IS_ENABLED(CONFIG_IMAGEMAP) && !defined(CONFIG_XPL_BUILD))
> +#define SPL_LOAD_INFO_HAS_BL_LEN
> +#endif
> +
> struct spl_load_info {
> spl_load_reader read;
> void *priv;
> -#if IS_ENABLED(CONFIG_SPL_LOAD_BLOCK)
> +#ifdef SPL_LOAD_INFO_HAS_BL_LEN
Why not just:
#if IS_ENABLED(CONFIG_SPL_LOAD_BLOCK) || CONFIG_IS_ENABLED(IMAGEMAP)
? Then for when someone says "Ah, I want to do all of this right in SPL"
there's less changes.
--
Tom
signature.asc
Description: PGP signature
