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