Kevin Peng | 75b0b76 | 2022-10-25 18:00:27 +0800 | [diff] [blame] | 1 | .. _Header_configuration: |
| 2 | |
| 3 | ############################# |
| 4 | The Header File Config System |
| 5 | ############################# |
| 6 | |
| 7 | The header file configurations system is used to fine-tune component options. |
| 8 | |
| 9 | The following diagram shows how the system works. |
| 10 | |
| 11 | .. figure:: header_file_system.png |
| 12 | |
| 13 | A ``config_tfm.h`` file collects customized configurations, including platform customized and |
| 14 | project specific settings. |
| 15 | Each component has a ``config_<comp_name>.h`` which includes the ``config_tfm.h`` first and then |
| 16 | provides default values for each config option of the component as well as necessary validations |
| 17 | on config dependencies. |
| 18 | Source files then include component header files when necessary. |
| 19 | |
| 20 | The ``config_tfm.h`` includes a customized project config file provided via compile definition |
| 21 | ``PROJECT_CONFIG_HEADER_FILE``. |
| 22 | Users set the corresponding CMake variable ``PROJECT_CONFIG_HEADER_FILE`` with the full path of the |
| 23 | configuration header file. |
| 24 | A platform can adjust or place restriction on config options by providing a ``config_tfm_target.h`` |
| 25 | under the root folder of their platforms. |
| 26 | If the build system finds the file, it sets the ``TARGET_CONFIG_HEADER_FILE`` compile definition. |
| 27 | |
| 28 | .. code-block:: c |
| 29 | |
| 30 | #ifdef PROJECT_CONFIG_HEADER_FILE |
| 31 | #include PROJECT_CONFIG_HEADER_FILE |
| 32 | #endif |
| 33 | |
| 34 | #ifdef TARGET_CONFIG_HEADER_FILE |
| 35 | #include TARGET_CONFIG_HEADER_FILE |
| 36 | #endif |
| 37 | |
| 38 | The project config header file can be |
| 39 | |
| 40 | - Generated by the TF-M Kconfig system <kconfig_system> |
| 41 | - One of the header files of Profiles <tf-m_profiles>, set via the ``TFM_PROFILE`` build option. |
| 42 | - Manually customized profile based on pre-set profiles. |
| 43 | |
| 44 | It is expected that all Component options are included in the header file to explicitly set values |
| 45 | for each option. |
Anton Komlev | 5bc799f | 2022-11-10 18:22:48 +0000 | [diff] [blame] | 46 | Refer to :ref:`Base_configuration` for details the base configurations. |
Kevin Peng | 75b0b76 | 2022-10-25 18:00:27 +0800 | [diff] [blame] | 47 | |
| 48 | -------------- |
| 49 | |
| 50 | *Copyright (c) 2022, Arm Limited. All rights reserved.* |