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/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();
         }