Mingyang Sun | deae45d | 2021-09-06 15:31:07 +0800 | [diff] [blame] | 1 | /* |
shejia01 | a0ea10c | 2022-06-27 13:56:00 +0800 | [diff] [blame] | 2 | * Copyright (c) 2021-2023, Arm Limited. All rights reserved. |
Mingyang Sun | deae45d | 2021-09-06 15:31:07 +0800 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #ifndef __BACKEND_H__ |
| 9 | #define __BACKEND_H__ |
| 10 | |
| 11 | #include <stdint.h> |
Sherry Zhang | c714702 | 2023-02-03 11:21:10 +0800 | [diff] [blame] | 12 | #include "spm.h" |
Ken Liu | e07c3b7 | 2021-10-14 16:19:13 +0800 | [diff] [blame] | 13 | #include "tfm_arch.h" |
Mingyang Sun | deae45d | 2021-09-06 15:31:07 +0800 | [diff] [blame] | 14 | #include "load/spm_load_api.h" |
Ken Liu | e07c3b7 | 2021-10-14 16:19:13 +0800 | [diff] [blame] | 15 | #include "psa/error.h" |
Mingyang Sun | deae45d | 2021-09-06 15:31:07 +0800 | [diff] [blame] | 16 | |
Ken Liu | 82a3883 | 2022-05-23 09:46:52 +0800 | [diff] [blame] | 17 | #if CONFIG_TFM_SPM_BACKEND_IPC == 1 |
| 18 | #include "backend_ipc.h" |
| 19 | #elif CONFIG_TFM_SPM_BACKEND_SFN == 1 |
| 20 | #include "backend_sfn.h" |
| 21 | #else |
| 22 | #error "No backend selected, check configurations." |
| 23 | #endif |
| 24 | |
shejia01 | a0ea10c | 2022-06-27 13:56:00 +0800 | [diff] [blame] | 25 | /** |
| 26 | * The signal number for the Secure Partition thread message and reply in IPC |
| 27 | * mode. |
| 28 | */ |
| 29 | #define TFM_IPC_REPLY_SIGNAL (0x00000002u) |
| 30 | |
Ken Liu | 995a974 | 2022-05-18 19:28:30 +0800 | [diff] [blame] | 31 | /* |
| 32 | * Runtime model-specific component initialization routine. This |
| 33 | * is an `assuredly` function, would panic if any error occurred. |
| 34 | */ |
| 35 | void backend_init_comp_assuredly(struct partition_t *p_pt, |
| 36 | uint32_t service_setting); |
Mingyang Sun | deae45d | 2021-09-06 15:31:07 +0800 | [diff] [blame] | 37 | |
Ken Liu | 995a974 | 2022-05-18 19:28:30 +0800 | [diff] [blame] | 38 | /* |
| 39 | * Runtime model-specific kick-off method for the whole system. |
| 40 | * Returns a hardware-specific control value, which is transparent |
| 41 | * to SPM common logic. |
| 42 | */ |
| 43 | uint32_t backend_system_run(void); |
Mingyang Sun | deae45d | 2021-09-06 15:31:07 +0800 | [diff] [blame] | 44 | |
Ken Liu | 995a974 | 2022-05-18 19:28:30 +0800 | [diff] [blame] | 45 | /* Runtime model-specific message handling mechanism. */ |
| 46 | psa_status_t backend_messaging(struct service_t *p_serv, |
Ken Liu | c9313eb | 2023-02-22 15:45:54 +0800 | [diff] [blame] | 47 | struct connection_t *handle); |
Mingyang Sun | deae45d | 2021-09-06 15:31:07 +0800 | [diff] [blame] | 48 | |
Ken Liu | 995a974 | 2022-05-18 19:28:30 +0800 | [diff] [blame] | 49 | /* |
| 50 | * Runtime model-specific message replying. |
| 51 | * Return the connection handle or the acked status code. |
| 52 | */ |
Ken Liu | c9313eb | 2023-02-22 15:45:54 +0800 | [diff] [blame] | 53 | psa_status_t backend_replying(struct connection_t *handle, int32_t status); |
Mingyang Sun | deae45d | 2021-09-06 15:31:07 +0800 | [diff] [blame] | 54 | |
shejia01 | 95a88bc | 2023-01-16 15:44:46 +0800 | [diff] [blame] | 55 | /** |
| 56 | * \brief Set the wait signal pattern in current partition. |
Ken Liu | 995a974 | 2022-05-18 19:28:30 +0800 | [diff] [blame] | 57 | */ |
Jianliang Shen | bd8c7c9 | 2023-03-03 16:07:42 +0100 | [diff] [blame^] | 58 | psa_signal_t backend_wait_signals(struct partition_t *p_pt, psa_signal_t signals); |
Kevin Peng | def92de | 2021-11-10 16:14:48 +0800 | [diff] [blame] | 59 | |
shejia01 | 95a88bc | 2023-01-16 15:44:46 +0800 | [diff] [blame] | 60 | /** |
| 61 | * \brief Set the asserted signal pattern in current partition. |
Ken Liu | 995a974 | 2022-05-18 19:28:30 +0800 | [diff] [blame] | 62 | */ |
Jianliang Shen | bd8c7c9 | 2023-03-03 16:07:42 +0100 | [diff] [blame^] | 63 | uint32_t backend_assert_signal(struct partition_t *p_pt, psa_signal_t signal); |
Mingyang Sun | deae45d | 2021-09-06 15:31:07 +0800 | [diff] [blame] | 64 | |
| 65 | /* The component list, and a MACRO indicate this is not a common global. */ |
| 66 | extern struct partition_head_t partition_listhead; |
| 67 | #define PARTITION_LIST_ADDR (&partition_listhead) |
| 68 | |
Ken Liu | e07c3b7 | 2021-10-14 16:19:13 +0800 | [diff] [blame] | 69 | /* TODO: Put this into NS Agent related service when available. */ |
| 70 | extern struct context_ctrl_t *p_spm_thread_context; |
| 71 | #define SPM_THREAD_CONTEXT p_spm_thread_context |
| 72 | |
Mingyang Sun | deae45d | 2021-09-06 15:31:07 +0800 | [diff] [blame] | 73 | #endif /* __BACKEND_H__ */ |