SPM: Enhance build control for IPC and SFN models
Currently, different models configuration such as
CONFIG_TFM_PSA_API_xxx_CALL are configured in generated header
file config_impl.h. CMake build system has no information on
which model should be built. As a result, files for different
models are always build in IPC model, such as psa_interface_cross.c,
psa_interface_sfn.c and psa_interface_svc.c.
This patch:
- Generate CMake variables for each model.
- Configure the build system based on generated CMake variables.
Signed-off-by: Sherry Zhang <sherry.zhang2@arm.com>
Change-Id: If3f92b07b618b13ca596306ffd19867010de83b7
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index c55cd90..7e95643 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -143,6 +143,8 @@
RESULT_VARIABLE RET
)
-if(NOT RET EQUAL 0)
+if(RET EQUAL 0)
+ include(${CMAKE_BINARY_DIR}/generated/tools/config_impl.cmake)
+else()
message(FATAL_ERROR "File generation failed")
endif()
diff --git a/tools/config_impl.cmake.template b/tools/config_impl.cmake.template
new file mode 100644
index 0000000..59a327c
--- /dev/null
+++ b/tools/config_impl.cmake.template
@@ -0,0 +1,39 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2022, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+
+########{{utilities.donotedit_warning}}########
+
+if(TFM_PSA_API)
+{% if partition_statistics['ipc_partition_num'] > 0
+ and partition_statistics['sfn_partition_num'] == 0 %}
+ set(CONFIG_TFM_SPM_BACKEND_IPC ON PARENT_SCOPE)
+
+ if(TFM_ISOLATION_LEVEL GREATER 1)
+ set(CONFIG_TFM_PSA_API_SUPERVISOR_CALL ON PARENT_SCOPE)
+ else()
+ set(CONFIG_TFM_PSA_API_CROSS_CALL ON PARENT_SCOPE)
+ endif()
+{% elif partition_statistics['sfn_partition_num'] > 0
+ and partition_statistics['ipc_partition_num'] == 0 %}
+ set(CONFIG_TFM_SPM_BACKEND_SFN ON PARENT_SCOPE)
+ set(CONFIG_TFM_PSA_API_SFN_CALL ON PARENT_SCOPE)
+
+ if(TFM_ISOLATION_LEVEL GREATER 1)
+ message(FATAL_ERROR "High isolation level SFN model is not supported.")
+ endif()
+{% elif partition_statistics['sfn_partition_num'] > 0
+ and partition_statistics['ipc_partition_num'] > 0 %}
+ message(FATAL_ERROR "IPC and SFN co-work not supported yet.")
+{% else %}
+ message(FATAL_ERROR "Invalid partition number input, check configurations.")
+{% endif %}
+
+ if((CONFIG_TFM_SPE_FP GREATER 0) AND CONFIG_TFM_SPM_BACKEND_SFN)
+ message(FATAL_ERROR "FP is not supported for SFN model.")
+ endif()
+endif()
diff --git a/tools/templates/manifestfilename.template b/tools/templates/manifestfilename.template
index 54ba9dc..9f90907 100644
--- a/tools/templates/manifestfilename.template
+++ b/tools/templates/manifestfilename.template
@@ -1,11 +1,11 @@
/*
- * Copyright (c) 2019-2021, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2022, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
-{{utilities.donotedit_warning}}
+/***********{{utilities.donotedit_warning}}***********/
#ifndef __PSA_MANIFEST_{{manifest_out_basename.upper()}}_H__
#define __PSA_MANIFEST_{{manifest_out_basename.upper()}}_H__
diff --git a/tools/templates/partition_intermedia.template b/tools/templates/partition_intermedia.template
index ce3d08b..a52a2cb 100644
--- a/tools/templates/partition_intermedia.template
+++ b/tools/templates/partition_intermedia.template
@@ -1,11 +1,11 @@
/*
- * Copyright (c) 2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2020-2022, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
-{{utilities.donotedit_warning}}
+/***********{{utilities.donotedit_warning}}***********/
#include <stdint.h>
diff --git a/tools/templates/partition_load_info.template b/tools/templates/partition_load_info.template
index a691ba2..d9e6bb2 100644
--- a/tools/templates/partition_load_info.template
+++ b/tools/templates/partition_load_info.template
@@ -1,12 +1,12 @@
/*
- * Copyright (c) 2021, Arm Limited. All rights reserved.
+ * Copyright (c) 2021-2022, Arm Limited. All rights reserved.
* Copyright (c) 2021, Cypress Semiconductor Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
-{{utilities.donotedit_warning}}
+/***********{{utilities.donotedit_warning}}***********/
#include <stdint.h>
#include <stddef.h>
diff --git a/tools/tfm_generated_file_list.yaml b/tools/tfm_generated_file_list.yaml
index 0c866c7..a8ffe19 100644
--- a/tools/tfm_generated_file_list.yaml
+++ b/tools/tfm_generated_file_list.yaml
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2018-2021, Arm Limited. All rights reserved.
+# Copyright (c) 2018-2022, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -56,6 +56,12 @@
"short_name": "config_impl.h",
"template": "interface/include/config_impl.h.template",
"output": "interface/include/config_impl.h"
+ },
+ {
+ "name": "CMake variables generated",
+ "short_name": "config_impl.cmake",
+ "template": "tools/config_impl.cmake.template",
+ "output": "tools/config_impl.cmake"
}
]
}
diff --git a/tools/tfm_parse_manifest_list.py b/tools/tfm_parse_manifest_list.py
index 5652461..3a6bd71 100644
--- a/tools/tfm_parse_manifest_list.py
+++ b/tools/tfm_parse_manifest_list.py
@@ -20,9 +20,7 @@
exit(1)
donotedit_warning = \
- '/*********** ' + \
- 'WARNING: This is an auto-generated file. Do not edit!' + \
- ' ***********/'
+ ' WARNING: This is an auto-generated file. Do not edit! '
TFM_ROOT_DIR = os.path.join(sys.path[0], '..')
OUT_DIR = None # The root directory that files are generated to
@@ -267,11 +265,8 @@
context contains partition infos
"""
- utilities = {}
- utilities['donotedit_warning'] = donotedit_warning
-
partition_context = {}
- partition_context['utilities'] = utilities
+ partition_context['utilities'] = context['utilities']
manifesttemplate = ENV.get_template(os.path.join(sys.path[0], 'templates/manifestfilename.template'))
memorytemplate = ENV.get_template(os.path.join(sys.path[0], 'templates/partition_intermedia.template'))
@@ -337,7 +332,6 @@
manifest_out_file = os.path.join(OUT_DIR, manifest_out_file)
print ('Generating ' + manifest_out_file)
-
outfile_path = os.path.dirname(manifest_out_file)
if not os.path.exists(outfile_path):
os.makedirs(outfile_path)