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