binman: Add a way to read the ROM offset
authorSimon Glass <sjg@chromium.org>
Mon, 28 Sep 2020 00:46:19 +0000 (18:46 -0600)
committerSimon Glass <sjg@chromium.org>
Thu, 29 Oct 2020 20:42:17 +0000 (14:42 -0600)
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 <sjg@chromium.org>
include/binman.h
lib/binman.c

index e0b9207..8b89a96 100644 (file)
@@ -43,6 +43,13 @@ int binman_entry_map(ofnode parent, const char *name, void **bufp, int *sizep);
 void binman_set_rom_offset(int rom_offset);
 
 /**
+ * binman_get_rom_offset() - Get the ROM memory-map offset
+ *
+ * @returns offset from an image_pos to the memory-mapped address
+ */
+int binman_get_rom_offset(void);
+
+/**
  * binman_entry_find() - Find a binman symbol
  *
  * This searches the binman information in the device tree for a symbol of the
index 7a8ad62..79e497f 100644 (file)
@@ -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));