Build: Generate manifest file name header file
According to PSA FF, the 'manifestfilename.h' need be created by tools:
- Add generate_manifestfilename() function to generate this header file.
- The template file is put in 'secure_fw/services'.
- The related header files of secure partition and test partition are
created by tools.
Change-Id: Ic53ad481860fea018f29b7eca5a9548d074c19ae
Signed-off-by: Edison Ai <edison.ai@arm.com>
diff --git a/secure_fw/services/audit_logging/psa_manifest/tfm_audit_logging.h b/secure_fw/services/audit_logging/psa_manifest/tfm_audit_logging.h
new file mode 100644
index 0000000..b22a970
--- /dev/null
+++ b/secure_fw/services/audit_logging/psa_manifest/tfm_audit_logging.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+/*********** WARNING: This is an auto-generated file. Do not edit! ***********/
+
+#ifndef __PSA_MANIFEST_TFM_AUDIT_LOGGING_H__
+#define __PSA_MANIFEST_TFM_AUDIT_LOGGING_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef TFM_PARTITION_AUDIT_LOG
+
+#endif /* TFM_PARTITION_AUDIT_LOG */
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __PSA_MANIFEST_TFM_AUDIT_LOGGING_H__ */
diff --git a/secure_fw/services/crypto/psa_manifest/tfm_crypto.h b/secure_fw/services/crypto/psa_manifest/tfm_crypto.h
new file mode 100644
index 0000000..3047087
--- /dev/null
+++ b/secure_fw/services/crypto/psa_manifest/tfm_crypto.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+/*********** WARNING: This is an auto-generated file. Do not edit! ***********/
+
+#ifndef __PSA_MANIFEST_TFM_CRYPTO_H__
+#define __PSA_MANIFEST_TFM_CRYPTO_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define TFM_CRYPTO_SIG (1U << ( 0 + 4))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __PSA_MANIFEST_TFM_CRYPTO_H__ */
diff --git a/secure_fw/services/initial_attestation/psa_manifest/tfm_initial_attestation.h b/secure_fw/services/initial_attestation/psa_manifest/tfm_initial_attestation.h
new file mode 100644
index 0000000..6cf3e1e
--- /dev/null
+++ b/secure_fw/services/initial_attestation/psa_manifest/tfm_initial_attestation.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+/*********** WARNING: This is an auto-generated file. Do not edit! ***********/
+
+#ifndef __PSA_MANIFEST_TFM_INITIAL_ATTESTATION_H__
+#define __PSA_MANIFEST_TFM_INITIAL_ATTESTATION_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define PSA_ATTEST_GET_TOKEN_SIG (1U << ( 0 + 4))
+#define PSA_ATTEST_GET_TOKEN_SIZE_SIG (1U << ( 1 + 4))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __PSA_MANIFEST_TFM_INITIAL_ATTESTATION_H__ */
diff --git a/secure_fw/services/manifestfilename.template b/secure_fw/services/manifestfilename.template
new file mode 100644
index 0000000..b1ddd4c
--- /dev/null
+++ b/secure_fw/services/manifestfilename.template
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+{{utilities.donotedit_warning}}
+
+#ifndef __PSA_MANIFEST_{{file_name.upper()}}_H__
+#define __PSA_MANIFEST_{{file_name.upper()}}_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+{% if attr.conditional %}
+#ifdef {{attr.conditional}}
+{% endif %}
+{% if attr.tfm_partition_ipc %}
+ {% set ns = namespace(iterator_counter=0) %}
+ {% if manifest.services %}
+ {% for service in manifest.services %}
+#define {{"%-55s"|format(service.signal)}} (1U << ({{"%2d"|format(ns.iterator_counter)}} + 4))
+ {% set ns.iterator_counter = ns.iterator_counter + 1 %}
+ {% endfor %}
+ {% endif %}
+ {% if ns.iterator_counter > 28 %}
+
+#error "Too many signals!"
+ {% endif %}
+{% endif %}
+{% if manifest.irqs %}
+
+ {% set irq_ns = namespace(irq_iterator_counter=27) %}
+ {% for irq in manifest.irqs %}
+#define {{"%-55s"|format(irq.signal)}} (1U << ({{"%2d"|format(irq_ns.irq_iterator_counter)}} + 4))
+ {% set irq_ns.irq_iterator_counter = irq_ns.irq_iterator_counter - 1 %}
+ {% endfor %}
+ {% if attr.tfm_partition_ipc %}
+ {% if (ns.iterator_counter - 1) >= (irq_ns.irq_iterator_counter + 1) %}
+
+#error "Secure service and IRQ signal values overlap!"
+ {% endif %}
+ {% else %}
+ {% if (irq_ns.irq_iterator_counter + 1) < 0 %}
+
+#error "Too many IRQ signals!"
+ {% endif %}
+ {% endif %}
+{% endif %}
+
+{% if attr.conditional %}
+#endif /* {{attr.conditional}} */
+{% endif %}
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __PSA_MANIFEST_{{file_name.upper()}}_H__ */
diff --git a/secure_fw/services/platform/psa_manifest/tfm_platform.h b/secure_fw/services/platform/psa_manifest/tfm_platform.h
new file mode 100644
index 0000000..5eab230
--- /dev/null
+++ b/secure_fw/services/platform/psa_manifest/tfm_platform.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+/*********** WARNING: This is an auto-generated file. Do not edit! ***********/
+
+#ifndef __PSA_MANIFEST_TFM_PLATFORM_H__
+#define __PSA_MANIFEST_TFM_PLATFORM_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef TFM_PARTITION_PLATFORM
+
+#endif /* TFM_PARTITION_PLATFORM */
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __PSA_MANIFEST_TFM_PLATFORM_H__ */
diff --git a/secure_fw/services/secure_storage/psa_manifest/tfm_secure_storage.h b/secure_fw/services/secure_storage/psa_manifest/tfm_secure_storage.h
new file mode 100644
index 0000000..b6ab3dd
--- /dev/null
+++ b/secure_fw/services/secure_storage/psa_manifest/tfm_secure_storage.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+/*********** WARNING: This is an auto-generated file. Do not edit! ***********/
+
+#ifndef __PSA_MANIFEST_TFM_SECURE_STORAGE_H__
+#define __PSA_MANIFEST_TFM_SECURE_STORAGE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define TFM_SST_SET_SIG (1U << ( 0 + 4))
+#define TFM_SST_GET_SIG (1U << ( 1 + 4))
+#define TFM_SST_GET_INFO_SIG (1U << ( 2 + 4))
+#define TFM_SST_REMOVE_SIG (1U << ( 3 + 4))
+#define TFM_SST_GET_SUPPORT_SIG (1U << ( 4 + 4))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __PSA_MANIFEST_TFM_SECURE_STORAGE_H__ */
diff --git a/test/test_services/tfm_core_test/psa_manifest/tfm_test_core.h b/test/test_services/tfm_core_test/psa_manifest/tfm_test_core.h
new file mode 100644
index 0000000..e6ab73b
--- /dev/null
+++ b/test/test_services/tfm_core_test/psa_manifest/tfm_test_core.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+/*********** WARNING: This is an auto-generated file. Do not edit! ***********/
+
+#ifndef __PSA_MANIFEST_TFM_TEST_CORE_H__
+#define __PSA_MANIFEST_TFM_TEST_CORE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef TFM_PARTITION_TEST_CORE
+#define SPM_CORE_TEST_INIT_SUCCESS_SIGNAL (1U << ( 0 + 4))
+#define SPM_CORE_TEST_DIRECT_RECURSION_SIGNAL (1U << ( 1 + 4))
+#define SPM_CORE_TEST_MPU_ACCESS_SIGNAL (1U << ( 2 + 4))
+#define SPM_CORE_TEST_MEMORY_PERMISSIONS_SIGNAL (1U << ( 3 + 4))
+#define SPM_CORE_TEST_SHARE_REDIRECTION_SIGNAL (1U << ( 4 + 4))
+#define SPM_CORE_TEST_SS_TO_SS_SIGNAL (1U << ( 5 + 4))
+#define SPM_CORE_TEST_SS_TO_SS_BUFFER_SIGNAL (1U << ( 6 + 4))
+#define SPM_CORE_TEST_OUTVEC_WRITE_SIGNAL (1U << ( 7 + 4))
+#define SPM_CORE_TEST_PERIPHERAL_ACCESS_SIGNAL (1U << ( 8 + 4))
+#define SPM_CORE_TEST_GET_CALLER_CLIENT_ID_SIGNAL (1U << ( 9 + 4))
+#define SPM_CORE_TEST_SPM_REQUEST_SIGNAL (1U << (10 + 4))
+#define SPM_CORE_TEST_BLOCK_SIGNAL (1U << (11 + 4))
+#define SPM_CORE_TEST_NS_THREAD_SIGNAL (1U << (12 + 4))
+
+#endif /* TFM_PARTITION_TEST_CORE */
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __PSA_MANIFEST_TFM_TEST_CORE_H__ */
diff --git a/test/test_services/tfm_core_test_2/psa_manifest/tfm_test_core_2.h b/test/test_services/tfm_core_test_2/psa_manifest/tfm_test_core_2.h
new file mode 100644
index 0000000..565d3dc
--- /dev/null
+++ b/test/test_services/tfm_core_test_2/psa_manifest/tfm_test_core_2.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+/*********** WARNING: This is an auto-generated file. Do not edit! ***********/
+
+#ifndef __PSA_MANIFEST_TFM_TEST_CORE_2_H__
+#define __PSA_MANIFEST_TFM_TEST_CORE_2_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef TFM_PARTITION_TEST_CORE
+#define SPM_CORE_TEST_2_SLAVE_SERVICE_SIGNAL (1U << ( 0 + 4))
+#define SPM_CORE_TEST_2_CHECK_CALLER_CLIENT_ID_SIGNAL (1U << ( 1 + 4))
+#define SPM_CORE_TEST_2_GET_EVERY_SECOND_BYTE_SIGNAL (1U << ( 2 + 4))
+#define SPM_CORE_TEST_2_INVERT_SIGNAL (1U << ( 3 + 4))
+#define SPM_CORE_TEST_2_PREPARE_TEST_SCENARIO_SIGNAL (1U << ( 4 + 4))
+#define SPM_CORE_TEST_2_EXECUTE_TEST_SCENARIO_SIGNAL (1U << ( 5 + 4))
+
+#endif /* TFM_PARTITION_TEST_CORE */
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __PSA_MANIFEST_TFM_TEST_CORE_2_H__ */
diff --git a/test/test_services/tfm_ipc_client/psa_manifest/tfm_ipc_client_partition.h b/test/test_services/tfm_ipc_client/psa_manifest/tfm_ipc_client_partition.h
new file mode 100644
index 0000000..b8688d9
--- /dev/null
+++ b/test/test_services/tfm_ipc_client/psa_manifest/tfm_ipc_client_partition.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+/*********** WARNING: This is an auto-generated file. Do not edit! ***********/
+
+#ifndef __PSA_MANIFEST_TFM_IPC_CLIENT_PARTITION_H__
+#define __PSA_MANIFEST_TFM_IPC_CLIENT_PARTITION_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef TFM_PARTITION_TEST_CORE_IPC
+#define IPC_CLIENT_TEST_BASIC_SIGNAL (1U << ( 0 + 4))
+#define IPC_CLIENT_TEST_PSA_ACCESS_APP_MEM_SIGNAL (1U << ( 1 + 4))
+#define IPC_CLIENT_TEST_PSA_ACCESS_APP_READ_ONLY_MEM_SIGNAL (1U << ( 2 + 4))
+#define IPC_CLIENT_TEST_APP_ACCESS_PSA_MEM_SIGNAL (1U << ( 3 + 4))
+#define IPC_CLIENT_TEST_MEM_CHECK_SIGNAL (1U << ( 4 + 4))
+
+#endif /* TFM_PARTITION_TEST_CORE_IPC */
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __PSA_MANIFEST_TFM_IPC_CLIENT_PARTITION_H__ */
diff --git a/test/test_services/tfm_ipc_service/psa_manifest/tfm_ipc_service_partition.h b/test/test_services/tfm_ipc_service/psa_manifest/tfm_ipc_service_partition.h
new file mode 100644
index 0000000..97465db
--- /dev/null
+++ b/test/test_services/tfm_ipc_service/psa_manifest/tfm_ipc_service_partition.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+/*********** WARNING: This is an auto-generated file. Do not edit! ***********/
+
+#ifndef __PSA_MANIFEST_TFM_IPC_SERVICE_PARTITION_H__
+#define __PSA_MANIFEST_TFM_IPC_SERVICE_PARTITION_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef TFM_PARTITION_TEST_CORE_IPC
+#define IPC_SERVICE_TEST_BASIC_SIGNAL (1U << ( 0 + 4))
+#define IPC_SERVICE_TEST_PSA_ACCESS_APP_MEM_SIGNAL (1U << ( 1 + 4))
+#define IPC_SERVICE_TEST_PSA_ACCESS_APP_READ_ONLY_MEM_SIGNAL (1U << ( 2 + 4))
+#define IPC_SERVICE_TEST_APP_ACCESS_PSA_MEM_SIGNAL (1U << ( 3 + 4))
+
+#endif /* TFM_PARTITION_TEST_CORE_IPC */
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __PSA_MANIFEST_TFM_IPC_SERVICE_PARTITION_H__ */
diff --git a/test/test_services/tfm_irq_test_service_1/psa_manifest/tfm_irq_test_service_1.h b/test/test_services/tfm_irq_test_service_1/psa_manifest/tfm_irq_test_service_1.h
new file mode 100644
index 0000000..585169f
--- /dev/null
+++ b/test/test_services/tfm_irq_test_service_1/psa_manifest/tfm_irq_test_service_1.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+/*********** WARNING: This is an auto-generated file. Do not edit! ***********/
+
+#ifndef __PSA_MANIFEST_TFM_IRQ_TEST_SERVICE_1_H__
+#define __PSA_MANIFEST_TFM_IRQ_TEST_SERVICE_1_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef TFM_PARTITION_TEST_CORE
+#define SPM_CORE_IRQ_TEST_1_PREPARE_TEST_SCENARIO_SIGNAL (1U << ( 0 + 4))
+#define SPM_CORE_IRQ_TEST_1_EXECUTE_TEST_SCENARIO_SIGNAL (1U << ( 1 + 4))
+
+#define SPM_CORE_IRQ_TEST_1_SIGNAL_TIMER_0_IRQ (1U << (27 + 4))
+
+#endif /* TFM_PARTITION_TEST_CORE */
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __PSA_MANIFEST_TFM_IRQ_TEST_SERVICE_1_H__ */
diff --git a/test/test_services/tfm_secure_client_service/psa_manifest/tfm_test_client_service.h b/test/test_services/tfm_secure_client_service/psa_manifest/tfm_test_client_service.h
new file mode 100644
index 0000000..5904681
--- /dev/null
+++ b/test/test_services/tfm_secure_client_service/psa_manifest/tfm_test_client_service.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+/*********** WARNING: This is an auto-generated file. Do not edit! ***********/
+
+#ifndef __PSA_MANIFEST_TFM_TEST_CLIENT_SERVICE_H__
+#define __PSA_MANIFEST_TFM_TEST_CLIENT_SERVICE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef TFM_PARTITION_TEST_SECURE_SERVICES
+#define TFM_SECURE_CLIENT_SFN_RUN_TESTS_SIG (1U << ( 0 + 4))
+
+#endif /* TFM_PARTITION_TEST_SECURE_SERVICES */
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __PSA_MANIFEST_TFM_TEST_CLIENT_SERVICE_H__ */
diff --git a/tools/tfm_parse_manifest_list.py b/tools/tfm_parse_manifest_list.py
index 1ed8b81..102ff13 100644
--- a/tools/tfm_parse_manifest_list.py
+++ b/tools/tfm_parse_manifest_list.py
@@ -16,6 +16,12 @@
print ("pip install PyYAML")
exit(1)
+donotedit_warning = \
+ "/*********** " + \
+ "WARNING: This is an auto-generated file. Do not edit!" + \
+ " ***********/"
+manifest_list_yaml_file_path = os.path.join('tools', 'tfm_manifest_list.yaml')
+
class TemplateLoader(BaseLoader):
"""
Template loader class.
@@ -69,6 +75,51 @@
return db
+def generate_manifestfilename(env):
+ """
+ Generate manifestfilename header file.
+
+ Parameters
+ ----------
+ env :
+ The instance of Environment.
+ """
+ with open(manifest_list_yaml_file_path) as manifest_list_yaml_file:
+ manifest_list = yaml.load(manifest_list_yaml_file)
+ templatefile_name = 'secure_fw/services/manifestfilename.template'
+ template = env.get_template(templatefile_name)
+
+ for manifest_file in manifest_list["manifest_list"]:
+ manifest_path = manifest_file['manifest']
+ file = open(manifest_path)
+ manifest = yaml.load(file)
+
+ utilities = {}
+ utilities['donotedit_warning']=donotedit_warning
+
+ context = {}
+ context['manifest'] = manifest
+ context['attr'] = manifest_file
+ context['utilities'] = utilities
+
+ manifest_dir, sep, manifest_name = manifest_path.rpartition('/')
+ outfile_name = manifest_name.replace('yaml', 'h')
+ outfile_path = manifest_dir + sep + "psa_manifest/" + outfile_name
+
+ context['file_name'] = outfile_name.replace('.h', '')
+
+ print ("Generating " + outfile_path)
+
+ if not os.path.exists(os.path.dirname(outfile_path)):
+ try:
+ os.makedirs(os.path.dirname(outfile_path))
+ except OSError:
+ raise Exception ("Failed to create folder" + os.path.dirname(outfile_path))
+
+ outfile = io.open(outfile_path, "w", newline='\n')
+ outfile.write(template.render(context))
+ outfile.close()
+ return
def main():
"""
@@ -76,11 +127,6 @@
Generates the output files based on the templates and the manifests.
"""
- donotedit_warning = \
- "/*********** " + \
- "WARNING: This is an auto-generated file. Do not edit!" + \
- " ***********/"
-
env = Environment(
loader = TemplateLoader(),
autoescape = select_autoescape(['html', 'xml']),
@@ -89,8 +135,7 @@
keep_trailing_newline = True
)
- with open(os.path.join('tools', 'tfm_manifest_list.yaml')) \
- as manifest_list_yaml_file:
+ with open(manifest_list_yaml_file_path) as manifest_list_yaml_file:
# Read manifest list file, build database
db = load_manifest_list(manifest_list_yaml_file)
@@ -117,6 +162,10 @@
outfile = io.open(outfile_name, "w", newline='\n')
outfile.write(template.render(context))
outfile.close()
+
+ # Generate manifestfilename
+ generate_manifestfilename(env)
+
print ("Generation of files done")
if __name__ == "__main__":