[PATCH 6/9] boot: imagemap: Clarify region replacement

Daniel Golle daniel at makrotopia.org
Fri Nov 13 16:11:40 PST 2026


The comments describe replacing a region only when it grows, but the
table keeps one region per image offset. Document replacement and
pointer lifetime, and update the allocation and extension descriptions.

Signed-off-by: Daniel Golle <daniel at makrotopia.org>
---
 boot/imagemap.c    |  6 +++---
 include/imagemap.h | 13 +++++++++----
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/boot/imagemap.c b/boot/imagemap.c
index 0e3fbd0934a..8455763815e 100644
--- a/boot/imagemap.c
+++ b/boot/imagemap.c
@@ -96,8 +96,8 @@ void *imagemap_lookup(struct udevice *dev, loff_t img_offset, ulong size)
 /**
  * imagemap_record() - Record a region in the translation table
  *
- * If an entry with the same img_offset already exists and the new size
- * is larger, update the existing entry. Otherwise add a new entry.
+ * An entry with the same img_offset is replaced, releasing a reservation
+ * it owns at a different address. Otherwise a new entry is added.
  *
  * @dev:		The imagemap device
  * @img_offset:		Byte offset within the source image
@@ -114,7 +114,7 @@ imagemap_record(struct udevice *dev, loff_t img_offset, ulong size,
 	struct imagemap_region *r;
 	struct imagemap_region entry;
 
-	/* Check for an existing entry at the same base that we can extend */
+	/* Each image offset has one entry */
 	alist_for_each(r, &priv->regions) {
 		if (r->img_offset != img_offset)
 			continue;
diff --git a/include/imagemap.h b/include/imagemap.h
index 984a2fa8934..dad438094af 100644
--- a/include/imagemap.h
+++ b/include/imagemap.h
@@ -74,8 +74,9 @@ void *imagemap_lookup(struct udevice *dev, loff_t img_offset, ulong size);
  * new pointer.
  *
  * If the requested range starts at the same offset as an existing
- * region but is larger, the existing region is extended (LMB
- * reservation adjusted, data re-read).
+ * region but is larger, the existing region is extended and only the
+ * added bytes are read. The region may move to a new address, after
+ * which pointers returned for it earlier are no longer valid.
  *
  * @dev:	The imagemap device
  * @img_offset:	Byte offset within the source image
@@ -88,8 +89,12 @@ void *imagemap_map(struct udevice *dev, loff_t img_offset, ulong size);
  * imagemap_map_to() - Load an image region to a specific RAM address
  *
  * Like imagemap_map() but reads into a caller-specified address
- * instead of allocating from the scratch area. Used when the sub-image
- * has a known load address for a zero-copy path.
+ * instead of allocating one. Used when the sub-image has a known load
+ * address for a zero-copy path.
+ *
+ * Each image offset has one region. A region already recorded at
+ * @img_offset is replaced: a reservation it owns is released and
+ * pointers returned for it earlier are no longer valid.
  *
  * @dev:	The imagemap device
  * @img_offset:	Byte offset within the source image
-- 
2.56.0



More information about the openwrt-devel mailing list