blob: b070510d871dff4601a05fcdbce06d24f109654b [file] [log] [blame]
Julian Halle76ade82020-11-25 03:07:21 +01001Project Structure
2=================
3
4This page describes the directory and repository structure for the trusted services project.
5
6Top-Level Project Organization
7------------------------------
8The project is organized under the following top-level directories::
9
10 project
11 |-- docs
12 |-- deployments
13 |-- environments
14 |-- platforms
15 |-- components
16 |-- external
17 |-- protocols
18 |-- tools
19
20Top-level directories are used to organize project files as follows:
21
22docs
23''''
24
25The home for project documentation source.
26
27deployments
28'''''''''''
29
30A deployment represents the build instance of a service (or in fact any unit of functionality) for a particular
31environment. For each deployment, there is a single deployable output, usually a binary executable. The
32deployment is concerned with configuring and building a particular set of components to run in a particular
33environment. For each supported deployment, there is a leaf sub-directory that lives under a parent. The
34parent directory identifies what's being deployed while the leaf sub-directory identifies where it is being
35deployed. The following example illustrates how the 'what' and 'where' are combined to form fully defined
36deployments::
37
38 deployment-name = <descriptive-name>/<environment>
39
40 deployments
41 |-- secure-storage/opteesp
42 |-- crypto/opteesp
43 |-- ts-demo/arm-linux
44 |-- component-test/posix-x86
45 |-- ts-lib/posix-x86
46
47The trusted services project uses CMake to configure and generate build files. A CMakeLists.txt file exists
48for each deployment to define the set of components, any deployment specific configuration and anything
49environment specific. Each deployment leaf directory also holds a source file that defines the main entry
50point to allow a particular set of components to be initialized before entering the application that implements
51the core functionality of software being deployed.
52
53The directory structure for deployments supports inheritance from the deployment parent to promote reuse of
54common definitions and initialization code. For example, deployments of the secure-storage service for
55different environments are likely to have similarities in terms of the set of components used and in subsystem
56initialization code. To avoid duplication between deployments, common cmake and source files may be located
57under the deployment parent. This is illustrated in the following::
58
59 deployments
60 |-- secure-storage
61 |-- common.cmake <-- Common cmake file
62 |-- service_init.c <-- Common initialization code
63 |-- opteesp
64 |-- CMakeLists.txt <-- Includes ../common.cmake to inherit common definitions
65 |-- opteesp_service_init.c
66
67environments
68''''''''''''
69
70An environment represents the execution context in which a built image runs. There are different environments
71represented in the project structure, one for each supported isolated execution context. Files related to a
72particular environment live under a sub-directory whose name describes the environment. For example:
73
74 - opteesp An S-EL0 secure partition hosted by OP-TEE
75 - arm-linux Linux user-space, cross compiled for Arm.
76 - linux-pc Native PC POSIX environment
77
78Files related to an environment will tend to live outside of the project tree and will need to be imported
79in some way. How this is handled will depend on the environment. An environment will generally provide the
80following:
81
82 - Environment specific libraries that have been externally built.
83 - Public header files for libraries.
84 - An install method that takes a deployment image and installs it in the environment.
85 - Compiler configuration
86
87A deployment will include an environment specific build file (see above) that defines the list of environment
88specific components used for a deployment into a particular environment.
89
90platforms
91'''''''''
92
93For some deployments, an environment may not provide access to all hardware backed services needed by an
94application. Files under the platforms directory are concerned with configuring and building platform specific
95code that extends the capabilities of an environment. Details of how this works are described in the:
96:ref:`Portability Model`
97
98components
99''''''''''
100
101Source code lives under the components directory, organized as reusable groups of source files. A component
102is the unit of reuse for code that may be combined with other components to realize the functionality needed
103for a deployment. Creating a new deployment should be just a case of selecting the right set of components
104to provide the required functionality for the target environment. Some components may depend on other
105components and others may only make sense in a particular environment.
106
107The components sub-tree has an organization that reflects the layered model where service components are
108kept separate from RPC components and so on. There is also a separation between client components and service
109provider components. The following illustrates this::
110
111 components
112 |-- service
113 | |-- common
114 | | |-- test
115 | |-- secure-storage
116 | | |-- client
117 | | |-- provider
118 | | |-- test
119 | |-- crypto
120 | | |-- client
121 | | |- component.cmake
122 | | |-- provider
123 |-- rpc
124 | |-- common
125 | |-- ffarpc
126 | | |-- caller
127 | | |-- endpoint
128
129Each leaf directory under the components parent includes a cmake file called component.cmake. This is used to
130define all files that make up the component and any special defines that are needed to build it. A deployment
131CMakeLists.txt just needs to reference the required set of components. No details of the component internals
132are reflected in the deployment CMakeLists.txt file.
133
134Test components
135'''''''''''''''
136
137Test code is treated in exactly the same as any other source code and is organized into components to achieve
138the same reuse goals. To create a deployment intended for testing, you select an appropriate set of components
139where some happen to be test components. By convention, test components live in sub-directories called test.
140Test directories are located at the point in the components sub-tree that reflects the scope of tests. In the
141above example, two test sub-directories are illustrated. The locations of the test component directories imply
142the following about the scope of the tests::
143
144 components
145 |-- service
146 | |-- common
147 | | |-- test <-- Tests for the common service component
148 | |-- secure-storage
149 | | |-- client
150 | | |-- provider
151 | | |-- test <-- Service level tests for the secure-storage service
152
153If it is necessary to componentize tests further, sub-directories under the test directory may be used, say
154for different classes of test. e.g::
155
156 components
157 |-- service
158 |-- common
159 |-- test
160 |-- unit
161 |-- fuzz
162
163external
164''''''''
165
166Code that originates from other open source projects that needs to be built as part of trusted service
167deployments is represented by directories beneath the external top-level directory. External components
168are generally fetched from the source repo during the CMake build process. During the build for a particular
169deployment, a deployment specific configuration may be applied to an external component. A CMake file under
170each external component directory is responsible for fetching and building the external component::
171
172 external
173 |-- CppUTest
174 | |-- CppUTest.cmake
175 | |-- cpputest-cmake-fix.patch
176 |-- mbed-crypto
177 |-- nanopb
178
179protocols
180'''''''''
181
182The protocols directory holds protocol definition files to allow clients to use trusted services. Ideally,
183the service access protocol should be formally defined using an interface description language (IDL) that
184provides a programming language neutral definition of the service interface. The protocols directory
185structure accommodates protocol definitions using different definition methods. Where a service access
186protocol has been defined using an IDL with language compilation support, code may be generated from the
187interface description to allow RPC request and response parameters to be serialized and deserialized in a
188compatible way between service clients and providers. The protocols sub-tree is organized as follows::
189
190 protocols
191 |-- service
192 | |-- common
193 | |-- crypto
194 | | |-- packed-c <-- C structure based definitions
195 | | |-- protobuf <-- Protocol Buffers definitions
196 | |-- secure-storage
197 | |-- packed-c
198
199tools
200'''''
201
202The project directory structure includes a tools directory for holding general purpose tools components
203to support activities such as build and test.
204
205--------------
206
207*Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.*
208
209SPDX-License-Identifier: BSD-3-Clause