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