blob: 7557d575547c93ca84fe28cc7c01f6a6df917bea [file] [log] [blame]
Mingyang Suneab7eae2021-09-30 13:06:52 +08001/*
2 * Copyright (c) 2021, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8{{utilities.donotedit_warning}}
9
10#ifndef __CONFIG_IMPL_H__
11#define __CONFIG_IMPL_H__
12
13{% if ipc_partition_num > 0 and sfn_partition_num == 0 %}
Mingyang Sunc2521f72021-08-13 15:03:05 +080014/* IPC model */
Ken Liu82e3eac2021-10-14 16:19:13 +080015#define {{"%-56s"|format("CONFIG_TFM_SPM_BACKEND_IPC")}} 1
Ken Liue07c3b72021-10-14 16:19:13 +080016
Mingyang Sunc2521f72021-08-13 15:03:05 +080017/* Trustzone NS agent working stack size. */
18#define {{"%-56s"|format("CONFIG_TFM_NS_AGENT_TZ_STACK_SIZE")}} 1024
19
Ken Liue07c3b72021-10-14 16:19:13 +080020#if TFM_LVL > 1
Ken Liu82e3eac2021-10-14 16:19:13 +080021#define {{"%-56s"|format("CONFIG_TFM_PSA_API_SUPERVISOR_CALL")}} 1
Mingyang Sunc2521f72021-08-13 15:03:05 +080022#else /* TFM_LVL > 1 */
Ken Liue07c3b72021-10-14 16:19:13 +080023#define {{"%-56s"|format("CONFIG_TFM_PSA_API_THREAD_CALL")}} 1
Mingyang Sunc2521f72021-08-13 15:03:05 +080024
25/* SPM re-uses Trustzone NS agent stack. */
26#define {{"%-56s"|format("CONFIG_TFM_SPM_THREAD_STACK_SIZE")}} \
27 {{"%-56s"|format("CONFIG_TFM_NS_AGENT_TZ_STACK_SIZE")}}
28#endif /* TFM_LVL > 1 */
Ken Liu82e3eac2021-10-14 16:19:13 +080029
Mingyang Suneab7eae2021-09-30 13:06:52 +080030{% elif sfn_partition_num > 0 and ipc_partition_num == 0 %}
Mingyang Sunc2521f72021-08-13 15:03:05 +080031/* SFN model */
Ken Liue07c3b72021-10-14 16:19:13 +080032#define {{"%-56s"|format("CONFIG_TFM_SPM_BACKEND_SFN")}} 1
Mingyang Sunc2521f72021-08-13 15:03:05 +080033#define {{"%-56s"|format("CONFIG_TFM_PSA_API_SFN_CALL")}} 1
Mingyang Suneab7eae2021-09-30 13:06:52 +080034
35#if TFM_LVL > 1
36#error "High isolation level SFN model is not supported."
37#endif
38
Mingyang Sunc9a96c02021-10-14 10:32:05 +080039 {% set total_stk = namespace(size=0) %}
40 {% for partition in partitions %}
41 {% if "0x" in partition.manifest.stack_size or "0X" in partition.manifest.stack_size %}
42 {% set total_stk.size = total_stk.size + partition.manifest.stack_size|int(base=16) %}
43 {% else %}
44 {% set total_stk.size = total_stk.size + partition.manifest.stack_size|int(base=10) %}
45 {% endif %}
46 {% endfor %}
Mingyang Sunc2521f72021-08-13 15:03:05 +080047/*
48 * In isolation level 1 SFN model, all subsequent components work on NS agent
49 * stack. It is observed that half of the sum of all partition stack sizes is
50 * enough for working. Define a divisor factor
51 * CONFIG_TFM_NS_AGENT_TZ_STK_SIZE_SHIFT_FACTOR for reference, and allow
52 * modification of the factor based on application situation. The stack size
53 * value is aligned to 8 bytes.
Ken Liuf39d8eb2021-10-07 12:55:33 +080054 * The minimum value is 0x400 to satisfy the SPM functional requirement.
55 * Manifest tool will assure this.
Mingyang Sunc2521f72021-08-13 15:03:05 +080056 */
Ken Liuf39d8eb2021-10-07 12:55:33 +080057 {% if total_stk.size|int < 2048 %}
58 {% set total_stk.size = 2048 %}
59 {% endif %}
Mingyang Sunc2521f72021-08-13 15:03:05 +080060#define CONFIG_TFM_NS_AGENT_TZ_STK_SIZE_SHIFT_FACTOR 1
Ken Liuf39d8eb2021-10-07 12:55:33 +080061#define {{"%-56s"|format("CONFIG_TFM_NS_AGENT_TZ_STACK_SIZE")}} \
Mingyang Sunc2521f72021-08-13 15:03:05 +080062 ((({{"0x%x"|format(total_stk.size)}} >> CONFIG_TFM_NS_AGENT_TZ_STK_SIZE_SHIFT_FACTOR) + 0x7) & (~0x7))
Mingyang Sunc9a96c02021-10-14 10:32:05 +080063
Mingyang Suneab7eae2021-09-30 13:06:52 +080064{% elif sfn_partition_num > 0 and ipc_partition_num > 0 %}
65#error "IPC and SFN co-work not supported yet."
66{% else %}
Ken Liu82e3eac2021-10-14 16:19:13 +080067#error "Invalid partition number input, check configurations."
Mingyang Suneab7eae2021-09-30 13:06:52 +080068{% endif %}
Ken Liu82e3eac2021-10-14 16:19:13 +080069#include "psa_interface_redirect.h"
Mingyang Suneab7eae2021-09-30 13:06:52 +080070
71#endif /* __CONFIG_IMPL_H__ */