diff options
Diffstat (limited to 'lib/binman.c')
-rw-r--r-- | lib/binman.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/binman.c b/lib/binman.c index 9047f5275f3..a594fe4c2ca 100644 --- a/lib/binman.c +++ b/lib/binman.c @@ -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)); |