blob: 89d7205d324df3004de87236ff94989c79c3170f [file] [log] [blame]
Ken Liubc88eb42020-04-25 19:32:25 +08001###################################
2Trusted Firmware-M Source Structure
3###################################
4
5:Organization: Arm Limited
6:Contact: tf-m@lists.trustedfirmware.org
7
8.. note::
Anton Komlev3356ba32022-03-31 22:02:11 +01009 Reference the document :doc:`Glossary </glossary>` for terms
Edison Aif7990c82020-07-16 18:31:48 +080010 and abbreviations.
Ken Liubc88eb42020-04-25 19:32:25 +080011
12************
13Introduction
14************
Ken Liu8e41e3e2020-06-02 10:57:53 +080015TF-M is designed to provide a user-friendly source structure to ease
Ken Liubc88eb42020-04-25 19:32:25 +080016integration and service development. This document introduces the source
17structure and its design intention of TF-M.
18
19.. note::
20 - This document goes ahead of the implementation so the existing source
Ken Liu8e41e3e2020-06-02 10:57:53 +080021 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 Liubc88eb42020-04-25 19:32:25 +080025
26****************
27Source Structure
28****************
29The description of the source structure is broken down into subsections, each
30subsection introduces one detailed folder.
31
Edison Aif7990c82020-07-16 18:31:48 +080032Root Directory
Ken Liubc88eb42020-04-25 19:32:25 +080033==============
Ken Liu8e41e3e2020-06-02 10:57:53 +080034This table describes the structure under the root directory with part of
35possible folders. Note that the ``Detailed`` field indicates if the folder is
36described in details here in this document:
Ken Liubc88eb42020-04-25 19:32:25 +080037
38============= ==================================== ====================
39Folder name Purpose Detailed
40============= ==================================== ====================
Ken Liu8e41e3e2020-06-02 10:57:53 +080041bl2 The 2nd stage bootloader. No.
42cmake Cmake files. No.
43configs Configuration system files. No.
44docs The documentations. No.
45lib The 3rd party library. No.
Ken Liubc88eb42020-04-25 19:32:25 +080046**platform** Platform intermedia files. See `'platform'`_.
47**secure_fw** The secure firmware. See `'secure_fw'`_.
Ken Liu8e41e3e2020-06-02 10:57:53 +080048tools Tools in scripts for building. No.
Ken Liubc88eb42020-04-25 19:32:25 +080049============= ==================================== ====================
50
Ken Liubc88eb42020-04-25 19:32:25 +080051'platform'
52==========
53The platform sources contain necessary platform sources or intermedia files
54pointing to the sources out of TF-M folder.
55
56========================= =============================================
57Folder name Purpose
58========================= =============================================
59common/\* Common HAL implementation.
Ken Liu8e41e3e2020-06-02 10:57:53 +080060include/\* Platform public headers.
61<vendor> Vendor specific folders.
Ken Liubc88eb42020-04-25 19:32:25 +080062========================= =============================================
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===========
76This folder contains components needed by secure firmware, and the exported
77interfaces for application, service development and HAL integration:
78
Ken Liu8e41e3e2020-06-02 10:57:53 +080079================= ===================================== ======================
80Folder 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 Liubc88eb42020-04-25 19:32:25 +080086
87.. note::
Ken Liu8e41e3e2020-06-02 10:57:53 +080088 1. A PSA-FF-M complied SPM implementation.
Ken Liubc88eb42020-04-25 19:32:25 +080089
Ken Liu8e41e3e2020-06-02 10:57:53 +080090 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 Liubc88eb42020-04-25 19:32:25 +080093
94'include'
95---------
96This folder holds headers for client, services and platform integration usage.
97
Ken Liu8e41e3e2020-06-02 10:57:53 +080098=========================== ===================================================
Ken Liubc88eb42020-04-25 19:32:25 +080099Folder name Purpose
Ken Liu8e41e3e2020-06-02 10:57:53 +0800100=========================== ===================================================
101psa/\* PSA FF Client API.
102=========================== ===================================================
Ken Liubc88eb42020-04-25 19:32:25 +0800103
104.. note::
105 TFM applies an explicit including policy. Each module's headers are put into
Ken Liu8e41e3e2020-06-02 10:57:53 +0800106 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 Liubc88eb42020-04-25 19:32:25 +0800111
112'partitions'
113------------
114This folder contains default services implemented as partitions and necessary
115partition runtime utilities provided by TF-M.
116
117================================= =============================================
118Folder name Purpose
119================================= =============================================
Ken Liu562f2a12022-05-12 20:02:33 +0800120lib/runtime/\* The SPRTL sources and intermedia files. [1]
121lib/runtime/shared\* Sources can be shared by out of SPRTL. [2]
Ken Liubc88eb42020-04-25 19:32:25 +0800122<partition_x>/\* Files for 'partition_x'.
Ken Liu8e41e3e2020-06-02 10:57:53 +0800123<partition_x>/include/\* RoT Service API headers of 'partition_x'. [3]
Ken Liubc88eb42020-04-25 19:32:25 +0800124<partition_y>/\* Files for 'partition_y'.
Ken Liu8e41e3e2020-06-02 10:57:53 +0800125<partition_y>/include/\* RoT Service API headers of 'partition_y'. [3]
Ken Liubc88eb42020-04-25 19:32:25 +0800126================================= =============================================
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 Liu8e41e3e2020-06-02 10:57:53 +0800132 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 Liubc88eb42020-04-25 19:32:25 +0800138
Ken Liu8e41e3e2020-06-02 10:57:53 +0800139'spm'
140-----
141The SPM is the core component to provide a mechanism for providing secure
142services.
Ken Liubc88eb42020-04-25 19:32:25 +0800143
Ken Liu8e41e3e2020-06-02 10:57:53 +0800144=================================== ===========================================
145Folder name Purpose
146=================================== ===========================================
147include/\* SPM public headers.
Ken Liu55ba01f2021-01-20 17:34:50 +0800148ffm/\* SPM logic complies with PSA-FF-M and
Summer Qina62b0c62020-08-31 15:36:06 +0800149 its necessary supporting functionalities,
150 such as the runtime API and the thread
151 operation, etc.
Ken Liubeaad802020-08-04 12:58:12 +0800152cmsis_psa/\* CMSIS implementation for PSA-FF-M SPM. [1]
Ken Liu8e41e3e2020-06-02 10:57:53 +0800153\* Implementation sources.
154=================================== ===========================================
Ken Liubc88eb42020-04-25 19:32:25 +0800155
156.. note::
Ken Liu8e41e3e2020-06-02 10:57:53 +0800157 1. CMSIS is the first implementation system.
158 2. This folder contains a function call based secure firmware implementation.
159 This model is the prototype model which would be updated after the PSA
160 model. Create a standalone folder to hold it.
Ken Liubc88eb42020-04-25 19:32:25 +0800161
162--------------
163
Summer Qin2db78c82022-10-10 17:17:44 +0800164*Copyright (c) 2020-2022, Arm Limited. All rights reserved.*