1/*
2 * Copyright (c) 2021-2022, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7/***********{{utilities.donotedit_warning}}***********/
8
9#ifndef __CONFIG_IMPL_H__
10#define __CONFIG_IMPL_H__
11
12#include "config_tfm.h"
13
14/* Backends */
15#define {{"%-56s"|format("CONFIG_TFM_SPM_BACKEND_IPC")}} {{config_impl['CONFIG_TFM_SPM_BACKEND_IPC']}}
16#define {{"%-56s"|format("CONFIG_TFM_SPM_BACKEND_SFN")}} {{config_impl['CONFIG_TFM_SPM_BACKEND_SFN']}}
17
18#define {{"%-56s"|format("CONFIG_TFM_CONNECTION_BASED_SERVICE_API")}} {{config_impl['CONFIG_TFM_CONNECTION_BASED_SERVICE_API']}}
19#define {{"%-56s"|format("CONFIG_TFM_MMIO_REGION_ENABLE")}} {{config_impl['CONFIG_TFM_MMIO_REGION_ENABLE']}}
20#define {{"%-56s"|format("CONFIG_TFM_FLIH_API")}} {{config_impl['CONFIG_TFM_FLIH_API']}}
21#define {{"%-56s"|format("CONFIG_TFM_SLIH_API")}} {{config_impl['CONFIG_TFM_SLIH_API']}}
22
23#if CONFIG_TFM_SPM_BACKEND_IPC == 1
24/* Trustzone NS agent working stack size. */
25#if defined(TFM_FIH_PROFILE_ON) && TFM_ISOLATION_LEVEL == 1
26#define {{"%-56s"|format("CONFIG_TFM_NS_AGENT_TZ_STACK_SIZE")}} 1256
27#else
28#define {{"%-56s"|format("CONFIG_TFM_NS_AGENT_TZ_STACK_SIZE")}} 1024
29#endif
30
31/* SPM re-uses Trustzone NS agent stack. */
32#define {{"%-56s"|format("CONFIG_TFM_SPM_THREAD_STACK_SIZE")}}     \
33            {{"%-56s"|format("CONFIG_TFM_NS_AGENT_TZ_STACK_SIZE")}}
34
35#elif CONFIG_TFM_SPM_BACKEND_SFN == 1
36    {% set total_stk = namespace(size="0") %}
37    {% for partition in partitions %}
38        {% set total_stk.size = total_stk.size + " + " + partition.manifest.stack_size %}
39    {% endfor %}
40/*
41 * In isolation level 1 SFN model, all subsequent components work on NS agent
42 * stack. It is observed that half of the sum of all partition stack sizes is
43 * enough for working. Define a divisor factor
44 * CONFIG_TFM_NS_AGENT_TZ_STK_SIZE_SHIFT_FACTOR for reference, and allow
45 * modification of the factor based on application situation. The stack size
46 * value is aligned to 8 bytes.
47 * The minimum value is 0x400 to satisfy the SPM functional requirement.
48 * Manifest tool will assure this.
49 */
50#define {{"%-56s"|format("CONFIG_TFM_TOTAL_STACK_SIZE")}} ({{total_stk.size}})
51#if (CONFIG_TFM_TOTAL_STACK_SIZE < 2048)
52#undef {{"%-56s"|format("CONFIG_TFM_TOTAL_STACK_SIZE")}}
53#define {{"%-56s"|format("CONFIG_TFM_TOTAL_STACK_SIZE")}} 2048
54#endif
55
56#define CONFIG_TFM_NS_AGENT_TZ_STK_SIZE_SHIFT_FACTOR             1
57#define {{"%-56s"|format("CONFIG_TFM_NS_AGENT_TZ_STACK_SIZE")}}  \
58    (((CONFIG_TFM_TOTAL_STACK_SIZE >> CONFIG_TFM_NS_AGENT_TZ_STK_SIZE_SHIFT_FACTOR) + 0x7) & (~0x7))
59
60#endif /* CONFIG_TFM_SPM_BACKEND_IPC == 1 */
61
62#endif /* __CONFIG_IMPL_H__ */
63