Mingyang Sun | eab7eae | 2021-09-30 13:06:52 +0800 | [diff] [blame] | 1 | /* |
Xinyu Zhang | 90f08dc | 2022-01-12 15:55:17 +0800 | [diff] [blame] | 2 | * Copyright (c) 2021-2022, Arm Limited. All rights reserved. |
Mingyang Sun | eab7eae | 2021-09-30 13:06:52 +0800 | [diff] [blame] | 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 | |
Xinyu Zhang | 90f08dc | 2022-01-12 15:55:17 +0800 | [diff] [blame] | 13 | {% if partition_statistics['ipc_partition_num'] > 0 |
| 14 | and partition_statistics['sfn_partition_num'] == 0 %} |
Mingyang Sun | c2521f7 | 2021-08-13 15:03:05 +0800 | [diff] [blame] | 15 | /* IPC model */ |
Ken Liu | 82e3eac | 2021-10-14 16:19:13 +0800 | [diff] [blame] | 16 | #define {{"%-56s"|format("CONFIG_TFM_SPM_BACKEND_IPC")}} 1 |
Ken Liu | e07c3b7 | 2021-10-14 16:19:13 +0800 | [diff] [blame] | 17 | |
Mingyang Sun | c2521f7 | 2021-08-13 15:03:05 +0800 | [diff] [blame] | 18 | /* Trustzone NS agent working stack size. */ |
| 19 | #define {{"%-56s"|format("CONFIG_TFM_NS_AGENT_TZ_STACK_SIZE")}} 1024 |
| 20 | |
Ken Liu | e07c3b7 | 2021-10-14 16:19:13 +0800 | [diff] [blame] | 21 | #if TFM_LVL > 1 |
Ken Liu | 82e3eac | 2021-10-14 16:19:13 +0800 | [diff] [blame] | 22 | #define {{"%-56s"|format("CONFIG_TFM_PSA_API_SUPERVISOR_CALL")}} 1 |
Mingyang Sun | c2521f7 | 2021-08-13 15:03:05 +0800 | [diff] [blame] | 23 | #else /* TFM_LVL > 1 */ |
Xinyu Zhang | a7ba50b | 2021-12-27 17:32:53 +0800 | [diff] [blame] | 24 | #define {{"%-56s"|format("CONFIG_TFM_PSA_API_CROSS_CALL")}} 1 |
Mingyang Sun | c2521f7 | 2021-08-13 15:03:05 +0800 | [diff] [blame] | 25 | |
| 26 | /* SPM re-uses Trustzone NS agent stack. */ |
| 27 | #define {{"%-56s"|format("CONFIG_TFM_SPM_THREAD_STACK_SIZE")}} \ |
| 28 | {{"%-56s"|format("CONFIG_TFM_NS_AGENT_TZ_STACK_SIZE")}} |
| 29 | #endif /* TFM_LVL > 1 */ |
Ken Liu | 82e3eac | 2021-10-14 16:19:13 +0800 | [diff] [blame] | 30 | |
Xinyu Zhang | 90f08dc | 2022-01-12 15:55:17 +0800 | [diff] [blame] | 31 | {% elif partition_statistics['sfn_partition_num'] > 0 |
| 32 | and partition_statistics['ipc_partition_num'] == 0 %} |
Mingyang Sun | c2521f7 | 2021-08-13 15:03:05 +0800 | [diff] [blame] | 33 | /* SFN model */ |
Ken Liu | e07c3b7 | 2021-10-14 16:19:13 +0800 | [diff] [blame] | 34 | #define {{"%-56s"|format("CONFIG_TFM_SPM_BACKEND_SFN")}} 1 |
Mingyang Sun | c2521f7 | 2021-08-13 15:03:05 +0800 | [diff] [blame] | 35 | #define {{"%-56s"|format("CONFIG_TFM_PSA_API_SFN_CALL")}} 1 |
Mingyang Sun | eab7eae | 2021-09-30 13:06:52 +0800 | [diff] [blame] | 36 | |
| 37 | #if TFM_LVL > 1 |
| 38 | #error "High isolation level SFN model is not supported." |
| 39 | #endif |
| 40 | |
Mingyang Sun | c9a96c0 | 2021-10-14 10:32:05 +0800 | [diff] [blame] | 41 | {% set total_stk = namespace(size=0) %} |
| 42 | {% for partition in partitions %} |
| 43 | {% if "0x" in partition.manifest.stack_size or "0X" in partition.manifest.stack_size %} |
| 44 | {% set total_stk.size = total_stk.size + partition.manifest.stack_size|int(base=16) %} |
| 45 | {% else %} |
| 46 | {% set total_stk.size = total_stk.size + partition.manifest.stack_size|int(base=10) %} |
| 47 | {% endif %} |
| 48 | {% endfor %} |
Mingyang Sun | c2521f7 | 2021-08-13 15:03:05 +0800 | [diff] [blame] | 49 | /* |
| 50 | * In isolation level 1 SFN model, all subsequent components work on NS agent |
| 51 | * stack. It is observed that half of the sum of all partition stack sizes is |
| 52 | * enough for working. Define a divisor factor |
| 53 | * CONFIG_TFM_NS_AGENT_TZ_STK_SIZE_SHIFT_FACTOR for reference, and allow |
| 54 | * modification of the factor based on application situation. The stack size |
| 55 | * value is aligned to 8 bytes. |
Ken Liu | f39d8eb | 2021-10-07 12:55:33 +0800 | [diff] [blame] | 56 | * The minimum value is 0x400 to satisfy the SPM functional requirement. |
| 57 | * Manifest tool will assure this. |
Mingyang Sun | c2521f7 | 2021-08-13 15:03:05 +0800 | [diff] [blame] | 58 | */ |
Ken Liu | f39d8eb | 2021-10-07 12:55:33 +0800 | [diff] [blame] | 59 | {% if total_stk.size|int < 2048 %} |
| 60 | {% set total_stk.size = 2048 %} |
| 61 | {% endif %} |
Mingyang Sun | c2521f7 | 2021-08-13 15:03:05 +0800 | [diff] [blame] | 62 | #define CONFIG_TFM_NS_AGENT_TZ_STK_SIZE_SHIFT_FACTOR 1 |
Ken Liu | f39d8eb | 2021-10-07 12:55:33 +0800 | [diff] [blame] | 63 | #define {{"%-56s"|format("CONFIG_TFM_NS_AGENT_TZ_STACK_SIZE")}} \ |
Mingyang Sun | c2521f7 | 2021-08-13 15:03:05 +0800 | [diff] [blame] | 64 | ((({{"0x%x"|format(total_stk.size)}} >> CONFIG_TFM_NS_AGENT_TZ_STK_SIZE_SHIFT_FACTOR) + 0x7) & (~0x7)) |
Mingyang Sun | c9a96c0 | 2021-10-14 10:32:05 +0800 | [diff] [blame] | 65 | |
Xinyu Zhang | 90f08dc | 2022-01-12 15:55:17 +0800 | [diff] [blame] | 66 | {% elif partition_statistics['sfn_partition_num'] > 0 |
| 67 | and partition_statistics['ipc_partition_num'] > 0 %} |
Mingyang Sun | eab7eae | 2021-09-30 13:06:52 +0800 | [diff] [blame] | 68 | #error "IPC and SFN co-work not supported yet." |
| 69 | {% else %} |
Ken Liu | 82e3eac | 2021-10-14 16:19:13 +0800 | [diff] [blame] | 70 | #error "Invalid partition number input, check configurations." |
Mingyang Sun | eab7eae | 2021-09-30 13:06:52 +0800 | [diff] [blame] | 71 | {% endif %} |
Feder Liang | b714079 | 2021-11-25 16:07:16 +0800 | [diff] [blame] | 72 | |
| 73 | #if (CONFIG_TFM_SPE_FP > 0) && (CONFIG_TFM_SPM_BACKEND_SFN == 1) |
| 74 | #error "FP is not supported for SFN model." |
| 75 | #endif |
| 76 | |
Mingyang Sun | eab7eae | 2021-09-30 13:06:52 +0800 | [diff] [blame] | 77 | #endif /* __CONFIG_IMPL_H__ */ |