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:: |
| 9 | Refernce the document :doc:`Glossary </docs/glossary>` for terms and |
| 10 | abbreviations. |
| 11 | |
| 12 | ************ |
| 13 | Introduction |
| 14 | ************ |
| 15 | TF-M is designed to provide a user-friendly source structure to easy |
| 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 |
| 21 | structure may be different from the description listed here. Staging |
| 22 | changes must reference this document since it is the goal of structure |
| 23 | design. |
| 24 | - Related non-source content like libraries, scripts and binaries are also |
| 25 | introduced but briefly since this document focuses more on the source |
| 26 | code. |
| 27 | |
| 28 | **************** |
| 29 | Source Structure |
| 30 | **************** |
| 31 | The description of the source structure is broken down into subsections, each |
| 32 | subsection introduces one detailed folder. |
| 33 | |
| 34 | Root Direcotry |
| 35 | ============== |
| 36 | This table describes the structure under the root directory. The item with a |
| 37 | `No` in the `Detailed` field is briefly introduced but not detailed into |
| 38 | subsections. |
| 39 | |
| 40 | ============= ==================================== ==================== |
| 41 | Folder name Purpose Detailed |
| 42 | ============= ==================================== ==================== |
| 43 | bl2 The 2nd stage bootloader. No. [1] |
| 44 | cmake Cmake files. No. [2] |
| 45 | configs Configuration system files. No. [2] |
| 46 | docs The documentations. No. [2] |
| 47 | lib The 3rd party library. No. [1] |
| 48 | **platform** Platform intermedia files. See `'platform'`_. |
| 49 | **secure_fw** The secure firmware. See `'secure_fw'`_. |
| 50 | **test** Tests. See `'test'`_. |
| 51 | tools Tools in scripts for building. No. [2] |
| 52 | ============= ==================================== ==================== |
| 53 | |
| 54 | .. note:: |
| 55 | 1. 3rd party project structure is not introduced. |
| 56 | 2. Non-source content maybe not listed here, or introduction is skipped even |
| 57 | they are listed. |
| 58 | |
| 59 | 'platform' |
| 60 | ========== |
| 61 | The platform sources contain necessary platform sources or intermedia files |
| 62 | pointing to the sources out of TF-M folder. |
| 63 | |
| 64 | ========================= ============================================= |
| 65 | Folder name Purpose |
| 66 | ========================= ============================================= |
| 67 | common/\* Common HAL implementation. |
| 68 | <vendor> Vendor specific folder. |
| 69 | ========================= ============================================= |
| 70 | |
| 71 | .. note:: |
| 72 | The ``common`` folder contains the example implementation of the ``HAL`` API |
| 73 | bases on common ``system`` (CMSIS e.g.). The platform could reference to |
| 74 | sources in the ``common`` folder directly if applicable or apply a |
| 75 | customized HAL implementation. |
| 76 | A ``system`` can have a standalone folder under ``common``, depends on how |
| 77 | 'common' this system is. Each ``platform vendor`` is assigned with one |
| 78 | folder for usage. As the content of the ``vendor`` folder comes by the |
| 79 | contribution of vendors, the ``vendor`` manages the structure inside it. |
| 80 | |
| 81 | 'secure_fw' |
| 82 | =========== |
| 83 | This folder contains components needed by secure firmware, and the exported |
| 84 | interfaces for application, service development and HAL integration: |
| 85 | |
| 86 | ============== =========================================== ==================== |
| 87 | Folder name Purpose Detailed |
| 88 | ============== =========================================== ==================== |
| 89 | **spm** Generic SPM sources. See `'spm'`_ |
| 90 | **include** Interfaces for PSA FF and TF-M generic. See `'include'`_ |
| 91 | **partitions** Default services and supportings. See `'partitions'`_ |
| 92 | **shared** Sources not only for secure firmware usage. See `'shared'`_ |
| 93 | ============== =========================================== ==================== |
| 94 | |
| 95 | 'spm' |
| 96 | ----- |
| 97 | The SPM is the core component to provide a mechanism for providing secure |
| 98 | services. |
| 99 | |
| 100 | =================================== =========================================== |
| 101 | Folder name Purpose |
| 102 | =================================== =========================================== |
| 103 | arch/\* Architecture sources. [1] |
| 104 | include/\* SPM public headers. |
| 105 | include/hal\* SPM public headers for HAL. |
| 106 | init/* SPM initializing entry. [2] |
| 107 | model_ipc/\* PSA-FF-M SPM implementation. [3] |
| 108 | model_func/\* The library model SPM implementation. [4] |
| 109 | runtime/\* SPM runtime utilities. [5] |
| 110 | services/\* PRoT Services not in partitions. [6] |
| 111 | =================================== =========================================== |
| 112 | |
| 113 | .. note:: |
| 114 | 1. The Architecture source focus on context-related operations. |
| 115 | 2. SPM startup code. |
| 116 | 3. A PSA-FF-M-complied SPM implementation. |
| 117 | 4. A customized library model SPM implementation. |
| 118 | 5. The SPM runtime utilities such as memory managing and scheduling. |
| 119 | 6. The services can be implemented as Secure Partitions or partition-less PSA |
| 120 | RoT Services. Here puts the partition-less services. |
| 121 | |
| 122 | The private headers for each component in this folder are |
| 123 | development-defined. Do not mix private headers with public headers into the |
| 124 | same folder. |
| 125 | |
| 126 | 'include' |
| 127 | --------- |
| 128 | This folder holds headers for client, services and platform integration usage. |
| 129 | |
| 130 | =========================== ============================================= |
| 131 | Folder name Purpose |
| 132 | =========================== ============================================= |
| 133 | psa/\*.h PSA FF headers. |
| 134 | tfm/\*.h TF-M specific feature headers. |
| 135 | =========================== ============================================= |
| 136 | |
| 137 | .. note:: |
| 138 | TFM applies an explicit including policy. Each module's headers are put into |
| 139 | a specific folder which follows the pattern '\*/include', this folder needs |
| 140 | to be added into the project's searching path if this project needs to |
| 141 | include headers in this folder. The 'include' in a path indicates the end of |
| 142 | including-path. If there are subfolders under folder 'include', apply a |
| 143 | relative hierarchy including. |
| 144 | |
| 145 | 'partitions' |
| 146 | ------------ |
| 147 | This folder contains default services implemented as partitions and necessary |
| 148 | partition runtime utilities provided by TF-M. |
| 149 | |
| 150 | ================================= ============================================= |
| 151 | Folder name Purpose |
| 152 | ================================= ============================================= |
| 153 | lib/sprt/\* The SPRTL sources and intermedia files. [1] |
| 154 | <partition_x>/\* Files for 'partition_x'. |
| 155 | <partition_x>/export/include/\*.h RoT Service API headers of 'partition_x'. [2] |
| 156 | <partition_x>/export/src/\*.c RoT Service API sources of 'partition_x'. [2] |
| 157 | <partition_y>/\* Files for 'partition_y'. |
| 158 | <partition_y>/export/include/\*.h RoT Service API headers of 'partition_y'. [2] |
| 159 | <partition_y>/export/src/\*.c RoT Service API sources of 'partition_y'. [2] |
| 160 | ================================= ============================================= |
| 161 | |
| 162 | .. note:: |
| 163 | 1. The SPRTL sources and intermediate files. SPRTL contains sources from |
| 164 | other folders, such as necessary RoT Service API implementation from |
| 165 | 'partitions' folder. |
| 166 | 2. Here takes 'partition_x' and 'partition_y' as an example, and showcases |
| 167 | a detailed structure of them. |
| 168 | |
| 169 | 'shared' |
| 170 | -------- |
| 171 | Here place the sources which are needed by SPE components and shared between |
| 172 | multiple components (includes NSPE components). |
| 173 | |
| 174 | ========================= ============================================= |
| 175 | Folder name Purpose |
| 176 | ========================= ============================================= |
| 177 | shared/psa/\*.c Shared PSA FF sources. |
| 178 | shared/tfm/\*.c Shared TF-M feature sources. |
| 179 | ========================= ============================================= |
| 180 | |
| 181 | .. note:: |
| 182 | Examples for the shared sources: |
| 183 | The parameter packing for ``psa_call()`` is same between NSPE clients and |
| 184 | the secure clients, the only difference is the final call. In a TrustZone |
| 185 | implementation it is an 'SG' for NSPE while for secure clients it can be a |
| 186 | 'SVC'. So this ``psa_call`` implementation under 'psa/' can be shared |
| 187 | between NSPE clients and the secure clients. So does the TF-M customized |
| 188 | feature sources under the 'tfm/' direcotry. |
| 189 | |
| 190 | 'test' |
| 191 | ====== |
| 192 | The NSPE examples are for test-purpose-specific. |
| 193 | |
| 194 | ============================== =========================================== |
| 195 | Folder name Purpose |
| 196 | ============================== =========================================== |
| 197 | test/nspe/rtx/\* RTX - the example NSPE instance. [1] |
| 198 | test/* Other test related sources. [2] |
| 199 | ============================== =========================================== |
| 200 | |
| 201 | .. note:: |
| 202 | 1. This is the example NSPE instance. |
| 203 | 2. Other sources are managed by the 'test' design. The test purpose secure |
| 204 | services are also put under this foler (NOT the `'partitions'`_ folder). |
| 205 | |
| 206 | -------------- |
| 207 | |
| 208 | *Copyright (c) 2020, Arm Limited. All rights reserved.* |