SPM: Use FF-A for message handling in Ivy

Replace the use of SPRT for message handling with FF-A.

Signed-off-by: Daniel Boulby <daniel.boulby@arm.com>
Change-Id: I489d33a958f8c43aef7c9074f5c570f0c8b37518
diff --git a/spm/ivy/ivy_main.c b/spm/ivy/ivy_main.c
index 8542150..02f8be2 100644
--- a/spm/ivy/ivy_main.c
+++ b/spm/ivy/ivy_main.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2021, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -13,8 +13,6 @@
 #include <plat_arm.h>
 #include <platform_def.h>
 #include <sp_helpers.h>
-#include <sprt_client.h>
-#include <sprt_svc.h>
 
 #include "ivy.h"
 #include "ivy_def.h"
@@ -48,46 +46,11 @@
 		(void *)(IVY_NS_BUF_BASE + IVY_NS_BUF_SIZE));
 }
 
-void ivy_message_handler(struct sprt_queue_entry_message *message)
-{
-	u_register_t ret0 = 0U, ret1 = 0U, ret2 = 0U, ret3 = 0U;
-
-	if (message->type == SPRT_MSG_TYPE_SERVICE_REQUEST) {
-		switch (message->args[1]) {
-
-		case IVY_PRINT_MAGIC:
-			INFO("IVY: Magic: 0x%x\n", IVY_MAGIC_NUMBER);
-			ret0 = SPRT_SUCCESS;
-			break;
-
-		case IVY_GET_MAGIC:
-			ret1 = IVY_MAGIC_NUMBER;
-			ret0 = SPRT_SUCCESS;
-			break;
-
-		case IVY_SLEEP_MS:
-			sp_sleep(message->args[2]);
-			ret0 = SPRT_SUCCESS;
-			break;
-
-		default:
-			NOTICE("IVY: Unhandled Service ID 0x%x\n",
-			       (unsigned int)message->args[1]);
-			ret0 = SPRT_NOT_SUPPORTED;
-			break;
-		}
-	} else {
-		NOTICE("Ivy: Unhandled Service type 0x%x\n",
-		       (unsigned int)message->type);
-		ret0 = SPRT_NOT_SUPPORTED;
-	}
-
-
-	sprt_message_end(message, ret0, ret1, ret2, ret3);
-}
-
 void __dead2 ivy_main(void)
 {
+	u_register_t ret;
+	svc_args args;
+
 	console_init(PL011_UART3_BASE,
 		     PL011_UART3_CLK_IN_HZ,
 		     PL011_BAUDRATE);
@@ -99,37 +62,19 @@
 
 	ivy_print_memory_layout();
 
-	/*
-	 * Handle secure service requests.
-	 */
-	sprt_initialize_queues((void *)IVY_SPM_BUF_BASE);
-
+init:
+	args = (svc_args){.fid = FFA_MSG_WAIT};
+	ret = sp_svc(&args);
 	while (1) {
-		struct sprt_queue_entry_message message;
-
-		/*
-		 * Try to fetch a message from the blocking requests queue. If
-		 * it is empty, try to fetch from the non-blocking requests
-		 * queue. Repeat until both of them are empty.
-		 */
-		while (1) {
-			int err = sprt_get_next_message(&message,
-					SPRT_QUEUE_NUM_BLOCKING);
-			if (err == -ENOENT) {
-				err = sprt_get_next_message(&message,
-						SPRT_QUEUE_NUM_NON_BLOCKING);
-				if (err == -ENOENT) {
-					break;
-				} else {
-					assert(err == 0);
-					ivy_message_handler(&message);
-				}
-			} else {
-				assert(err == 0);
-				ivy_message_handler(&message);
-			}
+		if (ret != FFA_MSG_SEND_DIRECT_REQ_SMC32) {
+			ERROR("unknown FF-A request %lx\n", ret);
+			goto init;
 		}
-
-		sprt_wait_for_messages();
+		VERBOSE("Received request: %lx\n", args.arg3);
+		args.fid = FFA_MSG_SEND_DIRECT_RESP_SMC32;
+		args.arg1 = 0x80020000;
+		args.arg2 = 0;
+		args.arg3 = 0;
+		ret = sp_svc(&args);
 	}
 }