blob: b68558cc3004ba6a03b99757360e7eeb570d5c18 [file] [log] [blame]
Anton Komlev91281f02022-04-22 09:24:20 +01001#################
Summer Qinabf66982021-04-06 17:22:15 +08002Integration Guide
Anton Komlev91281f02022-04-22 09:24:20 +01003#################
4The purpose of this document is to provide a guide on how to integrate TF-M
5with other hardware platforms and operating systems.
6
7
Minos Galanakise4094012020-06-12 14:25:34 +01008.. toctree::
9 :maxdepth: 1
Minos Galanakise4094012020-06-12 14:25:34 +010010
Anton Komlev91281f02022-04-22 09:24:20 +010011 NS client integration <non-secure_client_extension_integration_guide.rst>
12 OS migration to Armv8-M <os_migration_guide_armv8m.rst>
Anton Komlev1f1bec02022-06-17 15:45:09 +010013 tfm_fpu_support
14 Secure Interrupt <tfm_secure_irq_integration_guide.rst>
Anton Komlev91281f02022-04-22 09:24:20 +010015
16.. toctree::
17 :maxdepth: 2
18
19 platform/index
20 services/index
21
22
23*****************
24How to build TF-M
25*****************
Anton Komlev0dbe8f12022-06-17 16:48:12 +010026Follow the :doc:`Build instructions </building/tfm_build_instruction>`.
Anton Komlev91281f02022-04-22 09:24:20 +010027
28********************************************************
29How to export files for building non-secure applications
30********************************************************
Anton Komlev0dbe8f12022-06-17 16:48:12 +010031Explained in the :doc:`Build instructions </building/tfm_build_instruction>`.
Anton Komlev91281f02022-04-22 09:24:20 +010032
33*************************
34How to add a new platform
35*************************
36
37:doc:`Porting TF-M to a New Hardware </integration_guide/platform/porting_TFM_to_a_new_hardware>`
38contains guidance on how to add a new platform.
39
40***************************
41How to integrate another OS
42***************************
43
44OS migration to Armv8-M platforms
45=================================
46To work with TF-M on Armv8-M platforms, the OS needs to support the Armv8-M
47architecture and, in particular, it needs to be able to run in the non-secure
48world. More information about OS migration to the Armv8-M architecture can be
49found in the :doc:`OS requirements <os_migration_guide_armv8m>`. Depending upon
50the system configuration this may require configuring drivers to use appropriate
51address ranges.
52
53Interface with TF-M
54===================
55The files needed for the interface with TF-M are exported at the
56``<install_dir>/interface`` path. The NS side is only allowed to call
57TF-M secure functions (veneers) from the NS Thread mode.
58
59TF-M interface header files are exported in ``<install_dir>/interface/include``
60directory. For example, the Protected Storage (PS) service PSA API is declared
61in the file ``<install_dir>/interface/include/psa/protected_storage.h``.
62
63TF-M also exports a reference implementation of PSA APIs for NS clients in the
64``<install_dir>/interface/src``.
65
66On Armv8-M TrustZone based platforms, NS OS shall implement interface API
67``tfm_ns_interface_dispatch()`` to integrate with TF-M implementation of PSA
68APIs. See ``interface/include/tfm_ns_interface.h`` for the detailed declaration
69of ``tfm_ns_interface_dispatch()``.
70TF-M provides an example of ``tfm_ns_interface_dispatch()`` implementation on
71Armv8-M TrustZone based platforms. In this example, NS OS calls mutex in
72``tfm_ns_interface_dispatch()`` to synchronize multiple NS client calls to TF-M.
73See ``interface/src/tfm_ns_interface.c.example`` for more details.
74
75TF-M provides a reference implementation of NS mailbox on multi-core platforms,
76under folder ``interface/src/multi_core``.
77See :doc:`Mailbox design </technical_references/design_docs/dual-cpu/mailbox_design_on_dual_core_system>`
78for TF-M multi-core mailbox design.
79
80Interface with non-secure world regression tests
81================================================
82A non-secure application that wants to run the non-secure regression tests
83needs to call the ``tfm_non_secure_client_run_tests()``. This function is
84exported into the header file ``test_framework_integ_test.h`` inside the
85``<build_dir>/install`` folder structure in the test specific files,
86i.e. ``<build_dir>/install/export/tfm/test/inc``. The non-secure regression
87tests are precompiled and delivered as a static library which is available in
88``<build_dir>/install/export/tfm/test/lib``, so that the non-secure application
89needs to link against the library to be able to invoke the
90``tfm_non_secure_client_run_tests()`` function. The PS non-secure side
91regression tests rely on some OS functionality e.g. threads, mutexes etc. These
92functions comply with CMSIS RTOS2 standard and have been exported as thin
93wrappers defined in ``os_wrapper.h`` contained in
94``<build_dir>/install/export/tfm/test/inc``. OS needs to provide the
95implementation of these wrappers to be able to run the tests.
96
97NS client Identification
98========================
99
100The NS client identification (NSID) is specified by either SPM or NSPE RTOS.
101If SPM manages the NSID (default option), then the same NSID (-1) will be used
102for all connections from NS clients.
103For the case that NSPE RTOS manages the NSID and/or different NSIDs should be
104used for different NS clients. See
105:doc:`Non-secure Client Extension Integration Guide </integration_guide/non-secure_client_extension_integration_guide>`.
106
107*********************
108Non-secure interrupts
109*********************
110Non-secure interrupts are allowed to preempt Secure thread mode.
111With the current implementation, a NSPE task can spoof the identity of another
112NSPE task. This is an issue only when NSPE has provisions for task isolation.
113Note, that ``AIRCR.PRIS`` is still set to restrict the priority range available
114to NS interrupts to the lower half of available priorities so that it wouldn't
115be possible for any non-secure interrupt to preempt a higher-priority secure
116interrupt.
117
118**********************************
119Integration with non-Cmake systems
120**********************************
121
122Generated Files
123===============
124
125Files that are derived from PSA manifests are generated at build-time by cmake.
126For integration with systems that do no use cmake, the files must be generated
127manually.
128
129The ``tools/tfm_parse_manifest_list.py`` script can be invoked manually. Some
130arguments will be needed to be provided. Please refer to
131``tfm_parse_manifest_list.py --help`` for more details.
132
133Some variables are used in the template files, these will need to be set in the
134environment before the script will succeed when the script is not run via cmake.
Minos Galanakise4094012020-06-12 14:25:34 +0100135
136--------------
137
Anton Komlev91281f02022-04-22 09:24:20 +0100138*Copyright (c) 2017-2022, Arm Limited. All rights reserved.*