aboutsummaryrefslogtreecommitdiff
path: root/interface
diff options
context:
space:
mode:
authorDavid Hu <david.hu@arm.com>2019-09-29 16:01:54 +0800
committerDavid Hu <david.hu@arm.com>2020-02-14 11:04:53 +0800
commit06ebac73af740d6ccb7bf47e26cde135f1f50962 (patch)
tree84fa1b208a6f1742bef7fa40579d1d8f387fe815 /interface
parenta79c7c14afe1262b8fbe6a7870923d9ad9032afc (diff)
downloadtrusted-firmware-m-06ebac73af740d6ccb7bf47e26cde135f1f50962.tar.gz
Dualcpu: Set mailbox message owner in NS mailbox queue slot
NSPE mailbox sets the task handle into the owner field of the queue slot. After the PSA Client result is returned, the task handle can be fetched from the owner filed and the waiting task can be woken up according to the handle value. Declare tfm_ns_mailbox_get_task_handle() to fetch the handle of current NS task executing the mailbox functionalities. Implement a dummy tfm_ns_mailbox_get_task_handle() which returns NULL when sleep/wake-up mechanism is not required. Change-Id: I58731dea26db5446bac35d6b4800bff936120ebd Signed-off-by: David Hu <david.hu@arm.com>
Diffstat (limited to 'interface')
-rw-r--r--interface/include/tfm_mailbox.h3
-rw-r--r--interface/include/tfm_ns_mailbox.h22
-rw-r--r--interface/src/tfm_ns_mailbox.c21
3 files changed, 42 insertions, 4 deletions
diff --git a/interface/include/tfm_mailbox.h b/interface/include/tfm_mailbox.h
index 9342ed6823..bb23b7a097 100644
--- a/interface/include/tfm_mailbox.h
+++ b/interface/include/tfm_mailbox.h
@@ -108,8 +108,7 @@ struct mailbox_reply_t {
struct ns_mailbox_slot_t {
struct mailbox_msg_t msg;
struct mailbox_reply_t reply;
-
- void *owner; /* Identification of the owner of this
+ const void *owner; /* Handle of the owner task of this
* slot
*/
};
diff --git a/interface/include/tfm_ns_mailbox.h b/interface/include/tfm_ns_mailbox.h
index d2bbd3f4fd..a846e7612d 100644
--- a/interface/include/tfm_ns_mailbox.h
+++ b/interface/include/tfm_ns_mailbox.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -67,6 +67,26 @@ bool tfm_ns_mailbox_is_msg_replied(mailbox_msg_handle_t handle);
*/
int32_t tfm_ns_mailbox_init(struct ns_mailbox_queue_t *queue);
+#ifdef TFM_MULTI_CORE_MULTI_CLIENT_CALL
+/**
+ * \brief Get the handle of the current non-secure task executing mailbox
+ * functionalities
+ *
+ * \note This function should be implemented according to platform, NS OS
+ * and actual use scenario.
+ * This function can be ignored or return NULL if sleep/wake-up mechanism
+ * is not required in PSA Client API implementation.
+ *
+ * \return Return the handle of task.
+ */
+const void *tfm_ns_mailbox_get_task_handle(void);
+#else
+static inline const void *tfm_ns_mailbox_get_task_handle(void)
+{
+ return NULL;
+}
+#endif
+
/**
* \brief Platform specific NSPE mailbox initialization.
* Invoked by \ref tfm_ns_mailbox_init().
diff --git a/interface/src/tfm_ns_mailbox.c b/interface/src/tfm_ns_mailbox.c
index 23e450eb0a..9ab3004769 100644
--- a/interface/src/tfm_ns_mailbox.c
+++ b/interface/src/tfm_ns_mailbox.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -7,6 +7,7 @@
#include <string.h>
#include "tfm_ns_mailbox.h"
+#include "tfm_plat_ns.h"
/* The pointer to NSPE mailbox queue */
static struct ns_mailbox_queue_t *mailbox_queue_ptr = NULL;
@@ -90,6 +91,13 @@ static uint8_t acquire_empty_slot(const struct ns_mailbox_queue_t *queue)
return idx;
}
+static void set_msg_owner(uint8_t idx, const void *owner)
+{
+ if (idx < NUM_MAILBOX_QUEUE_SLOT) {
+ mailbox_queue_ptr->queue[idx].owner = owner;
+ }
+}
+
mailbox_msg_handle_t tfm_ns_mailbox_tx_client_req(uint32_t call_type,
const struct psa_client_params_t *params,
int32_t client_id)
@@ -97,6 +105,7 @@ mailbox_msg_handle_t tfm_ns_mailbox_tx_client_req(uint32_t call_type,
uint8_t idx;
struct mailbox_msg_t *msg_ptr;
mailbox_msg_handle_t handle;
+ const void *task_handle;
if (!mailbox_queue_ptr) {
return MAILBOX_MSG_NULL_HANDLE;
@@ -118,6 +127,13 @@ mailbox_msg_handle_t tfm_ns_mailbox_tx_client_req(uint32_t call_type,
memcpy(&msg_ptr->params, params, sizeof(msg_ptr->params));
msg_ptr->client_id = client_id;
+ /*
+ * Fetch the current task handle. The task will be woken up according the
+ * handle value set in the owner field.
+ */
+ task_handle = tfm_ns_mailbox_get_task_handle();
+ set_msg_owner(idx, task_handle);
+
get_mailbox_msg_handle(idx, &handle);
tfm_ns_mailbox_hal_enter_critical();
@@ -150,6 +166,9 @@ int32_t tfm_ns_mailbox_rx_client_reply(mailbox_msg_handle_t handle,
*reply = mailbox_queue_ptr->queue[idx].reply.return_val;
+ /* Clear up the owner field */
+ set_msg_owner(idx, NULL);
+
tfm_ns_mailbox_hal_enter_critical();
set_queue_slot_empty(idx);
clear_queue_slot_replied(idx);