blob: bc29ac0490be257c191a372adefd57cd2b522794 [file] [log] [blame]
Mingyang Suneab7eae2021-09-30 13:06:52 +08001/*
Xinyu Zhang90f08dc2022-01-12 15:55:17 +08002 * Copyright (c) 2021-2022, Arm Limited. All rights reserved.
Mingyang Suneab7eae2021-09-30 13:06:52 +08003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
Sherry Zhangf58f2bd2022-01-10 17:21:11 +08007/***********{{utilities.donotedit_warning}}***********/
Mingyang Suneab7eae2021-09-30 13:06:52 +08008
9#ifndef __CONFIG_IMPL_H__
10#define __CONFIG_IMPL_H__
11
Xinyu Zhang90f08dc2022-01-12 15:55:17 +080012{% if partition_statistics['ipc_partition_num'] > 0
13 and partition_statistics['sfn_partition_num'] == 0 %}
Mingyang Sunc2521f72021-08-13 15:03:05 +080014/* IPC model */
Mingyang Sunc2521f72021-08-13 15:03:05 +080015/* Trustzone NS agent working stack size. */
16#define {{"%-56s"|format("CONFIG_TFM_NS_AGENT_TZ_STACK_SIZE")}} 1024
17
Mingyang Sunc2521f72021-08-13 15:03:05 +080018/* SPM re-uses Trustzone NS agent stack. */
19#define {{"%-56s"|format("CONFIG_TFM_SPM_THREAD_STACK_SIZE")}} \
20 {{"%-56s"|format("CONFIG_TFM_NS_AGENT_TZ_STACK_SIZE")}}
Ken Liu82e3eac2021-10-14 16:19:13 +080021
Xinyu Zhang90f08dc2022-01-12 15:55:17 +080022{% elif partition_statistics['sfn_partition_num'] > 0
23 and partition_statistics['ipc_partition_num'] == 0 %}
Mingyang Sunc2521f72021-08-13 15:03:05 +080024/* SFN model */
Mingyang Suneab7eae2021-09-30 13:06:52 +080025
Mingyang Sunc9a96c02021-10-14 10:32:05 +080026 {% set total_stk = namespace(size=0) %}
27 {% for partition in partitions %}
28 {% if "0x" in partition.manifest.stack_size or "0X" in partition.manifest.stack_size %}
29 {% set total_stk.size = total_stk.size + partition.manifest.stack_size|int(base=16) %}
30 {% else %}
31 {% set total_stk.size = total_stk.size + partition.manifest.stack_size|int(base=10) %}
32 {% endif %}
33 {% endfor %}
Mingyang Sunc2521f72021-08-13 15:03:05 +080034/*
35 * In isolation level 1 SFN model, all subsequent components work on NS agent
36 * stack. It is observed that half of the sum of all partition stack sizes is
37 * enough for working. Define a divisor factor
38 * CONFIG_TFM_NS_AGENT_TZ_STK_SIZE_SHIFT_FACTOR for reference, and allow
39 * modification of the factor based on application situation. The stack size
40 * value is aligned to 8 bytes.
Ken Liuf39d8eb2021-10-07 12:55:33 +080041 * The minimum value is 0x400 to satisfy the SPM functional requirement.
42 * Manifest tool will assure this.
Mingyang Sunc2521f72021-08-13 15:03:05 +080043 */
Ken Liuf39d8eb2021-10-07 12:55:33 +080044 {% if total_stk.size|int < 2048 %}
45 {% set total_stk.size = 2048 %}
46 {% endif %}
Mingyang Sunc2521f72021-08-13 15:03:05 +080047#define CONFIG_TFM_NS_AGENT_TZ_STK_SIZE_SHIFT_FACTOR 1
Ken Liuf39d8eb2021-10-07 12:55:33 +080048#define {{"%-56s"|format("CONFIG_TFM_NS_AGENT_TZ_STACK_SIZE")}} \
Mingyang Sunc2521f72021-08-13 15:03:05 +080049 ((({{"0x%x"|format(total_stk.size)}} >> CONFIG_TFM_NS_AGENT_TZ_STK_SIZE_SHIFT_FACTOR) + 0x7) & (~0x7))
Mingyang Sunc9a96c02021-10-14 10:32:05 +080050
Xinyu Zhang90f08dc2022-01-12 15:55:17 +080051{% elif partition_statistics['sfn_partition_num'] > 0
52 and partition_statistics['ipc_partition_num'] > 0 %}
Mingyang Suneab7eae2021-09-30 13:06:52 +080053#error "IPC and SFN co-work not supported yet."
54{% else %}
Ken Liu82e3eac2021-10-14 16:19:13 +080055#error "Invalid partition number input, check configurations."
Mingyang Suneab7eae2021-09-30 13:06:52 +080056{% endif %}
Feder Liangb7140792021-11-25 16:07:16 +080057
Mingyang Suneab7eae2021-09-30 13:06:52 +080058#endif /* __CONFIG_IMPL_H__ */