1/* 2 * Copyright (c) 2021-2022, Arm Limited. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 * 6 */ 7/***********{{utilities.donotedit_warning}}***********/ 8 9#ifndef __CONFIG_IMPL_H__ 10#define __CONFIG_IMPL_H__ 11 12#include "config_tfm.h" 13 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']}} 24#define {{"%-56s"|format("CONFIG_TFM_MMIO_REGION_ENABLE")}} {{config_impl['CONFIG_TFM_MMIO_REGION_ENABLE']}} 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']}} 27 28#if CONFIG_TFM_SPM_BACKEND_IPC == 1 29/* Trustzone NS agent working stack size. */ 30#if defined(TFM_FIH_PROFILE_ON) && TFM_LVL == 1 31#define {{"%-56s"|format("CONFIG_TFM_NS_AGENT_TZ_STACK_SIZE")}} 1256 32#else 33#define {{"%-56s"|format("CONFIG_TFM_NS_AGENT_TZ_STACK_SIZE")}} 1024 34#endif 35 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")}} 39 40#elif CONFIG_TFM_SPM_BACKEND_SFN == 1 41 {% set total_stk = namespace(size="0") %} 42 {% for partition in partitions %} 43 {% set total_stk.size = total_stk.size + " + " + partition.manifest.stack_size %} 44 {% endfor %} 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. 52 * The minimum value is 0x400 to satisfy the SPM functional requirement. 53 * Manifest tool will assure this. 54 */ 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 61#define CONFIG_TFM_NS_AGENT_TZ_STK_SIZE_SHIFT_FACTOR 1 62#define {{"%-56s"|format("CONFIG_TFM_NS_AGENT_TZ_STACK_SIZE")}} \ 63 (((CONFIG_TFM_TOTAL_STACK_SIZE >> CONFIG_TFM_NS_AGENT_TZ_STK_SIZE_SHIFT_FACTOR) + 0x7) & (~0x7)) 64 65#endif /* CONFIG_TFM_SPM_BACKEND_IPC == 1 */ 66 67#endif /* __CONFIG_IMPL_H__ */ 68