index.rst 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. Firmware Configuration Framework
  2. ================================
  3. This document provides an overview of the |FCONF| framework.
  4. Introduction
  5. ~~~~~~~~~~~~
  6. The Firmware CONfiguration Framework (|FCONF|) is an abstraction layer for
  7. platform specific data, allowing a "property" to be queried and a value
  8. retrieved without the requesting entity knowing what backing store is being used
  9. to hold the data.
  10. It is used to bridge new and old ways of providing platform-specific data.
  11. Today, information like the Chain of Trust is held within several, nested
  12. platform-defined tables. In the future, it may be provided as part of a device
  13. blob, along with the rest of the information about images to load.
  14. Introducing this abstraction layer will make migration easier and will preserve
  15. functionality for platforms that cannot / don't want to use device tree.
  16. Accessing properties
  17. ~~~~~~~~~~~~~~~~~~~~
  18. Properties defined in the |FCONF| are grouped around namespaces and
  19. sub-namespaces: a.b.property.
  20. Examples namespace can be:
  21. - (|TBBR|) Chain of Trust data: tbbr.cot.trusted_boot_fw_cert
  22. - (|TBBR|) dynamic configuration info: tbbr.dyn_config.disable_auth
  23. - Arm io policies: arm.io_policies.bl2_image
  24. - GICv3 properties: hw_config.gicv3_config.gicr_base
  25. Properties can be accessed with the ``FCONF_GET_PROPERTY(a,b,property)`` macro.
  26. Defining properties
  27. ~~~~~~~~~~~~~~~~~~~
  28. Properties composing the |FCONF| have to be stored in C structures. If
  29. properties originate from a different backend source such as a device tree,
  30. then the platform has to provide a ``populate()`` function which essentially
  31. captures the property and stores them into a corresponding |FCONF| based C
  32. structure.
  33. Such a ``populate()`` function is usually platform specific and is associated
  34. with a specific backend source. For example, a populator function which
  35. captures the hardware topology of the platform from the HW_CONFIG device tree.
  36. Hence each ``populate()`` function must be registered with a specific
  37. ``config_type`` identifier. It broadly represents a logical grouping of
  38. configuration properties which is usually a device tree file.
  39. Example:
  40. - FW_CONFIG: properties related to base address, maximum size and image id
  41. of other DTBs etc.
  42. - TB_FW: properties related to trusted firmware such as IO policies,
  43. mbedtls heap info etc.
  44. - HW_CONFIG: properties related to hardware configuration of the SoC
  45. such as topology, GIC controller, PSCI hooks, CPU ID etc.
  46. Hence the ``populate()`` callback must be registered to the (|FCONF|) framework
  47. with the ``FCONF_REGISTER_POPULATOR()`` macro. This ensures that the function
  48. would be called inside the generic ``fconf_populate()`` function during
  49. initialization.
  50. ::
  51. int fconf_populate_topology(uintptr_t config)
  52. {
  53. /* read hw config dtb and fill soc_topology struct */
  54. }
  55. FCONF_REGISTER_POPULATOR(HW_CONFIG, topology, fconf_populate_topology);
  56. Then, a wrapper has to be provided to match the ``FCONF_GET_PROPERTY()`` macro:
  57. ::
  58. /* generic getter */
  59. #define FCONF_GET_PROPERTY(a,b,property) a##__##b##_getter(property)
  60. /* my specific getter */
  61. #define hw_config__topology_getter(prop) soc_topology.prop
  62. This second level wrapper can be used to remap the ``FCONF_GET_PROPERTY()`` to
  63. anything appropriate: structure, array, function, etc..
  64. To ensure a good interpretation of the properties, this documentation must
  65. explain how the properties are described for a specific backend. Refer to the
  66. :ref:`binding-document` section for more information and example.
  67. Loading the property device tree
  68. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  69. The ``fconf_load_config(image_id)`` must be called to load fw_config and
  70. tb_fw_config devices tree containing the properties' values. This must be done
  71. after the io layer is initialized, as the |DTB| is stored on an external
  72. device (FIP).
  73. .. uml:: ../../resources/diagrams/plantuml/fconf_bl1_load_config.puml
  74. Populating the properties
  75. ~~~~~~~~~~~~~~~~~~~~~~~~~
  76. Once a valid device tree is available, the ``fconf_populate(config)`` function
  77. can be used to fill the C data structure with the data from the config |DTB|.
  78. This function will call all the ``populate()`` callbacks which have been
  79. registered with ``FCONF_REGISTER_POPULATOR()`` as described above.
  80. .. uml:: ../../resources/diagrams/plantuml/fconf_bl2_populate.puml
  81. Namespace guidance
  82. ~~~~~~~~~~~~~~~~~~
  83. As mentioned above, properties are logically grouped around namespaces and
  84. sub-namespaces. The following concepts should be considered when adding new
  85. properties/namespaces.
  86. The framework differentiates two types of properties:
  87. - Properties used inside common code.
  88. - Properties used inside platform specific code.
  89. The first category applies to properties being part of the firmware and shared
  90. across multiple platforms. They should be globally accessible and defined
  91. inside the ``lib/fconf`` directory. The namespace must be chosen to reflect the
  92. feature/data abstracted.
  93. Example:
  94. - |TBBR| related properties: tbbr.cot.bl2_id
  95. - Dynamic configuration information: dyn_cfg.dtb_info.hw_config_id
  96. The second category should represent the majority of the properties defined
  97. within the framework: Platform specific properties. They must be accessed only
  98. within the platform API and are defined only inside the platform scope. The
  99. namespace must contain the platform name under which the properties defined
  100. belong.
  101. Example:
  102. - Arm io framework: arm.io_policies.bl31_id
  103. .. _binding-document:
  104. Properties binding information
  105. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  106. .. toctree::
  107. :maxdepth: 1
  108. fconf_properties
  109. amu-bindings
  110. mpmm-bindings
  111. tb_fw_bindings