binman.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. #include <common.h>
  9. #include <binman.h>
  10. #include <dm.h>
  11. struct binman_info {
  12. ofnode image;
  13. };
  14. static struct binman_info *binman;
  15. int binman_entry_find(const char *name, struct binman_entry *entry)
  16. {
  17. ofnode node;
  18. int ret;
  19. node = ofnode_find_subnode(binman->image, name);
  20. if (!ofnode_valid(node))
  21. return log_msg_ret("no binman node", -ENOENT);
  22. ret = ofnode_read_u32(node, "image-pos", &entry->image_pos);
  23. if (ret)
  24. return log_msg_ret("bad binman node1", ret);
  25. ret = ofnode_read_u32(node, "size", &entry->size);
  26. if (ret)
  27. return log_msg_ret("bad binman node2", ret);
  28. return 0;
  29. }
  30. int binman_init(void)
  31. {
  32. binman = malloc(sizeof(struct binman_info));
  33. if (!binman)
  34. return log_msg_ret("space for binman", -ENOMEM);
  35. binman->image = ofnode_path("/binman");
  36. if (!ofnode_valid(binman->image))
  37. return log_msg_ret("binman node", -EINVAL);
  38. return 0;
  39. }