blob: 4a172e3e64e8d41a2cb405c79531e436ccc72381 [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 Zhangcf8478f2022-10-27 15:54:58 +080012#include "config_tfm.h"
13
Kevin Peng9f1a7542022-02-07 16:32:27 +080014/* 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/* API calls */
19#define {{"%-56s"|format("CONFIG_TFM_PSA_API_SFN_CALL")}} {{config_impl['CONFIG_TFM_PSA_API_SFN_CALL']}}
20#define {{"%-56s"|format("CONFIG_TFM_PSA_API_CROSS_CALL")}} {{config_impl['CONFIG_TFM_PSA_API_CROSS_CALL']}}
21#define {{"%-56s"|format("CONFIG_TFM_PSA_API_SUPERVISOR_CALL")}} {{config_impl['CONFIG_TFM_PSA_API_SUPERVISOR_CALL']}}
22
23#define {{"%-56s"|format("CONFIG_TFM_CONNECTION_BASED_SERVICE_API")}} {{config_impl['CONFIG_TFM_CONNECTION_BASED_SERVICE_API']}}
Sherry Zhang2ed48fd2022-09-06 11:33:22 +080024#define {{"%-56s"|format("CONFIG_TFM_MMIO_REGION_ENABLE")}} {{config_impl['CONFIG_TFM_MMIO_REGION_ENABLE']}}
Mingyang Suned5fe7b2022-02-10 17:33:21 +080025#define {{"%-56s"|format("CONFIG_TFM_FLIH_API")}} {{config_impl['CONFIG_TFM_FLIH_API']}}
26#define {{"%-56s"|format("CONFIG_TFM_SLIH_API")}} {{config_impl['CONFIG_TFM_SLIH_API']}}
Kevin Peng9f1a7542022-02-07 16:32:27 +080027
28#if CONFIG_TFM_SPM_BACKEND_IPC == 1
Mingyang Sunc2521f72021-08-13 15:03:05 +080029/* Trustzone NS agent working stack size. */
Xinyu Zhang6ad07032022-08-10 14:45:56 +080030#if defined(TFM_FIH_PROFILE_ON) && TFM_LVL == 1
31#define {{"%-56s"|format("CONFIG_TFM_NS_AGENT_TZ_STACK_SIZE")}} 1256
32#else
Mingyang Sunc2521f72021-08-13 15:03:05 +080033#define {{"%-56s"|format("CONFIG_TFM_NS_AGENT_TZ_STACK_SIZE")}} 1024
Xinyu Zhang6ad07032022-08-10 14:45:56 +080034#endif
Mingyang Sunc2521f72021-08-13 15:03:05 +080035
Mingyang Sunc2521f72021-08-13 15:03:05 +080036/* SPM re-uses Trustzone NS agent stack. */
37#define {{"%-56s"|format("CONFIG_TFM_SPM_THREAD_STACK_SIZE")}} \
38 {{"%-56s"|format("CONFIG_TFM_NS_AGENT_TZ_STACK_SIZE")}}
Ken Liu82e3eac2021-10-14 16:19:13 +080039
Kevin Peng9f1a7542022-02-07 16:32:27 +080040#elif CONFIG_TFM_SPM_BACKEND_SFN == 1
Xinyu Zhangcf8478f2022-10-27 15:54:58 +080041 {% set total_stk = namespace(size="0") %}
Mingyang Sunc9a96c02021-10-14 10:32:05 +080042 {% for partition in partitions %}
Xinyu Zhangcf8478f2022-10-27 15:54:58 +080043 {% set total_stk.size = total_stk.size + " + " + partition.manifest.stack_size %}
Mingyang Sunc9a96c02021-10-14 10:32:05 +080044 {% endfor %}
Mingyang Sunc2521f72021-08-13 15:03:05 +080045/*
46 * In isolation level 1 SFN model, all subsequent components work on NS agent
47 * stack. It is observed that half of the sum of all partition stack sizes is
48 * enough for working. Define a divisor factor
49 * CONFIG_TFM_NS_AGENT_TZ_STK_SIZE_SHIFT_FACTOR for reference, and allow
50 * modification of the factor based on application situation. The stack size
51 * value is aligned to 8 bytes.
Ken Liuf39d8eb2021-10-07 12:55:33 +080052 * The minimum value is 0x400 to satisfy the SPM functional requirement.
53 * Manifest tool will assure this.
Mingyang Sunc2521f72021-08-13 15:03:05 +080054 */
Xinyu Zhangcf8478f2022-10-27 15:54:58 +080055#define {{"%-56s"|format("CONFIG_TFM_TOTAL_STACK_SIZE")}} ({{total_stk.size}})
56#if (CONFIG_TFM_TOTAL_STACK_SIZE < 2048)
57#undef {{"%-56s"|format("CONFIG_TFM_TOTAL_STACK_SIZE")}}
58#define {{"%-56s"|format("CONFIG_TFM_TOTAL_STACK_SIZE")}} 2048
59#endif
60
Mingyang Sunc2521f72021-08-13 15:03:05 +080061#define CONFIG_TFM_NS_AGENT_TZ_STK_SIZE_SHIFT_FACTOR 1
Ken Liuf39d8eb2021-10-07 12:55:33 +080062#define {{"%-56s"|format("CONFIG_TFM_NS_AGENT_TZ_STACK_SIZE")}} \
Xinyu Zhangcf8478f2022-10-27 15:54:58 +080063 (((CONFIG_TFM_TOTAL_STACK_SIZE >> CONFIG_TFM_NS_AGENT_TZ_STK_SIZE_SHIFT_FACTOR) + 0x7) & (~0x7))
Mingyang Sunc9a96c02021-10-14 10:32:05 +080064
Kevin Peng9f1a7542022-02-07 16:32:27 +080065#endif /* CONFIG_TFM_SPM_BACKEND_IPC == 1 */
Feder Liangb7140792021-11-25 16:07:16 +080066
Mingyang Suneab7eae2021-09-30 13:06:52 +080067#endif /* __CONFIG_IMPL_H__ */