blob: b69af98504aafaf4fccd59e415072a6ec199db88 [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
Julian Hall2075a212021-03-24 10:11:29 +000041 |-- protected-storage/opteesp
Julian Halle76ade82020-11-25 03:07:21 +010042 |-- crypto/opteesp
43 |-- ts-demo/arm-linux
Julian Hall2075a212021-03-24 10:11:29 +000044 |-- component-test/linux-pc
45 |-- libts/linux-pc
Julian Halle76ade82020-11-25 03:07:21 +010046
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
Julian Hall2075a212021-03-24 10:11:29 +000074 - *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
Julian Halle76ade82020-11-25 03:07:21 +010077
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
Julian Hall2075a212021-03-24 10:11:29 +0000116 | | |-- frontend
117 | | |-- backend
118 | | |-- factory
Julian Halle76ade82020-11-25 03:07:21 +0100119 | | |-- test
120 | |-- crypto
121 | | |-- client
122 | | |- component.cmake
123 | | |-- provider
124 |-- rpc
125 | |-- common
126 | |-- ffarpc
127 | | |-- caller
128 | | |-- endpoint
129
130Each leaf directory under the components parent includes a cmake file called component.cmake. This is used to
131define all files that make up the component and any special defines that are needed to build it. A deployment
132CMakeLists.txt just needs to reference the required set of components. No details of the component internals
133are reflected in the deployment CMakeLists.txt file.
134
135Test components
136'''''''''''''''
137
138Test code is treated in exactly the same as any other source code and is organized into components to achieve
139the same reuse goals. To create a deployment intended for testing, you select an appropriate set of components
140where some happen to be test components. By convention, test components live in sub-directories called test.
141Test directories are located at the point in the components sub-tree that reflects the scope of tests. In the
142above example, two test sub-directories are illustrated. The locations of the test component directories imply
143the following about the scope of the tests::
144
145 components
146 |-- service
147 | |-- common
148 | | |-- test <-- Tests for the common service component
149 | |-- secure-storage
Julian Hall2075a212021-03-24 10:11:29 +0000150 | | |-- frontend
151 | | |-- backend
152 | | |-- factory
Julian Halle76ade82020-11-25 03:07:21 +0100153 | | |-- test <-- Service level tests for the secure-storage service
154
155If it is necessary to componentize tests further, sub-directories under the test directory may be used, say
156for different classes of test. e.g::
157
158 components
159 |-- service
160 |-- common
161 |-- test
162 |-- unit
163 |-- fuzz
164
165external
166''''''''
167
168Code that originates from other open source projects that needs to be built as part of trusted service
169deployments is represented by directories beneath the external top-level directory. External components
170are generally fetched from the source repo during the CMake build process. During the build for a particular
171deployment, a deployment specific configuration may be applied to an external component. A CMake file under
172each external component directory is responsible for fetching and building the external component::
173
174 external
175 |-- CppUTest
176 | |-- CppUTest.cmake
177 | |-- cpputest-cmake-fix.patch
178 |-- mbed-crypto
179 |-- nanopb
180
181protocols
182'''''''''
183
184The protocols directory holds protocol definition files to allow clients to use trusted services. Ideally,
185the service access protocol should be formally defined using an interface description language (IDL) that
186provides a programming language neutral definition of the service interface. The protocols directory
187structure accommodates protocol definitions using different definition methods. Where a service access
188protocol has been defined using an IDL with language compilation support, code may be generated from the
189interface description to allow RPC request and response parameters to be serialized and deserialized in a
190compatible way between service clients and providers. The protocols sub-tree is organized as follows::
191
192 protocols
193 |-- service
194 | |-- common
195 | |-- crypto
196 | | |-- packed-c <-- C structure based definitions
197 | | |-- protobuf <-- Protocol Buffers definitions
198 | |-- secure-storage
199 | |-- packed-c
200
201tools
202'''''
203
204The project directory structure includes a tools directory for holding general purpose tools components
205to support activities such as build and test.
206
207--------------
208
209*Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.*
210
211SPDX-License-Identifier: BSD-3-Clause