]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
binman: Read the skip-at-start value on startup
authorSimon Glass <sjg@chromium.org>
Sun, 16 Feb 2025 02:02:36 +0000 (19:02 -0700)
committerSimon Glass <sjg@chromium.org>
Tue, 27 May 2025 09:07:36 +0000 (10:07 +0100)
This value provides an offset for all image-pos values in the image.
Read it on startup so that we can take account of it when calculating
positions.

Signed-off-by: Simon Glass <sjg@chromium.org>
lib/binman.c

index 9047f5275f3250ae1106b859f311a16e0c34cbf6..a594fe4c2ca61f47f277602d30ff118a199cc67a 100644 (file)
  * struct binman_info - Information needed by the binman library
  *
  * @image: Node describing the image we are running from
+ * @skip_at_start: Number of bytes skipped at the start of the image. This is
+ *     the value of the skip-at-start property for the image
  * @rom_offset: Offset from an image_pos to the memory-mapped address, or
  *     ROM_OFFSET_NONE if the ROM is not memory-mapped. Can be positive or
  *     negative
  */
 struct binman_info {
        ofnode image;
+       uint skip_at_start;
        int rom_offset;
 };
 
@@ -80,7 +83,14 @@ static int binman_entry_find_internal(ofnode node, const char *name,
 
 int binman_entry_find(const char *name, struct binman_entry *entry)
 {
-       return binman_entry_find_internal(binman->image, name, entry);
+       int ret;
+
+       ret = binman_entry_find_internal(binman->image, name, entry);
+       if (ret)
+               return log_msg_ret("bef", ret);
+       entry->image_pos -= binman->skip_at_start;
+
+       return 0;
 }
 
 int binman_entry_map(ofnode parent, const char *name, void **bufp, int *sizep)
@@ -107,7 +117,7 @@ ofnode binman_section_find_node(const char *name)
 
 void binman_set_rom_offset(int rom_offset)
 {
-       binman->rom_offset = rom_offset;
+       binman->rom_offset = rom_offset - binman->skip_at_start;
 }
 
 int binman_get_rom_offset(void)
@@ -140,10 +150,12 @@ int binman_init(void)
        binman = malloc(sizeof(struct binman_info));
        if (!binman)
                return log_msg_ret("space for binman", -ENOMEM);
+       memset(binman, '\0', sizeof(struct binman_info));
        ret = find_image_node(&binman->image);
        if (ret)
                return log_msg_ret("node", -ENOENT);
        binman_set_rom_offset(ROM_OFFSET_NONE);
+       ofnode_read_u32(binman->image, "skip-at-start", &binman->skip_at_start);
        log_debug("binman: Selected image node '%s'\n",
                  ofnode_get_name(binman->image));