summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-07-07 21:32:04 -0600
committerBin Meng <bmeng.cn@gmail.com>2020-07-17 14:32:24 +0800
commit8f9877df95ae0068ce14a962bd72c22026c1d2e8 (patch)
tree1e69d065586341d31e78dd8679ca6be934c893d5 /lib
parent956a9082d325fae2b8c840d6974b6d090a8a21a7 (diff)
binman: Add way to locate an entry in memory
Add support for accessing an entry's contents in memory-mapped SPI flash. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/binman.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/binman.c b/lib/binman.c
index 9098a1dffa..7a8ad62c4a 100644
--- a/lib/binman.c
+++ b/lib/binman.c
@@ -11,6 +11,7 @@
#include <dm.h>
#include <log.h>
#include <malloc.h>
+#include <mapmem.h>
/**
* struct binman_info - Information needed by the binman library
@@ -55,6 +56,28 @@ int binman_entry_find(const char *name, struct binman_entry *entry)
return binman_entry_find_internal(binman->image, name, entry);
}
+int binman_entry_map(ofnode parent, const char *name, void **bufp, int *sizep)
+{
+ struct binman_entry entry;
+ int ret;
+
+ if (binman->rom_offset == ROM_OFFSET_NONE)
+ return -EPERM;
+ ret = binman_entry_find_internal(parent, name, &entry);
+ if (ret)
+ return log_msg_ret("entry", ret);
+ if (sizep)
+ *sizep = entry.size;
+ *bufp = map_sysmem(entry.image_pos + binman->rom_offset, entry.size);
+
+ return 0;
+}
+
+ofnode binman_section_find_node(const char *name)
+{
+ return ofnode_find_subnode(binman->image, name);
+}
+
void binman_set_rom_offset(int rom_offset)
{
binman->rom_offset = rom_offset;