SPM: Add Asynchronous code to ns_agent_mailbox
Add AGENT_STATUS_IN_PROGRESS and ASYNC_MSG_REPLY defines.
Add handling of ASYNC_MSG_REPLY to ns_agent_mailbox main loop.
For now at least, this will never be called, this is simply to establish
the new API.
No behavioural change.
Change-Id: Iaee07d6eac097a20bf807844741cbecc54ad6ffd
Signed-off-by: Chris Brand <chris.brand@cypress.com>
diff --git a/docs/design_docs/dual-cpu/mailbox_ns_agent_update.rst b/docs/design_docs/dual-cpu/mailbox_ns_agent_update.rst
index 62be5ba..aae622f 100644
--- a/docs/design_docs/dual-cpu/mailbox_ns_agent_update.rst
+++ b/docs/design_docs/dual-cpu/mailbox_ns_agent_update.rst
@@ -187,7 +187,7 @@
.. code-block:: c
- #define PSA_MSG_ACK (0x00000004u)
+ #define ASYNC_MSG_REPLY (0x00000004u)
This signal can be sent to agent type component only. An agent can call
``psa_get`` with this signal to get one acknowledged message. This signal is
@@ -196,7 +196,7 @@
For the stateless handle, the internal handle object is freed after this
``psa_get`` call. The agent can know what kind of message is acknowledged by
the ``type`` member in the ``psa_msg_t``, and the ``client_data`` passed in is
-put in member ``rhandle``. If no 'PSA_MSG_ACK' signals pending, calling
+put in member ``rhandle``. If no 'ASYNC_MSG_REPLY' signals pending, calling
``psa_get`` gets ``panic``.
Code Example
@@ -260,9 +260,9 @@
*/
error_dispatch(status);
- } else if (signals & PSA_MSG_ACK) {
+ } else if (signals & ASYNC_MSG_REPLY) {
/* The handle is freed for stateless service after 'psa_get'. */
- status = psa_get(PSA_MSG_ACK, &msg);
+ status = psa_get(ASYNC_MSG_REPLY, &msg);
ms_msg = msg.rhandle;
ns_msg.status = status;
__customized_platform__send_mail(&ns_msg);
diff --git a/interface/include/psa/service.h b/interface/include/psa/service.h
index 09448c6..39fde10 100644
--- a/interface/include/psa/service.h
+++ b/interface/include/psa/service.h
@@ -1,5 +1,7 @@
/*
* Copyright (c) 2018-2022, Arm Limited. All rights reserved.
+ * Copyright (c) 2023 Cypress Semiconductor Corporation (an Infineon company)
+ * or an affiliate of Cypress Semiconductor Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -80,13 +82,11 @@
* - secure partition id;
* - non secure client endpoint id.
*/
-#if CONFIG_TFM_CONNECTION_BASED_SERVICE_API == 1
void *rhandle; /* Be useful for binding a connection to some
* application-specific data or function
* pointer within the RoT Service
* implementation.
*/
-#endif
size_t in_size[PSA_MAX_IOVEC]; /* Provide the size of each client input
* vector in bytes.
*/
diff --git a/secure_fw/include/async.h b/secure_fw/include/async.h
new file mode 100644
index 0000000..658b22e
--- /dev/null
+++ b/secure_fw/include/async.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2023 Cypress Semiconductor Corporation (an Infineon company)
+ * or an affiliate of Cypress Semiconductor Corporation. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#ifndef __ASYNC_H__
+#define __ASYNC_H__
+
+#include "psa/error.h"
+
+/**
+ * Status returned for a request that will complete asynchronously.
+ */
+#define AGENT_STATUS_IN_PROGRESS ((psa_status_t)-256)
+
+/**
+ * The signal number for the Secure Partition message acknowledgment.
+ */
+#define ASYNC_MSG_REPLY (0x00000004u)
+
+#endif /* __ASYNC_H__ */
diff --git a/secure_fw/partitions/ns_agent_mailbox/ns_agent_mailbox.c b/secure_fw/partitions/ns_agent_mailbox/ns_agent_mailbox.c
index 64effe0..26fe240 100644
--- a/secure_fw/partitions/ns_agent_mailbox/ns_agent_mailbox.c
+++ b/secure_fw/partitions/ns_agent_mailbox/ns_agent_mailbox.c
@@ -1,11 +1,13 @@
/*
* Copyright (c) 2021-2023, Arm Limited. All rights reserved.
- * Copyright (c) 2021, Cypress Semiconductor Corp. All rights reserved.
+ * Copyright (c) 2021-2023 Cypress Semiconductor Corporation (an Infineon company)
+ * or an affiliate of Cypress Semiconductor Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
+#include "async.h"
#include "psa/service.h"
#include "psa_manifest/ns_agent_mailbox.h"
#include "tfm_hal_multi_core.h"
@@ -41,6 +43,14 @@
if (signals & MAILBOX_SIGNAL) {
psa_eoi(MAILBOX_SIGNAL);
tfm_rpc_client_call_handler();
+ } else if (signals & ASYNC_MSG_REPLY) {
+ /* TODO when this is the only caller of tfm_rpc_client_call_reply(),
+ * make it parameterless and move the rest of this code inside it
+ */
+ psa_msg_t msg;
+ psa_status_t status = psa_get(ASYNC_MSG_REPLY, &msg);
+
+ tfm_rpc_client_call_reply(msg.rhandle, status);
} else {
psa_panic();
}