8 #include "cmsis_compiler.h"
16 #define NS_CALLER_FLAG (true)
20 static int32_t tfm_mailbox_dispatch(uint32_t call_type,
25 struct client_call_params_t spm_params = {0};
126 *idx = (uint8_t)(handle - 1);
131 static void mailbox_clean_queue_slot(uint8_t idx)
138 sizeof(spe_mailbox_queue.
queue[idx]));
155 static void mailbox_direct_reply(uint8_t idx, uint32_t result)
158 uint32_t ret_result = result;
165 mailbox_clean_queue_slot(idx);
207 mask_bits = (1 << idx);
209 if (!(pend_slots & mask_bits)) {
223 msg_ptr = &spe_mailbox_queue.
queue[idx].
msg;
227 mailbox_clean_queue_slot(idx);
244 mailbox_clean_queue_slot(idx);
257 reply_slots |= (1 << idx);
259 mailbox_direct_reply(idx, (uint32_t)psa_ret);
267 reply_slots |= (1 << idx);
268 mailbox_direct_reply(idx, (uint32_t)psa_ret);
321 mailbox_direct_reply(idx, (uint32_t)reply);
336 static void mailbox_handle_req(
void)
342 static void mailbox_reply(
const void *owner, int32_t ret)
355 static const void *mailbox_get_caller_data(int32_t client_id)
370 static const struct tfm_rpc_ops_t mailbox_rpc_ops = {
371 .handle_req = mailbox_handle_req,
372 .reply = mailbox_reply,
373 .get_caller_data = mailbox_get_caller_data,
380 spm_memset(&spe_mailbox_queue, 0,
sizeof(spe_mailbox_queue));
389 if (ret != TFM_RPC_SUCCESS) {
__STATIC_INLINE struct mailbox_reply_t * get_nspe_reply_addr(uint8_t idx)
psa_status_t tfm_rpc_psa_connect(const struct client_call_params_t *params, bool ns_caller)
psa_status_t tfm_rpc_psa_call(const struct client_call_params_t *params, bool ns_caller)
struct ns_mailbox_queue_t * ns_queue
struct mailbox_reply_t reply
__STATIC_INLINE void clear_spe_queue_empty_status(uint8_t idx)
struct psa_client_params_t::@2::@7 psa_close_params
mailbox_queue_status_t replied_slots
void tfm_rpc_psa_close(const struct client_call_params_t *params, bool ns_caller)
struct psa_client_params_t::@2::@6 psa_call_params
#define MAILBOX_INVAL_PARAMS
int32_t tfm_mailbox_hal_init(struct secure_mailbox_queue_t *s_queue)
Platform specific initialization of SPE mailbox.
struct psa_client_params_t params
__STATIC_INLINE void clear_nspe_queue_pend_status(struct ns_mailbox_queue_t *ns_queue, mailbox_queue_status_t mask)
mailbox_queue_status_t empty_slots
mailbox_msg_handle_t msg_handle
__STATIC_INLINE bool get_spe_queue_empty_status(uint8_t idx)
mailbox_queue_status_t pend_slots
#define MAILBOX_PSA_CLOSE
Standard error codes for the SPM and RoT Services.
uint8_t cur_proc_slot_idx
struct ns_mailbox_slot_t queue[(1)]
int32_t tfm_mailbox_init(void)
SPE mailbox initialization.
int32_t tfm_mailbox_hal_notify_peer(void)
Notify NSPE that a PSA client call return result is replied. Implemented by platform specific inter-p...
#define MAILBOX_PSA_CONNECT
uint32_t tfm_rpc_psa_framework_version(void)
#define PSA_ERROR_GENERIC_ERROR
__STATIC_INLINE int32_t get_spe_mailbox_msg_idx(mailbox_msg_handle_t handle, uint8_t *idx)
#define NUM_MAILBOX_QUEUE_SLOT
__STATIC_INLINE void set_spe_queue_empty_status(uint8_t idx)
#define MAILBOX_NO_PEND_EVENT
uint32_t mailbox_queue_status_t
__STATIC_INLINE mailbox_queue_status_t get_nspe_queue_pend_status(const struct ns_mailbox_queue_t *ns_queue)
int32_t mailbox_msg_handle_t
#define MAILBOX_CALLBACK_REG_ERROR
void * spm_memcpy(void *dest, const void *src, size_t n)
Memory copy function for TF-M core.
void * spm_memset(void *s, int c, size_t n)
Memory set function for TF-M core.
int32_t tfm_mailbox_reply_msg(mailbox_msg_handle_t handle, int32_t reply)
Return PSA client call return result to NSPE.
void tfm_mailbox_hal_enter_critical(void)
Enter critical section of NSPE mailbox.
__STATIC_INLINE int32_t check_mailbox_msg(const struct mailbox_msg_t *msg)
#define TFM_CORE_ASSERT(cond)
void tfm_rpc_unregister_ops(void)
__STATIC_INLINE int32_t get_spe_mailbox_msg_handle(uint8_t idx, mailbox_msg_handle_t *handle)
int32_t tfm_rpc_register_ops(const struct tfm_rpc_ops_t *ops_ptr)
__STATIC_INLINE void set_nspe_queue_replied_status(struct ns_mailbox_queue_t *ns_queue, mailbox_queue_status_t mask)
void tfm_mailbox_hal_exit_critical(void)
Exit critical section of NSPE mailbox.
struct psa_client_params_t::@2::@5 psa_connect_params
#define MAILBOX_PSA_FRAMEWORK_VERSION
uint32_t tfm_rpc_psa_version(const struct client_call_params_t *params, bool ns_caller)
#define MAILBOX_MSG_NULL_HANDLE
struct secure_mailbox_slot_t queue[NUM_MAILBOX_QUEUE_SLOT]
int32_t psa_status_t
Function return status.
int32_t tfm_mailbox_handle_msg(void)
Handle mailbox message(s) from NSPE.
#define MAILBOX_PSA_VERSION
struct psa_client_params_t::@2::@4 psa_version_params