From f4f4123708cd3699aa3981afca9511beb760c7fb Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 27 Sep 2020 18:46:19 -0600 Subject: binman: Add a way to read the ROM offset Provide a function to read the ROM offset so that we can store the value in one place and clients don't need to store it themselves after calling binman_set_rom_offset(). Signed-off-by: Simon Glass --- lib/binman.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/binman.c b/lib/binman.c index 7a8ad62c4a..79e497fc8d 100644 --- a/lib/binman.c +++ b/lib/binman.c @@ -43,7 +43,7 @@ static int binman_entry_find_internal(ofnode node, const char *name, ret = ofnode_read_u32(node, "image-pos", &entry->image_pos); if (ret) - return log_msg_ret("import-pos", ret); + return log_msg_ret("image-pos", ret); ret = ofnode_read_u32(node, "size", &entry->size); if (ret) return log_msg_ret("size", ret); @@ -83,6 +83,11 @@ void binman_set_rom_offset(int rom_offset) binman->rom_offset = rom_offset; } +int binman_get_rom_offset(void) +{ + return binman->rom_offset; +} + int binman_init(void) { binman = malloc(sizeof(struct binman_info)); -- cgit v1.2.3 From 83187546ae14e266c745c3bb24db492eb5433b89 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 27 Sep 2020 18:46:20 -0600 Subject: binman: Support multiple images in the library Add support for multiple images, since these are used on x86 now. Select the first image for now, since that is generally the correct one. At some point we can add a way to determine which image is currently running. Signed-off-by: Simon Glass --- lib/binman.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib') diff --git a/lib/binman.c b/lib/binman.c index 79e497fc8d..e71c1b9e99 100644 --- a/lib/binman.c +++ b/lib/binman.c @@ -96,6 +96,13 @@ int binman_init(void) binman->image = ofnode_path("/binman"); if (!ofnode_valid(binman->image)) return log_msg_ret("binman node", -EINVAL); + if (ofnode_read_bool(binman->image, "multiple-images")) { + ofnode node = ofnode_first_subnode(binman->image); + + if (!ofnode_valid(node)) + return log_msg_ret("first image", -ENOENT); + binman->image = node; + } binman->rom_offset = ROM_OFFSET_NONE; return 0; -- cgit v1.2.3