aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/CMakeLists.txt39
-rw-r--r--tools/templates/manifestfilename.template76
-rw-r--r--tools/templates/partition_intermedia.template12
-rw-r--r--tools/templates/partition_load_info.template267
-rw-r--r--tools/tfm_manifest_list.yaml162
-rw-r--r--tools/tfm_parse_manifest_list.py121
6 files changed, 496 insertions, 181 deletions
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 6c276800d1..6a2d01f1b4 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -14,7 +14,42 @@ get_filename_component(list_name ${TFM_MANIFEST_LIST} NAME)
configure_file(${TFM_MANIFEST_LIST} ${CMAKE_CURRENT_BINARY_DIR}/${list_name})
set(MANIFEST_LISTS ${CMAKE_CURRENT_BINARY_DIR}/${list_name})
-set(MANIFEST_LISTS ${MANIFEST_LISTS} ${TFM_EXTRA_MANIFEST_LIST_PATH})
+
+if (TFM_NS_REG_TEST OR TFM_S_REG_TEST)
+ list(APPEND TEMP_EXTRA_MANIFEST_LISTS ${TFM_TEST_PATH}/test_services/tfm_test_manifest_list.yaml)
+endif()
+
+if (TFM_EXTRA_MANIFEST_LIST_FILES)
+ list(APPEND TEMP_EXTRA_MANIFEST_LISTS ${TFM_EXTRA_MANIFEST_LIST_FILES})
+endif()
+
+# Build up out-of-tree manifest list array
+# Each manifest list occupies two elements in out-of-tree manifest list array:
+# - Manifest list path under build directory after configure_file()
+# - The original path of manifest list in source directory. It can be used to
+# build up manifest file path if manifest file path is a relative one in
+# manifest list.
+set(POSTFIX 1)
+
+foreach(MANIFEST_LIST IN LISTS TEMP_EXTRA_MANIFEST_LISTS)
+ if (NOT EXISTS ${MANIFEST_LIST})
+ message(FATAL_ERROR "Extra manifest list ${MANIFEST_LIST} doesn't exist")
+ endif()
+
+ get_filename_component(MANIFEST_LIST_NAME ${MANIFEST_LIST} NAME_WLE)
+ set(TEMP_MANIFEST_LIST
+ ${CMAKE_CURRENT_BINARY_DIR}/${MANIFEST_LIST_NAME}_${POSTFIX}.yaml)
+
+ configure_file(${MANIFEST_LIST} ${TEMP_MANIFEST_LIST})
+ list(APPEND OUT_OF_TREE_MANIFEST_LIST ${TEMP_MANIFEST_LIST})
+
+ get_filename_component(MANIFEST_LIST_PATH ${MANIFEST_LIST} DIRECTORY)
+ # Append the manifest list original path.
+ # Manifest file path can be a relative one to manifest list.
+ list(APPEND OUT_OF_TREE_MANIFEST_LIST ${MANIFEST_LIST_PATH})
+
+ math(EXPR POSTFIX "${POSTFIX} + 1")
+endforeach()
if ("${TEST_PSA_API}" STREQUAL "IPC")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tfm_psa_ff_test_manifest_list.yaml
@@ -76,6 +111,7 @@ add_custom_command(OUTPUT ${OUTPUT_FILES}
-m ${MANIFEST_LISTS}
-f ${GENERATED_FILE_LISTS}
-o ${CMAKE_BINARY_DIR}/generated
+ -e ${OUT_OF_TREE_MANIFEST_LIST}
DEPENDS ${TEMPLATE_FILES} ${MANIFEST_FILES}
DEPENDS ${MANIFEST_LISTS}
)
@@ -88,6 +124,7 @@ execute_process(
-m ${MANIFEST_LISTS}
-f ${GENERATED_FILE_LISTS}
-o ${CMAKE_BINARY_DIR}/generated
+ -e ${OUT_OF_TREE_MANIFEST_LIST}
RESULT_VARIABLE RET
)
diff --git a/tools/templates/manifestfilename.template b/tools/templates/manifestfilename.template
new file mode 100644
index 0000000000..6211ef34e6
--- /dev/null
+++ b/tools/templates/manifestfilename.template
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2019-2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+{{utilities.donotedit_warning}}
+
+#ifndef __PSA_MANIFEST_{{manifest_out_basename.upper()}}_H__
+#define __PSA_MANIFEST_{{manifest_out_basename.upper()}}_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+{% if manifest.psa_framework_version == 1.1 and manifest.model == "SFN" %}
+#define {{"%-55s"|format(manifest.name + "_MODEL_IPC")}} 0
+#define {{"%-55s"|format(manifest.name + "_MODEL_SFN")}} 1
+{% else %}
+#define {{"%-55s"|format(manifest.name + "_MODEL_IPC")}} 1
+#define {{"%-55s"|format(manifest.name + "_MODEL_SFN")}} 0
+{% endif %}
+
+{# Service and IRQ at least one must be declared. #}
+{% if (manifest.services | length) == 0 and (manifest.irqs | length) == 0 %}
+#error "Service and IRQ at least one must be declared!"
+{% endif %}
+
+{% set service_signal = namespace(bit=4) %}
+{% if manifest.services %}
+ {% for service in manifest.services %}
+ {% if manifest.psa_framework_version == 1.1 and manifest.model == "SFN" %}
+psa_status_t {{service.name|lower}}_sfn(const psa_msg_t* msg);
+ {% else %}
+#define {{"%-55s"|format(service.name + "_SIGNAL")}} (1U << {{"%d"|format(service_signal.bit)}})
+ {% set service_signal.bit = service_signal.bit + 1 %}
+ {% endif %}
+ {% endfor %}
+{% endif %}
+{% if service_signal.bit > 32 %}
+#error "Too many services!"
+{% endif %}
+
+{% set irq_signal = namespace(bit=31) %}
+{% if manifest.irqs %}
+ {% for irq in manifest.irqs %}
+ {% set irq_data = namespace() %}
+ {% if manifest.psa_framework_version == 1.0 %}
+ {% set irq_data.signal = irq.signal %}
+ {% else %}
+ {% set irq_data.signal = irq.name + "_SIGNAL" %}
+ {% endif %}
+#define {{"%-55s"|format(irq_data.signal)}} (1U << {{"%d"|format(irq_signal.bit)}})
+ {% set irq_signal.bit = irq_signal.bit - 1 %}
+ {% endfor %}
+ {% if manifest.psa_framework_version == 1.1 %}
+ {% for irq in manifest.irqs %}
+ {% if irq.handling == "FLIH" %}
+psa_flih_result_t {{irq.name|lower}}_flih(void);
+ {% endif %}
+ {% endfor %}
+ {% endif %}
+{% endif %}
+{% if (irq_signal.bit + 1) < 4 %}
+#error "Too many IRQ signals!"
+{% endif %}
+{% if (service_signal.bit - 1) >= (irq_signal.bit + 1) %}
+#error "Total number of services and irqs exceeds 28."
+{% endif %}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __PSA_MANIFEST_{{manifest_out_basename.upper()}}_H__ */
diff --git a/tools/templates/partition_intermedia.template b/tools/templates/partition_intermedia.template
new file mode 100644
index 0000000000..ce3d08b96b
--- /dev/null
+++ b/tools/templates/partition_intermedia.template
@@ -0,0 +1,12 @@
+/*
+ * Copyright (c) 2020, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+{{utilities.donotedit_warning}}
+
+#include <stdint.h>
+
+uint8_t {{manifest.name.lower()}}_stack[{{manifest.stack_size}}] __attribute__((aligned(8)));
diff --git a/tools/templates/partition_load_info.template b/tools/templates/partition_load_info.template
new file mode 100644
index 0000000000..07cd77e472
--- /dev/null
+++ b/tools/templates/partition_load_info.template
@@ -0,0 +1,267 @@
+/*
+ * Copyright (c) 2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+{{utilities.donotedit_warning}}
+
+#include <stdint.h>
+#include <stddef.h>
+#include "region.h"
+#include "spm_ipc.h"
+#include "load/interrupt_defs.h"
+#include "load/partition_defs.h"
+#include "load/service_defs.h"
+#include "load/asset_defs.h"
+#include "tfm_peripherals_def.h"
+#include "psa_manifest/pid.h"
+#include "psa_manifest/sid.h"
+#include "psa_manifest/{{manifest_out_basename}}.h"
+
+{% set counter = namespace() %}
+{% set counter.dep_counter = manifest.dependencies|count %}
+#define {{"%-55s"|format(manifest.name|upper + "_NDEPS")}} ({{"%d"|format(counter.dep_counter)}})
+{% set counter.service_counter = manifest.services|count %}
+#define {{"%-55s"|format(manifest.name|upper + "_NSERVS")}} ({{"%d"|format(counter.service_counter)}})
+{% set counter.asset_counter = manifest.mmio_regions|count %}
+#if TFM_LVL == 3
+#define {{"%-55s"|format(manifest.name|upper + "_NASSETS")}} ({{"%d"|format(counter.asset_counter)}} + 1)
+#else
+#define {{"%-55s"|format(manifest.name|upper + "_NASSETS")}} ({{"%d"|format(counter.asset_counter)}})
+#endif
+{% set counter.irq_counter = manifest.irqs|count %}
+#define {{"%-55s"|format(manifest.name|upper + "_NIRQS")}} ({{"%d"|format(counter.irq_counter)}})
+
+/* Memory region declaration */
+#if TFM_LVL == 3
+REGION_DECLARE(Image$$, PT_{{manifest.name}}_PRIVATE, _DATA_START$$Base);
+REGION_DECLARE(Image$$, PT_{{manifest.name}}_PRIVATE, _DATA_END$$Base);
+#endif
+extern uint8_t {{manifest.name|lower}}_stack[];
+
+{% if manifest.entry_init and manifest.entry_point %}
+#error "Both manifest.entry_init and manifest.entry_point exist, unsupported!"
+{% elif (manifest.model == "IPC" or manifest.psa_framework_version == 1.0) and (not manifest.entry_point) %}
+#error "The entry_point attribute is required, it should not be empty!"
+{% elif manifest.model == "SFN" and manifest.entry_point %}
+#error "The entry_point attribute should not be exist in SFN mode!"
+{% endif %}
+/* Entrypoint function declaration */
+{% if manifest.entry_point %}
+extern void {{manifest.entry_point}}(void);
+{% elif manifest.entry_init %}
+extern psa_status_t {{manifest.entry_init}}(void);
+{% endif %}
+
+/* partition load info type definition */
+struct partition_{{manifest.name|lower}}_load_info_t {
+ /* common length load data */
+ struct partition_load_info_t load_info;
+ /* per-partition variable length load data */
+ uintptr_t stack_addr;
+ uintptr_t heap_addr;
+{% if counter.dep_counter > 0 %}
+ uint32_t deps[{{(manifest.name|upper + "_NDEPS")}}];
+{% endif %}
+{% if counter.service_counter > 0 %}
+ struct service_load_info_t services[{{(manifest.name|upper + "_NSERVS")}}];
+{% endif %}
+#if TFM_LVL == 3
+ struct asset_desc_t assets[{{(manifest.name|upper + "_NASSETS")}}];
+#else
+{% if counter.asset_counter > 0 %}
+ struct asset_desc_t assets[{{(manifest.name|upper + "_NASSETS")}}];
+{% endif %}
+#endif
+{% if counter.irq_counter > 0 %}
+ struct irq_load_info_t irqs[{{(manifest.name|upper + "_NIRQS")}}];
+{% endif %}
+} __attribute__((aligned(4)));
+
+/* Partition load, deps, service load data. Put to a dedicated section. */
+#if defined(__ICCARM__)
+#pragma location = ".part_load"
+__root
+#endif /* __ICCARM__ */
+const struct partition_{{manifest.name|lower}}_load_info_t {{manifest.name|lower}}_load
+ __attribute__((used, section(".part_load"))) = {
+ .load_info = {
+{% if manifest.psa_framework_version == 1.0 %}
+ .psa_ff_ver = 0x0100 | PARTITION_INFO_MAGIC,
+{% elif manifest.psa_framework_version == 1.1 %}
+ .psa_ff_ver = 0x0101 | PARTITION_INFO_MAGIC,
+{% else %}
+#error "Unsupported ff version '{{manifest.psa_framework_version}}' for partition '{{manifest.name}}'!"
+{% endif %}
+ .pid = {{manifest.name}},
+ .flags = 0
+{% if (manifest.psa_framework_version == 1.1 and manifest.model == "IPC") or manifest.psa_framework_version == 1.0 %}
+ | SPM_PART_FLAG_IPC
+{% endif %}
+{% if manifest.type == "PSA-ROT" %}
+ | SPM_PART_FLAG_PSA_ROT
+{% elif manifest.type != "APPLICATION-ROT" %}
+#error "Unsupported type '{{manifest.type}}' for partition '{{manifest.name}}'!"
+{% endif %}
+ | PARTITION_PRI_{{manifest.priority}},
+{% if manifest.entry_point %}
+ .entry = ENTRY_TO_POSITION({{manifest.entry_point}}),
+{% elif manifest.entry_init %}
+ .entry = ENTRY_TO_POSITION({{manifest.entry_init}}),
+{% else %}
+ .entry = NULL,
+{% endif %}
+ .stack_size = {{manifest.stack_size}},
+ .heap_size = 0,
+ .ndeps = {{(manifest.name|upper + "_NDEPS")}},
+ .nservices = {{(manifest.name|upper + "_NSERVS")}},
+ .nassets = {{(manifest.name|upper + "_NASSETS")}},
+ .nirqs = {{(manifest.name|upper + "_NIRQS")}},
+ },
+ .stack_addr = (uintptr_t){{manifest.name|lower}}_stack,
+ .heap_addr = 0,
+{% if counter.dep_counter > 0 %}
+ .deps = {
+ {% for dep in manifest.dependencies %}
+ {{dep}}_SID,
+ {% endfor %}
+ },
+{% endif %}
+{% if counter.service_counter > 0 %}
+ .services = {
+ {% for service in manifest.services %}
+ {
+ .name_strid = STRING_PTR_TO_STRID("{{service.name}}"),
+{% if manifest.psa_framework_version == 1.1 and manifest.model == "SFN" %}
+ .sfn = ENTRY_TO_POSITION({{service.name|lower}}_sfn),
+{% else %}
+ .signal = {{service.name}}_SIGNAL,
+{% endif %}
+ .sid = {{service.sid}},
+ .flags = 0
+ {% if service.non_secure_clients is sameas true %}
+ | SERVICE_FLAG_NS_ACCESSIBLE
+ {% endif %}
+ {% if manifest.psa_framework_version > 1.0 and service.connection_based is sameas false %}
+ | SERVICE_FLAG_STATELESS | 0x{{"%x"|format(service.stateless_handle_index)}}
+ {% endif %}
+ {% if service.version_policy %}
+ | SERVICE_VERSION_POLICY_{{service.version_policy}},
+ {% else %}
+ | SERVICE_VERSION_POLICY_STRICT,
+ {% endif %}
+ {% if service.version %}
+ .version = {{service.version}},
+ {% else %}
+ .version = 1,
+ {% endif %}
+ },
+ {% endfor %}
+ },
+{% endif %}
+#if TFM_LVL == 3
+ .assets = {
+ {
+ .mem.start = PART_REGION_ADDR(PT_{{manifest.name}}_PRIVATE, _DATA_START$$Base),
+ .mem.limit = PART_REGION_ADDR(PT_{{manifest.name}}_PRIVATE, _DATA_END$$Base),
+ .attr = ASSET_ATTR_READ_WRITE,
+ },
+{% if counter.asset_counter > 0 %}
+ {% for region in manifest.mmio_regions %}
+ {% if region.conditional %}
+#ifdef {{region.conditional}}
+ {% endif %}
+ {% if region.base and region.size %}
+ {
+ .mem.start = {{region.base}},
+ .mem.limit = {{region.base}} + {{region.size}},
+ .attr = ASSET_ATTR_NUMBERED_MMIO
+ {% elif region.name %}
+ {
+ .dev.dev_ref = PTR_TO_REFERENCE({{region.name}}),
+ .attr = ASSET_ATTR_NAMED_MMIO
+ {% endif %}
+ {% if region.permission == "READ-WRITE" %}
+ | ASSET_ATTR_READ_WRITE,
+ {% else %}
+ | ASSET_ATTR_READ_ONLY,
+ {% endif %}
+ },
+ {% if region.conditional %}
+#endif
+ {% endif %}
+ {% endfor %}
+{% endif %}
+ },
+#else
+{% if counter.asset_counter > 0 %}
+ .assets = {
+ {% for region in manifest.mmio_regions %}
+ {% if region.conditional %}
+#ifdef {{region.conditional}}
+ {% endif %}
+ {% if region.base and region.size %}
+ {
+ .mem.start = {{region.base}},
+ .mem.limit = {{region.base}} + {{region.size}},
+ .attr = ASSET_ATTR_NUMBERED_MMIO
+ {% elif region.name %}
+ {
+ .dev.dev_ref = PTR_TO_REFERENCE({{region.name}}),
+ .attr = ASSET_ATTR_NAMED_MMIO
+ {% endif %}
+ {% if region.permission == "READ-WRITE" %}
+ | ASSET_ATTR_READ_WRITE,
+ {% else %}
+ | ASSET_ATTR_READ_ONLY,
+ {% endif %}
+ },
+ {% if region.conditional %}
+#endif
+ {% endif %}
+ {% endfor %}
+ },
+{% endif %}
+#endif
+{% if counter.irq_counter > 0 %}
+ .irqs = {
+ {% for irq in manifest.irqs %}
+ {% set irq_info = namespace() %}
+ {% set irq_info.source = irq.source %}
+ {% if manifest.psa_framework_version == 1.1 and irq.handling == "FLIH" %}
+ {% set irq_info.flih_func = "(uint32_t)" + irq.name|lower + "_flih" %}
+ {% else %}
+ {% set irq_info.flih_func = 0 %}
+ {% endif %}
+ {% if manifest.psa_framework_version == 1.0 %}
+ {% set irq_info.signal = irq.signal %}
+ {% else %}
+ {% set irq_info.signal = irq.name + "_SIGNAL" %}
+ {% endif %}
+ {
+ .source = {{irq_info.source}},
+ .flih_func = {{irq_info.flih_func}},
+ .signal = {{irq_info.signal}},
+ },
+ {% endfor %}
+ },
+{% endif %}
+};
+
+/* Placeholder for partition and service runtime space. Do not reference it. */
+#if defined(__ICCARM__)
+#pragma location=".bss.part_runtime"
+__root
+#endif /* __ICCARM__ */
+static struct partition_t {{manifest.name|lower}}_partition_runtime_item
+ __attribute__((used, section(".bss.part_runtime")));
+{% if counter.service_counter > 0 %}
+#if defined(__ICCARM__)
+#pragma location = ".bss.serv_runtime"
+__root
+#endif /* __ICCARM__ */
+static struct service_t {{manifest.name|lower}}_service_runtime_item[{{(manifest.name|upper + "_NSERVS")}}]
+ __attribute__((used, section(".bss.serv_runtime")));
+{% endif %}
diff --git a/tools/tfm_manifest_list.yaml b/tools/tfm_manifest_list.yaml
index 49f8fef727..cc93b9f75c 100644
--- a/tools/tfm_manifest_list.yaml
+++ b/tools/tfm_manifest_list.yaml
@@ -96,111 +96,6 @@
}
},
{
- "name": "TFM Core Test Service",
- "short_name": "TFM_SP_CORE_TEST",
- "manifest": "${TFM_TEST_PATH}/test_services/tfm_core_test/tfm_ss_core_test.yaml",
- "source_path": "${TFM_TEST_PATH}",
- "conditional": "TFM_PARTITION_TEST_CORE",
- "version_major": 0,
- "version_minor": 1,
- "pid": 262,
- "linker_pattern": {
- "library_list": [
- "*tfm_*partition_core_test.*"
- ]
- }
- },
- {
- "name": "TFM Core Test Service 2",
- "short_name": "TFM_SP_CORE_TEST_2",
- "manifest": "${TFM_TEST_PATH}/test_services/tfm_core_test_2/tfm_ss_core_test_2.yaml",
- "source_path": "${TFM_TEST_PATH}",
- "conditional": "TFM_PARTITION_TEST_CORE",
- "version_major": 0,
- "version_minor": 1,
- "pid": 263,
- "linker_pattern": {
- "library_list": [
- "*tfm_*partition_core_test_2.*"
- ]
- }
- },
- {
- "name": "TFM Secure Client Service",
- "short_name": "TFM_SP_SECURE_TEST_PARTITION",
- "manifest": "${TFM_TEST_PATH}/test_services/tfm_secure_client_service/tfm_secure_client_service.yaml",
- "source_path": "${TFM_TEST_PATH}",
- "conditional": "TFM_PARTITION_TEST_SECURE_SERVICES",
- "version_major": 0,
- "version_minor": 1,
- "pid": 264,
- "linker_pattern": {
- "library_list": [
- "*tfm_*partition_secure_client_service.*"
- ]
- }
- },
- {
- "name": "TFM IPC Service Test",
- "short_name": "TFM_SP_IPC_SERVICE_TEST",
- "manifest": "${TFM_TEST_PATH}/test_services/tfm_ipc_service/tfm_ipc_service_test.yaml",
- "source_path": "${TFM_TEST_PATH}",
- "conditional": "TFM_PARTITION_TEST_CORE_IPC",
- "version_major": 0,
- "version_minor": 1,
- "pid": 265,
- "linker_pattern": {
- "library_list": [
- "*tfm_*partition_ipc_service.*"
- ]
- }
- },
- {
- "name": "TFM IPC Client Service",
- "short_name": "TFM_SP_IPC_CLIENT_TEST",
- "manifest": "${TFM_TEST_PATH}/test_services/tfm_ipc_client/tfm_ipc_client_test.yaml",
- "source_path": "${TFM_TEST_PATH}",
- "conditional": "TFM_PARTITION_TEST_CORE_IPC",
- "version_major": 0,
- "version_minor": 1,
- "pid": 266,
- "linker_pattern": {
- "library_list": [
- "*tfm_*partition_ipc_client.*"
- ]
- }
- },
- {
- "name": "TF-M PS Test Service",
- "short_name": "TFM_SP_PS_TEST",
- "manifest": "${TFM_TEST_PATH}/test_services/tfm_ps_test_service/tfm_ps_test_service.yaml",
- "source_path": "${TFM_TEST_PATH}",
- "conditional": "TFM_PARTITION_TEST_PS",
- "version_major": 0,
- "version_minor": 1,
- "pid": 268,
- "linker_pattern": {
- "library_list": [
- "*tfm_*partition_ps_test.*"
- ]
- }
- },
- {
- "name": "TF-M Secure Client 2 Service",
- "short_name": "TFM_SP_SECURE_CLIENT_2",
- "manifest": "${TFM_TEST_PATH}/test_services/tfm_secure_client_2/tfm_secure_client_2.yaml",
- "source_path": "${TFM_TEST_PATH}",
- "conditional": "TFM_PARTITION_TEST_SECURE_SERVICES",
- "version_major": 0,
- "version_minor": 1,
- "pid": 269,
- "linker_pattern": {
- "library_list": [
- "*tfm_*partition_secure_client_2.*"
- ]
- }
- },
- {
"name": "TFM Firmware Update Service",
"short_name": "TFM_SP_FWU",
"manifest": "secure_fw/partitions/firmware_update/tfm_firmware_update.yaml",
@@ -214,62 +109,5 @@
]
}
},
- {
- "name": "TFM FFM11 Partition Service",
- "short_name": "TFM_SP_FFM11",
- "manifest": "secure_fw/partitions/tfm_ffm11_partition/tfm_ffm11_partition.yaml",
- "conditional": "TFM_PARTITION_FFM11",
- "version_major": 0,
- "version_minor": 1,
- "pid": 272,
- "linker_pattern": {
- "library_list": [
- "*tfm_*partition_ffm11.*"
- ]
- }
- },
- {
- "name": "TFM Initial Attestation Test Service",
- "short_name": "TFM_ATTEST_TEST_SERVICE",
- "manifest": "${TFM_TEST_PATH}/test_services/tfm_attest_test_service/tfm_attest_test_service.yaml",
- "source_path": "${TFM_TEST_PATH}",
- "conditional": "ATTEST_TEST_GET_PUBLIC_KEY",
- "version_major": 0,
- "version_minor": 1,
- "pid": 273,
- "linker_pattern": {
- "library_list": [
- "*tfm_*partition_attest_test_service.*"
- ]
- }
- },
- {
- "name": "TFM SLIH Test Service",
- "short_name": "TFM_SP_SLIH_TEST",
- "manifest": "${TFM_TEST_PATH}/test_services/tfm_slih_test_service/tfm_slih_test_service.yaml",
- "source_path": "${TFM_TEST_PATH}",
- "conditional": "TFM_ENABLE_SLIH_TEST",
- "version_major": 0,
- "version_minor": 1,
- "linker_pattern": {
- "library_list": [
- "*tfm_*partition_slih_test.*"
- ]
- }
- },
- {
- "name": "TFM FLIH Test Service",
- "short_name": "TFM_SP_FLIH_TEST",
- "manifest": "${TFM_TEST_PATH}/test_services/tfm_flih_test_service/tfm_flih_test_service.yaml",
- "source_path": "${TFM_TEST_PATH}",
- "conditional": "TFM_ENABLE_FLIH_TEST",
- "version_major": 0,
- "version_minor": 1,
- "linker_pattern": {
- "library_list": [
- "*tfm_*partition_flih_test.*"
- ]
- }
- }
]
}
diff --git a/tools/tfm_parse_manifest_list.py b/tools/tfm_parse_manifest_list.py
index 53faa281ba..9b7a36a1a1 100644
--- a/tools/tfm_parse_manifest_list.py
+++ b/tools/tfm_parse_manifest_list.py
@@ -25,6 +25,14 @@ donotedit_warning = \
OUT_DIR = None # The root directory that files are generated to
+# variable for checking for duplicated sid
+sid_list = []
+partition_list_sid = []
+service_list = []
+sid_duplicated_partition = []
+sid_duplicated_sid = []
+sid_duplicated_service = []
+
class TemplateLoader(BaseLoader):
"""
Template loader class.
@@ -66,9 +74,23 @@ def manifest_validation(partition_manifest):
if 'version_policy' not in service.keys():
service['version_policy'] = "STRICT"
+ for k in range (len(sid_list)):
+ sid_item = sid_list[k]
+ if ((service['sid'] == sid_item) & (service['name'] != service_list[k])):
+ sid_duplicated_partition.append(partition_list_sid[k])
+ sid_duplicated_partition.append(partition_manifest['name'])
+ sid_duplicated_sid.append(sid_item)
+ sid_duplicated_sid.append(service['sid'])
+ sid_duplicated_service.append(service_list[k])
+ sid_duplicated_service.append(service['name'])
+
+ sid_list.append(service['sid'])
+ partition_list_sid.append(partition_manifest['name'])
+ service_list.append(service['name'])
+
return partition_manifest
-def process_partition_manifests(manifest_list_files):
+def process_partition_manifests(manifest_list_files, extra_manifests_list):
"""
Parse the input manifest, generate the data base for genereated files
and generate manifest header files.
@@ -77,6 +99,8 @@ def process_partition_manifests(manifest_list_files):
----------
manifest_list_files:
The manifest lists to parse.
+ extra_manifests_list:
+ The extra manifest list to parse and its original path.
Returns
-------
@@ -92,6 +116,24 @@ def process_partition_manifests(manifest_list_files):
manifest_list.extend(manifest_dic["manifest_list"])
manifest_list_yaml_file.close()
+ # Out-of-tree secure partition build
+ if extra_manifests_list is not None:
+ for i, item in enumerate(extra_manifests_list):
+ # Skip if current item is the original manifest path
+ if os.path.isdir(item):
+ continue
+
+ # The manifest list file generated by configure_file()
+ with open(item) as manifest_list_yaml_file:
+ manifest_dic = yaml.safe_load(manifest_list_yaml_file)
+ extra_manifest_dic = manifest_dic["manifest_list"]
+ for dict in extra_manifest_dic:
+ # Append original directory of out-of-tree partition's
+ # manifest list source code
+ dict['extra_path'] = extra_manifests_list[i + 1]
+ manifest_list.append(dict)
+ manifest_list_yaml_file.close()
+
pid_list = []
no_pid_manifest_idx = []
for i, manifest_item in enumerate(manifest_list):
@@ -114,27 +156,44 @@ def process_partition_manifests(manifest_list_files):
for manifest_item in manifest_list:
# Replace environment variables in the manifest path
manifest_path = os.path.expandvars(manifest_item['manifest'])
+
+ # Handle out-of-tree secure partition manifest file path
+ if 'extra_path' in manifest_item:
+ if not os.path.isabs(manifest_path):
+ # manifest file path provided by manifest list is relative to
+ # manifest list path
+ manifest_path = os.path.join(manifest_item['extra_path'], manifest_path).replace('\\', '/')
+
file = open(manifest_path)
manifest = manifest_validation(yaml.safe_load(file))
file.close()
manifest_dir, manifest_name = os.path.split(manifest_path)
manifest_out_basename = manifest_name.replace('.yaml', '').replace('.json', '')
- manifest_head_file = os.path.join(manifest_dir, "psa_manifest", manifest_out_basename + '.h').replace('\\', '/')
- intermedia_file = os.path.join(manifest_dir, "auto_generated", 'intermedia_' + manifest_out_basename + '.c').replace('\\', '/')
- load_info_file = os.path.join(manifest_dir, "auto_generated", 'load_info_' + manifest_out_basename + '.c').replace('\\', '/')
if OUT_DIR is not None:
- """
- Remove the `source_path` portion of the filepaths, so that it can be
- interpreted as a relative path from the OUT_DIR.
- """
- if 'source_path' in manifest_item:
- # Replace environment variables in the source path
- source_path = os.path.expandvars(manifest_item['source_path'])
- manifest_head_file = os.path.relpath(manifest_head_file, start = source_path)
- intermedia_file = os.path.relpath(intermedia_file, start = source_path)
- load_info_file = os.path.relpath(load_info_file, start = source_path)
+ if 'output_path' in manifest_item:
+ # Build up generated files directory accroding to the relative
+ # path specified in output_path by the partition
+ output_path = os.path.expandvars(manifest_item['output_path'])
+ manifest_head_file = os.path.join(output_path, "psa_manifest", manifest_out_basename + '.h')
+ intermedia_file = os.path.join(output_path, "auto_generated", 'intermedia_' + manifest_out_basename + '.c')
+ load_info_file = os.path.join(output_path, "auto_generated", 'load_info_' + manifest_out_basename + '.c')
+ else:
+ manifest_head_file = os.path.join(manifest_dir, "psa_manifest", manifest_out_basename + '.h')
+ intermedia_file = os.path.join(manifest_dir, "auto_generated", 'intermedia_' + manifest_out_basename + '.c')
+ load_info_file = os.path.join(manifest_dir, "auto_generated", 'load_info_' + manifest_out_basename + '.c')
+
+ """
+ Remove the `source_path` portion of the filepaths, so that it can be
+ interpreted as a relative path from the OUT_DIR.
+ """
+ if 'source_path' in manifest_item:
+ # Replace environment variables in the source path
+ source_path = os.path.expandvars(manifest_item['source_path'])
+ manifest_head_file = os.path.relpath(manifest_head_file, start = source_path)
+ intermedia_file = os.path.relpath(intermedia_file, start = source_path)
+ load_info_file = os.path.relpath(load_info_file, start = source_path)
manifest_head_file = os.path.join(OUT_DIR, manifest_head_file).replace('\\', '/')
intermedia_file = os.path.join(OUT_DIR, intermedia_file).replace('\\', '/')
@@ -146,6 +205,18 @@ def process_partition_manifests(manifest_list_files):
"intermedia_file": intermedia_file,
"loadinfo_file": load_info_file})
+ if len(sid_duplicated_sid) != 0:
+ print("The following signals have duplicated sids."
+ "A Service requires a unique sid")
+ for i in range(len(sid_duplicated_sid)):
+ print("Partition: {parti} , Service: {servi} , SID: {sidn}".format(
+ parti = sid_duplicated_partition[i],
+ servi = sid_duplicated_service[i],
+ sidn = sid_duplicated_sid[i])
+ )
+
+ raise Exception("Duplicated SID found, check above for details")
+
return partition_list
def gen_per_partition_files(context):
@@ -164,9 +235,9 @@ def gen_per_partition_files(context):
subcontext = {}
subcontext['utilities'] = subutilities
- manifesttemplate = ENV.get_template('secure_fw/partitions/manifestfilename.template')
- memorytemplate = ENV.get_template('secure_fw/partitions/partition_intermedia.template')
- infotemplate = ENV.get_template('secure_fw/partitions/partition_load_info.template')
+ manifesttemplate = ENV.get_template(os.path.join(os.path.relpath(os.path.dirname(__file__)), 'templates/manifestfilename.template'))
+ memorytemplate = ENV.get_template(os.path.join(os.path.relpath(os.path.dirname(__file__)), 'templates/partition_intermedia.template'))
+ infotemplate = ENV.get_template(os.path.join(os.path.relpath(os.path.dirname(__file__)), 'templates/partition_load_info.template'))
print ("Start to generate partition files:")
@@ -355,6 +426,14 @@ def parse_args():
, metavar='file-list'
, help='These files descripe the file list to generate')
+ parser.add_argument('-e', '--extra-manifest'
+ , nargs='*'
+ , dest='extra_manifests_args'
+ , required=False
+ , default=None
+ , metavar='out-of-tree-manifest-list'
+ , help='Optional. Manifest lists and original paths for out-of-tree secure partitions.')
+
args = parser.parse_args()
manifest_args = args.manifest_args
gen_file_args = args.gen_file_args
@@ -382,11 +461,17 @@ def main():
manifest_args = args.manifest_args
gen_file_args = args.gen_file_args
+ extra_manifests_args = args.extra_manifests_args
OUT_DIR = args.outdir
manifest_list = [os.path.abspath(x) for x in args.manifest_args]
gen_file_list = [os.path.abspath(x) for x in args.gen_file_args]
+ if extra_manifests_args is not None:
+ extra_manifests_list = [os.path.abspath(x) for x in extra_manifests_args]
+ else:
+ extra_manifests_list = None
+
"""
Relative path to TF-M root folder is supported in the manifests
and default value of manifest list and generated file list are relative to TF-M root folder as well,
@@ -396,7 +481,7 @@ def main():
"""
os.chdir(os.path.join(sys.path[0], ".."))
- partition_list = process_partition_manifests(manifest_list)
+ partition_list = process_partition_manifests(manifest_list, extra_manifests_list)
utilities = {}
utilities['donotedit_warning'] = donotedit_warning