blob: 9beb5092e91aab1e3695f923b0b27cdd6892d851 [file] [log] [blame]
David Hu49ec08a2019-09-23 16:13:41 +08001/*
2 * Copyright (c) 2019, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8/* API definitions in NSPE mailbox library */
9
10#ifndef __TFM_NS_MAILBOX_H__
11#define __TFM_NS_MAILBOX_H__
12
13#include <stdbool.h>
14#include "tfm_mailbox.h"
15
16/**
17 * \brief Prepare and send PSA client call request to SPE via mailbox.
18 *
19 * \param[in] call_type PSA client call type
20 * \param[in] params Parmaters used for PSA client call
21 * \param[in] client_id Optional client ID of non-secure caller.
22 * It is required to identify the non-secure caller
23 * when NSPE OS enforces non-secure task isolation.
24 *
25 * \retval >= 0 The handle to the mailbox message assigned.
26 * \retval < 0 Operation failed with an error code.
27 */
28mailbox_msg_handle_t mailbox_tx_client_call_req(uint32_t call_type,
29 const struct psa_client_params_t *params,
30 int32_t client_id);
31
32/**
33 * \brief Fetch PSA client call return result.
34 *
35 * \param[in] handle The handle to the mailbox message
36 * \param[out] reply The address to be written with return result.
37 *
38 * \retval MAILBOX_SUCCESS Successfully get PSA client call return result.
39 * \retval Other return code Operation failed with an error code.
40 */
41int32_t mailbox_rx_client_call_reply(mailbox_msg_handle_t handle,
42 int32_t *reply);
43
44/**
45 * \brief Check whether a specific mailbox message has been replied.
46 *
47 * \param[in] handle The handle to the mailbox message
48 *
49 * \retval true The PSA client call return value is replied.
50 * \retval false The PSA client call return value is not
51 * replied yet.
52 */
53bool mailbox_is_msg_replied(mailbox_msg_handle_t handle);
54
55/**
56 * \brief Notify SPE to deal with the PSA client call sent via mailbox
57 *
58 * \retval MAILBOX_SUCCESS Operation succeeded.
59 * \retval Other return code Operation failed with an error code.
60 */
61int32_t mailbox_notify_peer(void);
62
63/**
64 * \brief NSPE mailbox initialization
65 *
66 * \param[in] queue The base address of NSPE mailbox queue to be
67 * initialized.
68 *
69 * \retval MAILBOX_SUCCESS Operation succeeded.
70 * \retval Other return code Operation failed with an error code.
71 */
72int32_t mailbox_init(struct ns_mailbox_queue_t *queue);
73
74/**
75 * \brief Platform specific NSPE mailbox initialization.
76 * Invoked by \ref mailbox_init().
77 *
78 * \param[in] queue The base address of NSPE mailbox queue to be
79 * initialized.
80 *
81 * \retval MAILBOX_SUCCESS Operation succeeded.
82 * \retval Other return code Operation failed with an error code.
83 */
84int32_t mailbox_hal_init(struct ns_mailbox_queue_t *queue);
85
86/**
87 * \brief Enter critical section of NSPE mailbox
88 */
89void mailbox_enter_critical(void);
90
91/**
92 * \brief Exit critical section of NSPE mailbox
93 */
94void mailbox_exit_critical(void);
95
96#endif /* __TFM_NS_MAILBOX_H__ */