Ken Liu | bc88eb4 | 2020-04-25 19:32:25 +0800 | [diff] [blame] | 1 | ################################### |
| 2 | Trusted Firmware-M Source Structure |
| 3 | ################################### |
| 4 | |
| 5 | :Organization: Arm Limited |
| 6 | :Contact: tf-m@lists.trustedfirmware.org |
| 7 | |
| 8 | .. note:: |
Edison Ai | f7990c8 | 2020-07-16 18:31:48 +0800 | [diff] [blame] | 9 | Reference the document :doc:`Glossary </docs/reference/glossary>` for terms |
| 10 | and abbreviations. |
Ken Liu | bc88eb4 | 2020-04-25 19:32:25 +0800 | [diff] [blame] | 11 | |
| 12 | ************ |
| 13 | Introduction |
| 14 | ************ |
Ken Liu | 8e41e3e | 2020-06-02 10:57:53 +0800 | [diff] [blame] | 15 | TF-M is designed to provide a user-friendly source structure to ease |
Ken Liu | bc88eb4 | 2020-04-25 19:32:25 +0800 | [diff] [blame] | 16 | integration and service development. This document introduces the source |
| 17 | structure and its design intention of TF-M. |
| 18 | |
| 19 | .. note:: |
| 20 | - This document goes ahead of the implementation so the existing source |
Ken Liu | 8e41e3e | 2020-06-02 10:57:53 +0800 | [diff] [blame] | 21 | structure may be different from the description listed here. It is |
| 22 | recommended to refer to this document for ongoing code structure changes. |
| 23 | - By getting feedback from the practical implementation, this document is |
| 24 | updated continuously before it is detailed enough to be a user guide. |
Ken Liu | bc88eb4 | 2020-04-25 19:32:25 +0800 | [diff] [blame] | 25 | |
| 26 | **************** |
| 27 | Source Structure |
| 28 | **************** |
| 29 | The description of the source structure is broken down into subsections, each |
| 30 | subsection introduces one detailed folder. |
| 31 | |
Edison Ai | f7990c8 | 2020-07-16 18:31:48 +0800 | [diff] [blame] | 32 | Root Directory |
Ken Liu | bc88eb4 | 2020-04-25 19:32:25 +0800 | [diff] [blame] | 33 | ============== |
Ken Liu | 8e41e3e | 2020-06-02 10:57:53 +0800 | [diff] [blame] | 34 | This table describes the structure under the root directory with part of |
| 35 | possible folders. Note that the ``Detailed`` field indicates if the folder is |
| 36 | described in details here in this document: |
Ken Liu | bc88eb4 | 2020-04-25 19:32:25 +0800 | [diff] [blame] | 37 | |
| 38 | ============= ==================================== ==================== |
| 39 | Folder name Purpose Detailed |
| 40 | ============= ==================================== ==================== |
Ken Liu | 8e41e3e | 2020-06-02 10:57:53 +0800 | [diff] [blame] | 41 | bl2 The 2nd stage bootloader. No. |
| 42 | cmake Cmake files. No. |
| 43 | configs Configuration system files. No. |
| 44 | docs The documentations. No. |
| 45 | lib The 3rd party library. No. |
Ken Liu | bc88eb4 | 2020-04-25 19:32:25 +0800 | [diff] [blame] | 46 | **platform** Platform intermedia files. See `'platform'`_. |
| 47 | **secure_fw** The secure firmware. See `'secure_fw'`_. |
Ken Liu | 8e41e3e | 2020-06-02 10:57:53 +0800 | [diff] [blame] | 48 | tools Tools in scripts for building. No. |
Ken Liu | bc88eb4 | 2020-04-25 19:32:25 +0800 | [diff] [blame] | 49 | ============= ==================================== ==================== |
| 50 | |
Ken Liu | bc88eb4 | 2020-04-25 19:32:25 +0800 | [diff] [blame] | 51 | 'platform' |
| 52 | ========== |
| 53 | The platform sources contain necessary platform sources or intermedia files |
| 54 | pointing to the sources out of TF-M folder. |
| 55 | |
| 56 | ========================= ============================================= |
| 57 | Folder name Purpose |
| 58 | ========================= ============================================= |
| 59 | common/\* Common HAL implementation. |
Ken Liu | 8e41e3e | 2020-06-02 10:57:53 +0800 | [diff] [blame] | 60 | include/\* Platform public headers. |
| 61 | <vendor> Vendor specific folders. |
Ken Liu | bc88eb4 | 2020-04-25 19:32:25 +0800 | [diff] [blame] | 62 | ========================= ============================================= |
| 63 | |
| 64 | .. note:: |
| 65 | The ``common`` folder contains the example implementation of the ``HAL`` API |
| 66 | bases on common ``system`` (CMSIS e.g.). The platform could reference to |
| 67 | sources in the ``common`` folder directly if applicable or apply a |
| 68 | customized HAL implementation. |
| 69 | A ``system`` can have a standalone folder under ``common``, depends on how |
| 70 | 'common' this system is. Each ``platform vendor`` is assigned with one |
| 71 | folder for usage. As the content of the ``vendor`` folder comes by the |
| 72 | contribution of vendors, the ``vendor`` manages the structure inside it. |
| 73 | |
| 74 | 'secure_fw' |
| 75 | =========== |
| 76 | This folder contains components needed by secure firmware, and the exported |
| 77 | interfaces for application, service development and HAL integration: |
| 78 | |
Ken Liu | 8e41e3e | 2020-06-02 10:57:53 +0800 | [diff] [blame] | 79 | ================= ===================================== ====================== |
| 80 | Folder name Purpose Detailed |
| 81 | ================= ===================================== ====================== |
| 82 | **include** Public headers of 'secure_fw'. See `'include'`_ |
| 83 | **partitions** Default services and supportings. See `'partitions'`_ |
| 84 | **spm** PSA-FF-M SPM implementation. [1] See `'spm'`_ |
| 85 | ================= ===================================== ====================== |
Ken Liu | bc88eb4 | 2020-04-25 19:32:25 +0800 | [diff] [blame] | 86 | |
| 87 | .. note:: |
Ken Liu | 8e41e3e | 2020-06-02 10:57:53 +0800 | [diff] [blame] | 88 | 1. A PSA-FF-M complied SPM implementation. |
Ken Liu | bc88eb4 | 2020-04-25 19:32:25 +0800 | [diff] [blame] | 89 | |
Ken Liu | 8e41e3e | 2020-06-02 10:57:53 +0800 | [diff] [blame] | 90 | The headers referenced by other modules are public headers and put under the |
| 91 | 'include' folder of the current module. Do not put headers not referenced by |
| 92 | other modules in this 'include' folder. |
Ken Liu | bc88eb4 | 2020-04-25 19:32:25 +0800 | [diff] [blame] | 93 | |
| 94 | 'include' |
| 95 | --------- |
| 96 | This folder holds headers for client, services and platform integration usage. |
| 97 | |
Ken Liu | 8e41e3e | 2020-06-02 10:57:53 +0800 | [diff] [blame] | 98 | =========================== =================================================== |
Ken Liu | bc88eb4 | 2020-04-25 19:32:25 +0800 | [diff] [blame] | 99 | Folder name Purpose |
Ken Liu | 8e41e3e | 2020-06-02 10:57:53 +0800 | [diff] [blame] | 100 | =========================== =================================================== |
| 101 | psa/\* PSA FF Client API. |
| 102 | =========================== =================================================== |
Ken Liu | bc88eb4 | 2020-04-25 19:32:25 +0800 | [diff] [blame] | 103 | |
| 104 | .. note:: |
| 105 | TFM applies an explicit including policy. Each module's headers are put into |
Ken Liu | 8e41e3e | 2020-06-02 10:57:53 +0800 | [diff] [blame] | 106 | a specific folder which follows the pattern '\*/inc', this folder needs to be |
| 107 | added into the project's searching path if this project needs to include |
| 108 | headers in this folder. The 'inc' in a path indicates the end of |
| 109 | including-path. If there are subfolders under folder 'inc', apply a |
| 110 | hierarchy including. |
Ken Liu | bc88eb4 | 2020-04-25 19:32:25 +0800 | [diff] [blame] | 111 | |
| 112 | 'partitions' |
| 113 | ------------ |
| 114 | This folder contains default services implemented as partitions and necessary |
| 115 | partition runtime utilities provided by TF-M. |
| 116 | |
| 117 | ================================= ============================================= |
| 118 | Folder name Purpose |
| 119 | ================================= ============================================= |
| 120 | lib/sprt/\* The SPRTL sources and intermedia files. [1] |
Ken Liu | 8e41e3e | 2020-06-02 10:57:53 +0800 | [diff] [blame] | 121 | lib/sprt/shared\* Sources can be shared by out of SPRTL. [2] |
Ken Liu | bc88eb4 | 2020-04-25 19:32:25 +0800 | [diff] [blame] | 122 | <partition_x>/\* Files for 'partition_x'. |
Ken Liu | 8e41e3e | 2020-06-02 10:57:53 +0800 | [diff] [blame] | 123 | <partition_x>/include/\* RoT Service API headers of 'partition_x'. [3] |
Ken Liu | bc88eb4 | 2020-04-25 19:32:25 +0800 | [diff] [blame] | 124 | <partition_y>/\* Files for 'partition_y'. |
Ken Liu | 8e41e3e | 2020-06-02 10:57:53 +0800 | [diff] [blame] | 125 | <partition_y>/include/\* RoT Service API headers of 'partition_y'. [3] |
Ken Liu | bc88eb4 | 2020-04-25 19:32:25 +0800 | [diff] [blame] | 126 | ================================= ============================================= |
| 127 | |
| 128 | .. note:: |
| 129 | 1. The SPRTL sources and intermediate files. SPRTL contains sources from |
| 130 | other folders, such as necessary RoT Service API implementation from |
| 131 | 'partitions' folder. |
Ken Liu | 8e41e3e | 2020-06-02 10:57:53 +0800 | [diff] [blame] | 132 | 2. The sources here can be referenced by the building system out of SPRTL. |
| 133 | Generally, they are runtime and PSA APIs. |
| 134 | 3. Here takes 'partition_x' and 'partition_y' as an example, and showcases |
| 135 | a detailed structure of them. The `<interface>` contains the RoT Service |
| 136 | API for client calls. The folder name of this client-orient folder is |
| 137 | decided by the service developer. |
Ken Liu | bc88eb4 | 2020-04-25 19:32:25 +0800 | [diff] [blame] | 138 | |
Ken Liu | 8e41e3e | 2020-06-02 10:57:53 +0800 | [diff] [blame] | 139 | 'spm' |
| 140 | ----- |
| 141 | The SPM is the core component to provide a mechanism for providing secure |
| 142 | services. |
Ken Liu | bc88eb4 | 2020-04-25 19:32:25 +0800 | [diff] [blame] | 143 | |
Ken Liu | 8e41e3e | 2020-06-02 10:57:53 +0800 | [diff] [blame] | 144 | =================================== =========================================== |
| 145 | Folder name Purpose |
| 146 | =================================== =========================================== |
| 147 | include/\* SPM public headers. |
Ken Liu | 55ba01f | 2021-01-20 17:34:50 +0800 | [diff] [blame] | 148 | ffm/\* SPM logic complies with PSA-FF-M and |
Summer Qin | a62b0c6 | 2020-08-31 15:36:06 +0800 | [diff] [blame] | 149 | its necessary supporting functionalities, |
| 150 | such as the runtime API and the thread |
| 151 | operation, etc. |
Ken Liu | beaad80 | 2020-08-04 12:58:12 +0800 | [diff] [blame] | 152 | cmsis_psa/\* CMSIS implementation for PSA-FF-M SPM. [1] |
| 153 | cmsis_func/\* The library model implementation. [2] |
Ken Liu | 8e41e3e | 2020-06-02 10:57:53 +0800 | [diff] [blame] | 154 | \* Implementation sources. |
| 155 | =================================== =========================================== |
Ken Liu | bc88eb4 | 2020-04-25 19:32:25 +0800 | [diff] [blame] | 156 | |
| 157 | .. note:: |
Ken Liu | 8e41e3e | 2020-06-02 10:57:53 +0800 | [diff] [blame] | 158 | 1. CMSIS is the first implementation system. |
| 159 | 2. This folder contains a function call based secure firmware implementation. |
| 160 | This model is the prototype model which would be updated after the PSA |
| 161 | model. Create a standalone folder to hold it. |
Ken Liu | bc88eb4 | 2020-04-25 19:32:25 +0800 | [diff] [blame] | 162 | |
| 163 | -------------- |
| 164 | |
| 165 | *Copyright (c) 2020, Arm Limited. All rights reserved.* |