]> git.ipfire.org Git - thirdparty/u-boot.git/blame - lib/binman.c
dm: core: Create a new header file for 'compat' features
[thirdparty/u-boot.git] / lib / binman.c
CommitLineData
3c10dc95
SG
1// SPDX-License-Identifier: Intel
2/*
3 * Access to binman information at runtime
4 *
5 * Copyright 2019 Google LLC
6 * Written by Simon Glass <sjg@chromium.org>
7 */
8
9#include <common.h>
10#include <binman.h>
11#include <dm.h>
336d4615 12#include <malloc.h>
3c10dc95
SG
13
14struct binman_info {
15 ofnode image;
16};
17
18static struct binman_info *binman;
19
20int binman_entry_find(const char *name, struct binman_entry *entry)
21{
22 ofnode node;
23 int ret;
24
25 node = ofnode_find_subnode(binman->image, name);
26 if (!ofnode_valid(node))
27 return log_msg_ret("no binman node", -ENOENT);
28
29 ret = ofnode_read_u32(node, "image-pos", &entry->image_pos);
30 if (ret)
31 return log_msg_ret("bad binman node1", ret);
32 ret = ofnode_read_u32(node, "size", &entry->size);
33 if (ret)
34 return log_msg_ret("bad binman node2", ret);
35
36 return 0;
37}
38
39int binman_init(void)
40{
41 binman = malloc(sizeof(struct binman_info));
42 if (!binman)
43 return log_msg_ret("space for binman", -ENOMEM);
44 binman->image = ofnode_path("/binman");
45 if (!ofnode_valid(binman->image))
46 return log_msg_ret("binman node", -EINVAL);
47
48 return 0;
49}