xref: /arm-trusted-firmware/docs/components/fconf/index.rst (revision 91f16700b400a8c0651d24a598fc48ee2997a0d7)
1*91f16700SchasingluluFirmware Configuration Framework
2*91f16700Schasinglulu================================
3*91f16700Schasinglulu
4*91f16700SchasingluluThis document provides an overview of the |FCONF| framework.
5*91f16700Schasinglulu
6*91f16700SchasingluluIntroduction
7*91f16700Schasinglulu~~~~~~~~~~~~
8*91f16700Schasinglulu
9*91f16700SchasingluluThe Firmware CONfiguration Framework (|FCONF|) is an abstraction layer for
10*91f16700Schasingluluplatform specific data, allowing a "property" to be queried and a value
11*91f16700Schasingluluretrieved without the requesting entity knowing what backing store is being used
12*91f16700Schasingluluto hold the data.
13*91f16700Schasinglulu
14*91f16700SchasingluluIt is used to bridge new and old ways of providing platform-specific data.
15*91f16700SchasingluluToday, information like the Chain of Trust is held within several, nested
16*91f16700Schasingluluplatform-defined tables. In the future, it may be provided as part of a device
17*91f16700Schasinglulublob, along with the rest of the information about images to load.
18*91f16700SchasingluluIntroducing this abstraction layer will make migration easier and will preserve
19*91f16700Schasinglulufunctionality for platforms that cannot / don't want to use device tree.
20*91f16700Schasinglulu
21*91f16700SchasingluluAccessing properties
22*91f16700Schasinglulu~~~~~~~~~~~~~~~~~~~~
23*91f16700Schasinglulu
24*91f16700SchasingluluProperties defined in the |FCONF| are grouped around namespaces and
25*91f16700Schasinglulusub-namespaces: a.b.property.
26*91f16700SchasingluluExamples namespace can be:
27*91f16700Schasinglulu
28*91f16700Schasinglulu- (|TBBR|) Chain of Trust data: tbbr.cot.trusted_boot_fw_cert
29*91f16700Schasinglulu- (|TBBR|) dynamic configuration info: tbbr.dyn_config.disable_auth
30*91f16700Schasinglulu- Arm io policies: arm.io_policies.bl2_image
31*91f16700Schasinglulu- GICv3 properties: hw_config.gicv3_config.gicr_base
32*91f16700Schasinglulu
33*91f16700SchasingluluProperties can be accessed with the ``FCONF_GET_PROPERTY(a,b,property)`` macro.
34*91f16700Schasinglulu
35*91f16700SchasingluluDefining properties
36*91f16700Schasinglulu~~~~~~~~~~~~~~~~~~~
37*91f16700Schasinglulu
38*91f16700SchasingluluProperties composing the |FCONF| have to be stored in C structures. If
39*91f16700Schasingluluproperties originate from a different backend source such as a device tree,
40*91f16700Schasingluluthen the platform has to provide a ``populate()`` function which essentially
41*91f16700Schasinglulucaptures the property and stores them into a corresponding |FCONF| based C
42*91f16700Schasinglulustructure.
43*91f16700Schasinglulu
44*91f16700SchasingluluSuch a ``populate()`` function is usually platform specific and is associated
45*91f16700Schasingluluwith a specific backend source. For example, a populator function which
46*91f16700Schasinglulucaptures the hardware topology of the platform from the HW_CONFIG device tree.
47*91f16700SchasingluluHence each ``populate()`` function must be registered with a specific
48*91f16700Schasinglulu``config_type`` identifier. It broadly represents a logical grouping of
49*91f16700Schasingluluconfiguration properties which is usually a device tree file.
50*91f16700Schasinglulu
51*91f16700SchasingluluExample:
52*91f16700Schasinglulu - FW_CONFIG: properties related to base address, maximum size and image id
53*91f16700Schasinglulu   of other DTBs etc.
54*91f16700Schasinglulu - TB_FW: properties related to trusted firmware such as IO policies,
55*91f16700Schasinglulu   mbedtls heap info etc.
56*91f16700Schasinglulu - HW_CONFIG: properties related to hardware configuration of the SoC
57*91f16700Schasinglulu   such as topology, GIC controller, PSCI hooks, CPU ID etc.
58*91f16700Schasinglulu
59*91f16700SchasingluluHence the ``populate()`` callback must be registered to the (|FCONF|) framework
60*91f16700Schasingluluwith the ``FCONF_REGISTER_POPULATOR()`` macro. This ensures that the function
61*91f16700Schasingluluwould be called inside the generic ``fconf_populate()`` function during
62*91f16700Schasingluluinitialization.
63*91f16700Schasinglulu
64*91f16700Schasinglulu::
65*91f16700Schasinglulu
66*91f16700Schasinglulu    int fconf_populate_topology(uintptr_t config)
67*91f16700Schasinglulu    {
68*91f16700Schasinglulu        /* read hw config dtb and fill soc_topology struct */
69*91f16700Schasinglulu    }
70*91f16700Schasinglulu
71*91f16700Schasinglulu    FCONF_REGISTER_POPULATOR(HW_CONFIG, topology, fconf_populate_topology);
72*91f16700Schasinglulu
73*91f16700SchasingluluThen, a wrapper has to be provided to match the ``FCONF_GET_PROPERTY()`` macro:
74*91f16700Schasinglulu
75*91f16700Schasinglulu::
76*91f16700Schasinglulu
77*91f16700Schasinglulu    /* generic getter */
78*91f16700Schasinglulu    #define FCONF_GET_PROPERTY(a,b,property)	a##__##b##_getter(property)
79*91f16700Schasinglulu
80*91f16700Schasinglulu    /* my specific getter */
81*91f16700Schasinglulu    #define hw_config__topology_getter(prop) soc_topology.prop
82*91f16700Schasinglulu
83*91f16700SchasingluluThis second level wrapper can be used to remap the ``FCONF_GET_PROPERTY()`` to
84*91f16700Schasingluluanything appropriate: structure, array, function, etc..
85*91f16700Schasinglulu
86*91f16700SchasingluluTo ensure a good interpretation of the properties, this documentation must
87*91f16700Schasingluluexplain how the properties are described for a specific backend. Refer to the
88*91f16700Schasinglulu:ref:`binding-document` section for more information and example.
89*91f16700Schasinglulu
90*91f16700SchasingluluLoading the property device tree
91*91f16700Schasinglulu~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
92*91f16700Schasinglulu
93*91f16700SchasingluluThe ``fconf_load_config(image_id)`` must be called to load fw_config and
94*91f16700Schasinglulutb_fw_config devices tree containing the properties' values. This must be done
95*91f16700Schasingluluafter the io layer is initialized, as the |DTB| is stored on an external
96*91f16700Schasingluludevice (FIP).
97*91f16700Schasinglulu
98*91f16700Schasinglulu.. uml:: ../../resources/diagrams/plantuml/fconf_bl1_load_config.puml
99*91f16700Schasinglulu
100*91f16700SchasingluluPopulating the properties
101*91f16700Schasinglulu~~~~~~~~~~~~~~~~~~~~~~~~~
102*91f16700Schasinglulu
103*91f16700SchasingluluOnce a valid device tree is available, the ``fconf_populate(config)`` function
104*91f16700Schasinglulucan be used to fill the C data structure with the data from the config |DTB|.
105*91f16700SchasingluluThis function will call all the ``populate()`` callbacks which have been
106*91f16700Schasingluluregistered with ``FCONF_REGISTER_POPULATOR()`` as described above.
107*91f16700Schasinglulu
108*91f16700Schasinglulu.. uml:: ../../resources/diagrams/plantuml/fconf_bl2_populate.puml
109*91f16700Schasinglulu
110*91f16700SchasingluluNamespace guidance
111*91f16700Schasinglulu~~~~~~~~~~~~~~~~~~
112*91f16700Schasinglulu
113*91f16700SchasingluluAs mentioned above, properties are logically grouped around namespaces and
114*91f16700Schasinglulusub-namespaces. The following concepts should be considered when adding new
115*91f16700Schasingluluproperties/namespaces.
116*91f16700SchasingluluThe framework differentiates two types of properties:
117*91f16700Schasinglulu
118*91f16700Schasinglulu - Properties used inside common code.
119*91f16700Schasinglulu - Properties used inside platform specific code.
120*91f16700Schasinglulu
121*91f16700SchasingluluThe first category applies to properties being part of the firmware and shared
122*91f16700Schasingluluacross multiple platforms. They should be globally accessible and defined
123*91f16700Schasingluluinside the ``lib/fconf`` directory. The namespace must be chosen to reflect the
124*91f16700Schasinglulufeature/data abstracted.
125*91f16700Schasinglulu
126*91f16700SchasingluluExample:
127*91f16700Schasinglulu - |TBBR| related properties: tbbr.cot.bl2_id
128*91f16700Schasinglulu - Dynamic configuration information: dyn_cfg.dtb_info.hw_config_id
129*91f16700Schasinglulu
130*91f16700SchasingluluThe second category should represent the majority of the properties defined
131*91f16700Schasingluluwithin the framework: Platform specific properties. They must be accessed only
132*91f16700Schasingluluwithin the platform API and are defined only inside the platform scope. The
133*91f16700Schasinglulunamespace must contain the platform name under which the properties defined
134*91f16700Schasinglulubelong.
135*91f16700Schasinglulu
136*91f16700SchasingluluExample:
137*91f16700Schasinglulu - Arm io framework: arm.io_policies.bl31_id
138*91f16700Schasinglulu
139*91f16700Schasinglulu.. _binding-document:
140*91f16700Schasinglulu
141*91f16700SchasingluluProperties binding information
142*91f16700Schasinglulu~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
143*91f16700Schasinglulu
144*91f16700Schasinglulu.. toctree::
145*91f16700Schasinglulu  :maxdepth: 1
146*91f16700Schasinglulu
147*91f16700Schasinglulu  fconf_properties
148*91f16700Schasinglulu  amu-bindings
149*91f16700Schasinglulu  mpmm-bindings
150