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