binman.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. #ifndef _BINMAN_H_
  9. #define _BINMAN_H_
  10. #include <dm/ofnode.h>
  11. /**
  12. *struct binman_entry - information about a binman entry
  13. *
  14. * @image_pos: Position of entry in the image
  15. * @size: Size of entry
  16. */
  17. struct binman_entry {
  18. u32 image_pos;
  19. u32 size;
  20. };
  21. /**
  22. * binman_entry_map() - Look up the address of an entry in memory
  23. *
  24. * @parent: Parent binman node
  25. * @name: Name of entry
  26. * @bufp: Returns a pointer to the entry
  27. * @sizep: Returns the size of the entry
  28. * Return: 0 on success, -EPERM if the ROM offset is not set, -ENOENT if the
  29. * entry cannot be found, other error code other error
  30. */
  31. int binman_entry_map(ofnode parent, const char *name, void **bufp, int *sizep);
  32. /**
  33. * binman_set_rom_offset() - Set the ROM memory-map offset
  34. *
  35. * @rom_offset: Offset from an image_pos to the memory-mapped address. This
  36. * tells binman that ROM image_pos x can be addressed at rom_offset + x
  37. */
  38. void binman_set_rom_offset(int rom_offset);
  39. /**
  40. * binman_get_rom_offset() - Get the ROM memory-map offset
  41. *
  42. * @returns offset from an image_pos to the memory-mapped address
  43. */
  44. int binman_get_rom_offset(void);
  45. /**
  46. * binman_entry_find() - Find a binman symbol
  47. *
  48. * This searches the binman information in the device tree for a symbol of the
  49. * given name
  50. *
  51. * @name: Path to entry to examine (e.g. "/read-only/u-boot")
  52. * @entry: Returns information about the entry
  53. * Return: 0 if OK, -ENOENT if the path is not found, other -ve value if the
  54. * binman information is invalid (missing image-pos or size)
  55. */
  56. int binman_entry_find(const char *name, struct binman_entry *entry);
  57. /**
  58. * binman_section_find_node() - Find a binman node
  59. *
  60. * @name: Name of node to look for
  61. * Return: Node that was found, ofnode_null() if not found
  62. */
  63. ofnode binman_section_find_node(const char *name);
  64. /**
  65. * binman_select_subnode() - Select a subnode to use to find entries
  66. *
  67. * Normally binman selects the top-level node for future entry requests, such as
  68. * binman_entry_find(). This function allows a subnode to be chosen instead.
  69. *
  70. * @name: Name of subnode, typically a section. This must be in the top-level
  71. * binman node
  72. * Return: 0 if OK, -EINVAL if there is no /binman node, -ECHILD if multiple
  73. * images are being used but the first image is not available, -ENOENT if
  74. * the requested subnode cannot be found
  75. */
  76. int binman_select_subnode(const char *name);
  77. /**
  78. * binman_init() - Set up the binman symbol information
  79. *
  80. * This locates the binary symbol information in the device tree ready for use
  81. *
  82. * Return: 0 if OK, -ENOMEM if out of memory, -EINVAL if there is no binman node
  83. */
  84. int binman_init(void);
  85. #endif