blob: 8c79f046a5d8f223cee14ee7ee8123e115e4480a [file] [log] [blame]
/*
* Copyright (c) 2021-2022, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
{{utilities.donotedit_warning}}
#ifndef __CONFIG_IMPL_H__
#define __CONFIG_IMPL_H__
{% if partition_statistics['ipc_partition_num'] > 0
and partition_statistics['sfn_partition_num'] == 0 %}
/* IPC model */
#define {{"%-56s"|format("CONFIG_TFM_SPM_BACKEND_IPC")}} 1
/* Trustzone NS agent working stack size. */
#define {{"%-56s"|format("CONFIG_TFM_NS_AGENT_TZ_STACK_SIZE")}} 1024
#if TFM_LVL > 1
#define {{"%-56s"|format("CONFIG_TFM_PSA_API_SUPERVISOR_CALL")}} 1
#else /* TFM_LVL > 1 */
#define {{"%-56s"|format("CONFIG_TFM_PSA_API_CROSS_CALL")}} 1
/* SPM re-uses Trustzone NS agent stack. */
#define {{"%-56s"|format("CONFIG_TFM_SPM_THREAD_STACK_SIZE")}} \
{{"%-56s"|format("CONFIG_TFM_NS_AGENT_TZ_STACK_SIZE")}}
#endif /* TFM_LVL > 1 */
{% elif partition_statistics['sfn_partition_num'] > 0
and partition_statistics['ipc_partition_num'] == 0 %}
/* SFN model */
#define {{"%-56s"|format("CONFIG_TFM_SPM_BACKEND_SFN")}} 1
#define {{"%-56s"|format("CONFIG_TFM_PSA_API_SFN_CALL")}} 1
#if TFM_LVL > 1
#error "High isolation level SFN model is not supported."
#endif
{% set total_stk = namespace(size=0) %}
{% for partition in partitions %}
{% if "0x" in partition.manifest.stack_size or "0X" in partition.manifest.stack_size %}
{% set total_stk.size = total_stk.size + partition.manifest.stack_size|int(base=16) %}
{% else %}
{% set total_stk.size = total_stk.size + partition.manifest.stack_size|int(base=10) %}
{% endif %}
{% endfor %}
/*
* In isolation level 1 SFN model, all subsequent components work on NS agent
* stack. It is observed that half of the sum of all partition stack sizes is
* enough for working. Define a divisor factor
* CONFIG_TFM_NS_AGENT_TZ_STK_SIZE_SHIFT_FACTOR for reference, and allow
* modification of the factor based on application situation. The stack size
* value is aligned to 8 bytes.
* The minimum value is 0x400 to satisfy the SPM functional requirement.
* Manifest tool will assure this.
*/
{% if total_stk.size|int < 2048 %}
{% set total_stk.size = 2048 %}
{% endif %}
#define CONFIG_TFM_NS_AGENT_TZ_STK_SIZE_SHIFT_FACTOR 1
#define {{"%-56s"|format("CONFIG_TFM_NS_AGENT_TZ_STACK_SIZE")}} \
((({{"0x%x"|format(total_stk.size)}} >> CONFIG_TFM_NS_AGENT_TZ_STK_SIZE_SHIFT_FACTOR) + 0x7) & (~0x7))
{% elif partition_statistics['sfn_partition_num'] > 0
and partition_statistics['ipc_partition_num'] > 0 %}
#error "IPC and SFN co-work not supported yet."
{% else %}
#error "Invalid partition number input, check configurations."
{% endif %}
#if (CONFIG_TFM_SPE_FP > 0) && (CONFIG_TFM_SPM_BACKEND_SFN == 1)
#error "FP is not supported for SFN model."
#endif
#endif /* __CONFIG_IMPL_H__ */