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 | |
David Hu | 6496183 | 2023-02-21 23:03:01 +0800 | [diff] [blame] | 11 | .. figure:: header_file_config_diagram.svg |
| 12 | :align: center |
Kevin Peng | 75b0b76 | 2022-10-25 18:00:27 +0800 | [diff] [blame] | 13 | |
David Hu | 6496183 | 2023-02-21 23:03:01 +0800 | [diff] [blame] | 14 | Source files shall include ``config_tfm.h`` when necessary to fetch Component option settings. |
| 15 | It is expected that all Component options are included in ``config_tfm.h`` to explicitly set values |
| 16 | for each option. |
| 17 | |
| 18 | |
| 19 | The ``config_tfm.h`` includes base configuration ``config_base.h``. Refer to |
| 20 | :ref:`Base_configuration` for details of the base configurations. |
Kevin Peng | 75b0b76 | 2022-10-25 18:00:27 +0800 | [diff] [blame] | 21 | |
| 22 | The ``config_tfm.h`` includes a customized project config file provided via compile definition |
David Hu | 6496183 | 2023-02-21 23:03:01 +0800 | [diff] [blame] | 23 | ``PROJECT_CONFIG_HEADER_FILE``. Customized Component options in the project config file overrides |
| 24 | those configured in ``config_base.h``. |
| 25 | The project config header file can be |
| 26 | |
| 27 | - Generated by the TF-M Kconfig system <kconfig_system> |
| 28 | - One of the header files of Profiles <tf-m_profiles>, set via the ``TFM_PROFILE`` build option. |
| 29 | - Manually customized profile based on pre-set profiles. |
| 30 | |
| 31 | Users set CMake variable ``PROJECT_CONFIG_HEADER_FILE`` with the full path of the configuration |
| 32 | header file. |
| 33 | |
Kevin Peng | 75b0b76 | 2022-10-25 18:00:27 +0800 | [diff] [blame] | 34 | A platform can adjust or place restriction on config options by providing a ``config_tfm_target.h`` |
| 35 | under the root folder of their platforms. |
| 36 | If the build system finds the file, it sets the ``TARGET_CONFIG_HEADER_FILE`` compile definition. |
David Hu | 6496183 | 2023-02-21 23:03:01 +0800 | [diff] [blame] | 37 | Platform specific option settings in ``TARGET_CONFIG_HEADER_FILE`` overrides those configured in |
| 38 | ``config_base.h``. |
Kevin Peng | 75b0b76 | 2022-10-25 18:00:27 +0800 | [diff] [blame] | 39 | |
| 40 | .. code-block:: c |
| 41 | |
Kevin Peng | 75b0b76 | 2022-10-25 18:00:27 +0800 | [diff] [blame] | 42 | #ifdef TARGET_CONFIG_HEADER_FILE |
| 43 | #include TARGET_CONFIG_HEADER_FILE |
| 44 | #endif |
| 45 | |
Andrej Butok | ab8f52d | 2023-06-06 15:51:41 +0200 | [diff] [blame] | 46 | #ifdef PROJECT_CONFIG_HEADER_FILE |
| 47 | #include PROJECT_CONFIG_HEADER_FILE |
| 48 | #endif |
| 49 | |
David Hu | 6496183 | 2023-02-21 23:03:01 +0800 | [diff] [blame] | 50 | #include "config_base.h" |
Kevin Peng | 75b0b76 | 2022-10-25 18:00:27 +0800 | [diff] [blame] | 51 | |
David Hu | 6496183 | 2023-02-21 23:03:01 +0800 | [diff] [blame] | 52 | Each component can implement a ``config_<comp_name>_check.h`` to validate component specific config |
| 53 | dependencies. ``config_<comp_name>_check.h`` shall include ``config_tfm.h`` |
Kevin Peng | 75b0b76 | 2022-10-25 18:00:27 +0800 | [diff] [blame] | 54 | |
| 55 | -------------- |
| 56 | |
| 57 | *Copyright (c) 2022, Arm Limited. All rights reserved.* |