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 | */ |
Sherry Zhang | f58f2bd | 2022-01-10 17:21:11 +0800 | [diff] [blame] | 7 | /***********{{utilities.donotedit_warning}}***********/ |
Mingyang Sun | eab7eae | 2021-09-30 13:06:52 +0800 | [diff] [blame] | 8 | |
| 9 | #ifndef __CONFIG_IMPL_H__ |
| 10 | #define __CONFIG_IMPL_H__ |
| 11 | |
Xinyu Zhang | cf8478f | 2022-10-27 15:54:58 +0800 | [diff] [blame] | 12 | #include "config_tfm.h" |
| 13 | |
Kevin Peng | 9f1a754 | 2022-02-07 16:32:27 +0800 | [diff] [blame] | 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 | /* 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 Zhang | 2ed48fd | 2022-09-06 11:33:22 +0800 | [diff] [blame] | 24 | #define {{"%-56s"|format("CONFIG_TFM_MMIO_REGION_ENABLE")}} {{config_impl['CONFIG_TFM_MMIO_REGION_ENABLE']}} |
Mingyang Sun | ed5fe7b | 2022-02-10 17:33:21 +0800 | [diff] [blame] | 25 | #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 Peng | 9f1a754 | 2022-02-07 16:32:27 +0800 | [diff] [blame] | 27 | |
| 28 | #if CONFIG_TFM_SPM_BACKEND_IPC == 1 |
Mingyang Sun | c2521f7 | 2021-08-13 15:03:05 +0800 | [diff] [blame] | 29 | /* Trustzone NS agent working stack size. */ |
Xinyu Zhang | 6ad0703 | 2022-08-10 14:45:56 +0800 | [diff] [blame] | 30 | #if defined(TFM_FIH_PROFILE_ON) && TFM_LVL == 1 |
| 31 | #define {{"%-56s"|format("CONFIG_TFM_NS_AGENT_TZ_STACK_SIZE")}} 1256 |
| 32 | #else |
Mingyang Sun | c2521f7 | 2021-08-13 15:03:05 +0800 | [diff] [blame] | 33 | #define {{"%-56s"|format("CONFIG_TFM_NS_AGENT_TZ_STACK_SIZE")}} 1024 |
Xinyu Zhang | 6ad0703 | 2022-08-10 14:45:56 +0800 | [diff] [blame] | 34 | #endif |
Mingyang Sun | c2521f7 | 2021-08-13 15:03:05 +0800 | [diff] [blame] | 35 | |
Mingyang Sun | c2521f7 | 2021-08-13 15:03:05 +0800 | [diff] [blame] | 36 | /* 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 Liu | 82e3eac | 2021-10-14 16:19:13 +0800 | [diff] [blame] | 39 | |
Kevin Peng | 9f1a754 | 2022-02-07 16:32:27 +0800 | [diff] [blame] | 40 | #elif CONFIG_TFM_SPM_BACKEND_SFN == 1 |
Xinyu Zhang | cf8478f | 2022-10-27 15:54:58 +0800 | [diff] [blame] | 41 | {% set total_stk = namespace(size="0") %} |
Mingyang Sun | c9a96c0 | 2021-10-14 10:32:05 +0800 | [diff] [blame] | 42 | {% for partition in partitions %} |
Xinyu Zhang | cf8478f | 2022-10-27 15:54:58 +0800 | [diff] [blame] | 43 | {% set total_stk.size = total_stk.size + " + " + partition.manifest.stack_size %} |
Mingyang Sun | c9a96c0 | 2021-10-14 10:32:05 +0800 | [diff] [blame] | 44 | {% endfor %} |
Mingyang Sun | c2521f7 | 2021-08-13 15:03:05 +0800 | [diff] [blame] | 45 | /* |
| 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 Liu | f39d8eb | 2021-10-07 12:55:33 +0800 | [diff] [blame] | 52 | * The minimum value is 0x400 to satisfy the SPM functional requirement. |
| 53 | * Manifest tool will assure this. |
Mingyang Sun | c2521f7 | 2021-08-13 15:03:05 +0800 | [diff] [blame] | 54 | */ |
Xinyu Zhang | cf8478f | 2022-10-27 15:54:58 +0800 | [diff] [blame] | 55 | #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 Sun | c2521f7 | 2021-08-13 15:03:05 +0800 | [diff] [blame] | 61 | #define CONFIG_TFM_NS_AGENT_TZ_STK_SIZE_SHIFT_FACTOR 1 |
Ken Liu | f39d8eb | 2021-10-07 12:55:33 +0800 | [diff] [blame] | 62 | #define {{"%-56s"|format("CONFIG_TFM_NS_AGENT_TZ_STACK_SIZE")}} \ |
Xinyu Zhang | cf8478f | 2022-10-27 15:54:58 +0800 | [diff] [blame] | 63 | (((CONFIG_TFM_TOTAL_STACK_SIZE >> CONFIG_TFM_NS_AGENT_TZ_STK_SIZE_SHIFT_FACTOR) + 0x7) & (~0x7)) |
Mingyang Sun | c9a96c0 | 2021-10-14 10:32:05 +0800 | [diff] [blame] | 64 | |
Kevin Peng | 9f1a754 | 2022-02-07 16:32:27 +0800 | [diff] [blame] | 65 | #endif /* CONFIG_TFM_SPM_BACKEND_IPC == 1 */ |
Feder Liang | b714079 | 2021-11-25 16:07:16 +0800 | [diff] [blame] | 66 | |
Mingyang Sun | eab7eae | 2021-09-30 13:06:52 +0800 | [diff] [blame] | 67 | #endif /* __CONFIG_IMPL_H__ */ |