diff options
author | Mingyang Sun <mingyang.sun@arm.com> | 2021-01-26 10:33:52 +0800 |
---|---|---|
committer | Mingyang Sun <mingyang.sun@arm.com> | 2021-03-22 11:11:50 +0800 |
commit | bc7c996c29f4714ccbfbff4c86e0a1b9d44c7f78 (patch) | |
tree | 321c72ff47bab3284c88d33e9232bea82ea5acdd | |
parent | 9ac44d3e8a17db88993aa60454421e06a7693371 (diff) | |
download | trusted-firmware-m-bc7c996c29f4714ccbfbff4c86e0a1b9d44c7f78.tar.gz |
Service: Create an example FF-M v1.1 partition
An example partition is created for testing FF-M v1.1 stateless
handle, only enabled in IPC model. It is also for future use.
Change-Id: I699bb23a24bc555b2d8769001b931f2d2c42277b
Signed-off-by: Mingyang Sun <mingyang.sun@arm.com>
-rw-r--r-- | config/tfm_ipc_config_default.cmake | 1 | ||||
-rw-r--r-- | secure_fw/CMakeLists.txt | 1 | ||||
-rw-r--r-- | secure_fw/partitions/tfm_ffm11_partition/CMakeLists.txt | 50 | ||||
-rw-r--r-- | secure_fw/partitions/tfm_ffm11_partition/tfm_ffm11_partition.c | 73 | ||||
-rw-r--r-- | secure_fw/partitions/tfm_ffm11_partition/tfm_ffm11_partition.yaml | 44 | ||||
-rw-r--r-- | tools/tfm_manifest_list.yaml | 19 |
6 files changed, 186 insertions, 2 deletions
diff --git a/config/tfm_ipc_config_default.cmake b/config/tfm_ipc_config_default.cmake index 14512e9b68..b18be1f54b 100644 --- a/config/tfm_ipc_config_default.cmake +++ b/config/tfm_ipc_config_default.cmake @@ -8,3 +8,4 @@ ############################ Partitions ######################################## set(TFM_PARTITION_AUDIT_LOG OFF CACHE BOOL "Enable Audit Log partition") +set(TFM_PARTITION_FFM11 ON CACHE BOOL "Enable the FFM1.1 partition") diff --git a/secure_fw/CMakeLists.txt b/secure_fw/CMakeLists.txt index 26dbfa20ea..afe1d0f400 100644 --- a/secure_fw/CMakeLists.txt +++ b/secure_fw/CMakeLists.txt @@ -27,6 +27,7 @@ add_subdirectory(partitions/internal_trusted_storage) add_subdirectory(partitions/platform) add_subdirectory(partitions/psa_proxy) add_subdirectory(partitions/firmware_update) +add_subdirectory(partitions/tfm_ffm11_partition) add_subdirectory(spm) target_include_directories(secure_fw diff --git a/secure_fw/partitions/tfm_ffm11_partition/CMakeLists.txt b/secure_fw/partitions/tfm_ffm11_partition/CMakeLists.txt new file mode 100644 index 0000000000..2d3ba76c7b --- /dev/null +++ b/secure_fw/partitions/tfm_ffm11_partition/CMakeLists.txt @@ -0,0 +1,50 @@ + +#------------------------------------------------------------------------------- +# Copyright (c) 2021, Arm Limited. All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# +#------------------------------------------------------------------------------- +if (NOT TFM_PARTITION_FFM11) + return() +endif() + +cmake_minimum_required(VERSION 3.15) +cmake_policy(SET CMP0079 NEW) + +add_library(tfm_app_rot_partition_ffm11 STATIC) + +target_sources(tfm_app_rot_partition_ffm11 + PRIVATE + tfm_ffm11_partition.c +) + +# The generated sources +target_sources(tfm_app_rot_partition_ffm11 + PRIVATE + ${CMAKE_BINARY_DIR}/generated/secure_fw/partitions/tfm_ffm11_partition/auto_generated/intermedia_tfm_ffm11_partition.c +) + +target_include_directories(tfm_app_rot_partition_ffm11 + PRIVATE + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> + ${CMAKE_BINARY_DIR}/generated/secure_fw/partitions/tfm_ffm11_partition +) + +target_link_libraries(tfm_app_rot_partition_ffm11 + PRIVATE + tfm_secure_api + psa_interface + platform_s + tfm_sprt +) + +############################ Partition Defs #################################### +target_link_libraries(tfm_partitions + INTERFACE + tfm_app_rot_partition_ffm11 +) +target_compile_definitions(tfm_partition_defs + INTERFACE + TFM_PARTITION_FFM11 +) diff --git a/secure_fw/partitions/tfm_ffm11_partition/tfm_ffm11_partition.c b/secure_fw/partitions/tfm_ffm11_partition/tfm_ffm11_partition.c new file mode 100644 index 0000000000..d7f5be0678 --- /dev/null +++ b/secure_fw/partitions/tfm_ffm11_partition/tfm_ffm11_partition.c @@ -0,0 +1,73 @@ + +/* + * Copyright (c) 2021, Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + */ + +#include <stdint.h> +#include "psa/service.h" +#include "psa_manifest/tfm_ffm11_partition.h" +#include "tfm/tfm_spm_services.h" +#include "tfm_sp_log.h" + +/** + * \brief An example service implementation that prints out a message. + */ +static void tfm_ffm11_service1(void) +{ + psa_status_t status; + uint32_t arg; + psa_msg_t msg; + size_t num; + + /* Retrieve the message corresponding to the example service signal */ + status = psa_get(TFM_FFM11_SERVICE1_SIGNAL, &msg); + if (status != PSA_SUCCESS) { + return; + } + + /* Decode the message */ + switch (msg.type) { + case PSA_IPC_CALL: + if (msg.in_size[0] != sizeof(arg)) { + status = PSA_ERROR_PROGRAMMER_ERROR; + break; + } + /* Print arg from client */ + num = psa_read(msg.handle, 0, &arg, sizeof(arg)); + if (num != msg.in_size[0]) { + status = PSA_ERROR_PROGRAMMER_ERROR; + break; + } + LOG_INFFMT("[Example FFM11 partition] Service called! arg=%x\r\n", arg); + status = PSA_SUCCESS; + break; + default: + /* Invalid message type */ + status = PSA_ERROR_PROGRAMMER_ERROR; + break; + } + /* Reply with the message result status to unblock the client */ + psa_reply(msg.handle, status); +} + +/** + * \brief The example FFM-1.1 partition's entry function. + */ +void tfm_ffm11_partition_main(void) +{ + psa_signal_t signals; + + while (1) { + signals = psa_wait(PSA_WAIT_ANY, PSA_BLOCK); + if (signals & TFM_FFM11_SERVICE1_SIGNAL) { + tfm_ffm11_service1(); + } + /* + * The other services are created in yaml for testing manifest tool, + * but not handled here. They are reserved for future use. + */ + } +} diff --git a/secure_fw/partitions/tfm_ffm11_partition/tfm_ffm11_partition.yaml b/secure_fw/partitions/tfm_ffm11_partition/tfm_ffm11_partition.yaml new file mode 100644 index 0000000000..abe0253c42 --- /dev/null +++ b/secure_fw/partitions/tfm_ffm11_partition/tfm_ffm11_partition.yaml @@ -0,0 +1,44 @@ +#------------------------------------------------------------------------------- +# Copyright (c) 2021, Arm Limited. All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# +#------------------------------------------------------------------------------- + +{ + "psa_framework_version": 1.1, + "name": "TFM_SP_FFM11", + "type": "APPLICATION-ROT", + "priority": "NORMAL", + "entry_point": "tfm_ffm11_partition_main", + "stack_size": "0x200", + "services": [ + { + "name": "TFM_FFM11_SERVICE1", + "sid": "0x0000F120", + "non_secure_clients": true, + "connection_based": false, + "stateless_handle": 4, + "version": 1, + "version_policy": "RELAXED" + }, + { + "name": "TFM_FFM11_SERVICE2", + "sid": "0x0000F121", + "non_secure_clients": true, + "connection_based": false, + "stateless_handle": "auto", + "version": 1, + "version_policy": "RELAXED" + }, + { + "name": "TFM_FFM11_SERVICE3", + "sid": "0x0000F122", + "non_secure_clients": true, + "connection_based": false, + "stateless_handle": 3, + "version": 1, + "version_policy": "RELAXED" + } + ], +} diff --git a/tools/tfm_manifest_list.yaml b/tools/tfm_manifest_list.yaml index 39ddfecefd..d69c66da99 100644 --- a/tools/tfm_manifest_list.yaml +++ b/tools/tfm_manifest_list.yaml @@ -256,9 +256,24 @@ "pid": 271, "linker_pattern": { "library_list": [ - "*tfm_*partition_fwu*" + "*tfm_*partition_fwu*" ] } - } + }, + { + "name": "TFM FFM11 Partition Service", + "short_name": "TFM_SP_FFM11", + "manifest": "secure_fw/partitions/tfm_ffm11_partition/tfm_ffm11_partition.yaml", + "tfm_partition_ipc": true, + "conditional": "TFM_PARTITION_FFM11", + "version_major": 0, + "version_minor": 1, + "pid": 272, + "linker_pattern": { + "library_list": [ + "*tfm_*partition_ffm11.*" + ] + } + }, ] } |