binman: Read the skip-at-start value on startup

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>
This commit is contained in:
Simon Glass
2025-02-15 19:02:36 -07:00
parent c3d3534806
commit 96b0a77da0

View File

@@ -16,12 +16,15 @@
* 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));