fconf.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright (c) 2019-2022, Arm Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef FCONF_H
  7. #define FCONF_H
  8. #include <stddef.h>
  9. #include <stdint.h>
  10. /* Public API */
  11. #define FCONF_GET_PROPERTY(a, b, c) a##__##b##_getter(c)
  12. /*
  13. * This macro takes three arguments:
  14. * config: Configuration identifier
  15. * name: property namespace
  16. * callback: populate() function
  17. */
  18. #define FCONF_REGISTER_POPULATOR(config, name, callback) \
  19. __attribute__((used, section(".fconf_populator"))) \
  20. static const struct fconf_populator (name##__populator) = { \
  21. .config_type = (#config), \
  22. .info = (#name), \
  23. .populate = (callback) \
  24. };
  25. /*
  26. * Populator callback
  27. *
  28. * This structure are used by the fconf_populate function and should only be
  29. * defined by the FCONF_REGISTER_POPULATOR macro.
  30. */
  31. struct fconf_populator {
  32. /* Description of the data loaded by the callback */
  33. const char *config_type;
  34. const char *info;
  35. /* Callback used by fconf_populate function with a provided config dtb.
  36. * Return 0 on success, err_code < 0 otherwise.
  37. */
  38. int (*populate)(uintptr_t config);
  39. };
  40. /* This function supports to load tb_fw_config and fw_config dtb */
  41. int fconf_load_config(unsigned int image_id);
  42. /* Top level populate function
  43. *
  44. * This function takes a configuration dtb and calls all the registered
  45. * populator callback with it.
  46. *
  47. * Panic on error.
  48. */
  49. void fconf_populate(const char *config_type, uintptr_t config);
  50. /* FCONF specific getter */
  51. #define fconf__dtb_getter(prop) fconf_dtb_info.prop
  52. /* Structure used to locally keep a reference to the config dtb. */
  53. struct fconf_dtb_info_t {
  54. uintptr_t base_addr;
  55. size_t size;
  56. };
  57. extern struct fconf_dtb_info_t fconf_dtb_info;
  58. #endif /* FCONF_H */