blob: 03f2f14ff6e548085c148bde58e6f4385a4efb39 [file] [log] [blame]
Mingyang Sundeae45d2021-09-06 15:31:07 +08001/*
shejia01a0ea10c2022-06-27 13:56:00 +08002 * Copyright (c) 2021-2023, Arm Limited. All rights reserved.
Mingyang Sundeae45d2021-09-06 15:31:07 +08003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8#ifndef __BACKEND_H__
9#define __BACKEND_H__
10
11#include <stdint.h>
Sherry Zhangc7147022023-02-03 11:21:10 +080012#include "spm.h"
Ken Liue07c3b72021-10-14 16:19:13 +080013#include "tfm_arch.h"
Mingyang Sundeae45d2021-09-06 15:31:07 +080014#include "load/spm_load_api.h"
Ken Liue07c3b72021-10-14 16:19:13 +080015#include "psa/error.h"
Mingyang Sundeae45d2021-09-06 15:31:07 +080016
Ken Liu82a38832022-05-23 09:46:52 +080017#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
shejia01a0ea10c2022-06-27 13:56:00 +080025/**
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 Liu995a9742022-05-18 19:28:30 +080031/*
32 * Runtime model-specific component initialization routine. This
33 * is an `assuredly` function, would panic if any error occurred.
34 */
35void backend_init_comp_assuredly(struct partition_t *p_pt,
36 uint32_t service_setting);
Mingyang Sundeae45d2021-09-06 15:31:07 +080037
Ken Liu995a9742022-05-18 19:28:30 +080038/*
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 */
43uint32_t backend_system_run(void);
Mingyang Sundeae45d2021-09-06 15:31:07 +080044
Ken Liu995a9742022-05-18 19:28:30 +080045/* Runtime model-specific message handling mechanism. */
46psa_status_t backend_messaging(struct service_t *p_serv,
Ken Liuc9313eb2023-02-22 15:45:54 +080047 struct connection_t *handle);
Mingyang Sundeae45d2021-09-06 15:31:07 +080048
Ken Liu995a9742022-05-18 19:28:30 +080049/*
50 * Runtime model-specific message replying.
51 * Return the connection handle or the acked status code.
52 */
Ken Liuc9313eb2023-02-22 15:45:54 +080053psa_status_t backend_replying(struct connection_t *handle, int32_t status);
Mingyang Sundeae45d2021-09-06 15:31:07 +080054
shejia0195a88bc2023-01-16 15:44:46 +080055/**
56 * \brief Set the wait signal pattern in current partition.
Ken Liu995a9742022-05-18 19:28:30 +080057 */
Jianliang Shenbd8c7c92023-03-03 16:07:42 +010058psa_signal_t backend_wait_signals(struct partition_t *p_pt, psa_signal_t signals);
Kevin Pengdef92de2021-11-10 16:14:48 +080059
shejia0195a88bc2023-01-16 15:44:46 +080060/**
61 * \brief Set the asserted signal pattern in current partition.
Ken Liu995a9742022-05-18 19:28:30 +080062 */
Jianliang Shenbd8c7c92023-03-03 16:07:42 +010063uint32_t backend_assert_signal(struct partition_t *p_pt, psa_signal_t signal);
Mingyang Sundeae45d2021-09-06 15:31:07 +080064
65/* The component list, and a MACRO indicate this is not a common global. */
66extern struct partition_head_t partition_listhead;
67#define PARTITION_LIST_ADDR (&partition_listhead)
68
Ken Liue07c3b72021-10-14 16:19:13 +080069/* TODO: Put this into NS Agent related service when available. */
70extern struct context_ctrl_t *p_spm_thread_context;
71#define SPM_THREAD_CONTEXT p_spm_thread_context
72
Mingyang Sundeae45d2021-09-06 15:31:07 +080073#endif /* __BACKEND_H__ */