SPCI is now called PSA FF-A.

Change-Id: Iaa10e0449edf5f6493ab21e648219392b17cc5ec
diff --git a/test/vmapi/common/BUILD.gn b/test/vmapi/common/BUILD.gn
index 081c90e..c9a6eea 100644
--- a/test/vmapi/common/BUILD.gn
+++ b/test/vmapi/common/BUILD.gn
@@ -19,7 +19,7 @@
   public_configs = [ "//test/hftest:hftest_config" ]
   sources = [
     "exception_handler.c",
-    "spci.c",
+    "ffa.c",
   ]
   include_dirs = [ "//src/arch/aarch64" ]
 }
diff --git a/test/vmapi/common/exception_handler.c b/test/vmapi/common/exception_handler.c
index 14fe1e1..82ca679 100644
--- a/test/vmapi/common/exception_handler.c
+++ b/test/vmapi/common/exception_handler.c
@@ -36,27 +36,27 @@
 
 	dlog("Sending exception_count %d to primary VM\n",
 	     exception_handler_exception_count);
-	memcpy_s(send_buf, SPCI_MSG_PAYLOAD_MAX,
+	memcpy_s(send_buf, FFA_MSG_PAYLOAD_MAX,
 		 (const void *)&exception_handler_exception_count,
 		 sizeof(exception_handler_exception_count));
-	EXPECT_EQ(spci_msg_send(hf_vm_get_id(), HF_PRIMARY_VM_ID,
-				sizeof(exception_handler_exception_count), 0)
+	EXPECT_EQ(ffa_msg_send(hf_vm_get_id(), HF_PRIMARY_VM_ID,
+			       sizeof(exception_handler_exception_count), 0)
 			  .func,
-		  SPCI_SUCCESS_32);
+		  FFA_SUCCESS_32);
 }
 
 /**
  * Receives the number of exceptions handled.
  */
 int exception_handler_receive_exception_count(
-	const struct spci_value *send_res,
-	const struct spci_memory_region *recv_buf)
+	const struct ffa_value *send_res,
+	const struct ffa_memory_region *recv_buf)
 {
 	int exception_count = *((const int *)recv_buf);
 
-	EXPECT_EQ(send_res->func, SPCI_MSG_SEND_32);
-	EXPECT_EQ(spci_msg_send_size(*send_res), sizeof(exception_count));
-	EXPECT_EQ(spci_rx_release().func, SPCI_SUCCESS_32);
+	EXPECT_EQ(send_res->func, FFA_MSG_SEND_32);
+	EXPECT_EQ(ffa_msg_send_size(*send_res), sizeof(exception_count));
+	EXPECT_EQ(ffa_rx_release().func, FFA_SUCCESS_32);
 	return exception_count;
 }
 
diff --git a/test/vmapi/common/ffa.c b/test/vmapi/common/ffa.c
new file mode 100644
index 0000000..a7048b1
--- /dev/null
+++ b/test/vmapi/common/ffa.c
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2018 The Hafnium Authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "hf/ffa.h"
+
+#include "hf/mm.h"
+#include "hf/static_assert.h"
+
+#include "vmapi/hf/call.h"
+
+#include "test/hftest.h"
+#include "test/vmapi/ffa.h"
+
+static alignas(PAGE_SIZE) uint8_t send_page[PAGE_SIZE];
+static alignas(PAGE_SIZE) uint8_t recv_page[PAGE_SIZE];
+static_assert(sizeof(send_page) == PAGE_SIZE, "Send page is not a page.");
+static_assert(sizeof(recv_page) == PAGE_SIZE, "Recv page is not a page.");
+
+static hf_ipaddr_t send_page_addr = (hf_ipaddr_t)send_page;
+static hf_ipaddr_t recv_page_addr = (hf_ipaddr_t)recv_page;
+
+struct mailbox_buffers set_up_mailbox(void)
+{
+	ASSERT_EQ(ffa_rxtx_map(send_page_addr, recv_page_addr).func,
+		  FFA_SUCCESS_32);
+	return (struct mailbox_buffers){
+		.send = send_page,
+		.recv = recv_page,
+	};
+}
+
+/*
+ * Helper function to send memory to a VM then send a message with the retrieve
+ * request it needs to retrieve it.
+ */
+ffa_memory_handle_t send_memory_and_retrieve_request(
+	uint32_t share_func, void *tx_buffer, ffa_vm_id_t sender,
+	ffa_vm_id_t recipient,
+	struct ffa_memory_region_constituent constituents[],
+	uint32_t constituent_count, ffa_memory_region_flags_t flags,
+	enum ffa_data_access send_data_access,
+	enum ffa_data_access retrieve_data_access,
+	enum ffa_instruction_access send_instruction_access,
+	enum ffa_instruction_access retrieve_instruction_access)
+{
+	uint32_t msg_size;
+	struct ffa_value ret;
+	ffa_memory_handle_t handle;
+
+	/* Send the memory. */
+	msg_size = ffa_memory_region_init(
+		tx_buffer, sender, recipient, constituents, constituent_count,
+		0, flags, send_data_access, send_instruction_access,
+		FFA_MEMORY_NORMAL_MEM, FFA_MEMORY_CACHE_WRITE_BACK,
+		FFA_MEMORY_OUTER_SHAREABLE);
+	switch (share_func) {
+	case FFA_MEM_DONATE_32:
+		ret = ffa_mem_donate(msg_size, msg_size);
+		break;
+	case FFA_MEM_LEND_32:
+		ret = ffa_mem_lend(msg_size, msg_size);
+		break;
+	case FFA_MEM_SHARE_32:
+		ret = ffa_mem_share(msg_size, msg_size);
+		break;
+	default:
+		FAIL("Invalid share_func %#x.\n", share_func);
+		/* Never reached, but needed to keep clang-analyser happy. */
+		return 0;
+	}
+	EXPECT_EQ(ret.func, FFA_SUCCESS_32);
+	handle = ffa_mem_success_handle(ret);
+
+	/*
+	 * Send the appropriate retrieve request to the VM so that it can use it
+	 * to retrieve the memory.
+	 */
+	msg_size = ffa_memory_retrieve_request_init(
+		tx_buffer, handle, sender, recipient, 0, 0,
+		retrieve_data_access, retrieve_instruction_access,
+		FFA_MEMORY_NORMAL_MEM, FFA_MEMORY_CACHE_WRITE_BACK,
+		FFA_MEMORY_OUTER_SHAREABLE);
+	EXPECT_EQ(ffa_msg_send(sender, recipient, msg_size, 0).func,
+		  FFA_SUCCESS_32);
+
+	return handle;
+}
+
+/*
+ * Use the retrieve request from the receive buffer to retrieve a memory region
+ * which has been sent to us. Returns the sender, and the handle via a return
+ * parameter.
+ */
+ffa_vm_id_t retrieve_memory_from_message(void *recv_buf, void *send_buf,
+					 struct ffa_value msg_ret,
+					 ffa_memory_handle_t *handle)
+{
+	uint32_t msg_size;
+	struct ffa_value ret;
+	struct ffa_memory_region *memory_region;
+	ffa_vm_id_t sender;
+
+	EXPECT_EQ(msg_ret.func, FFA_MSG_SEND_32);
+	msg_size = ffa_msg_send_size(msg_ret);
+	sender = ffa_msg_send_sender(msg_ret);
+
+	if (handle != NULL) {
+		struct ffa_memory_region *retrieve_request =
+			(struct ffa_memory_region *)recv_buf;
+		*handle = retrieve_request->handle;
+	}
+	memcpy_s(send_buf, HF_MAILBOX_SIZE, recv_buf, msg_size);
+	ffa_rx_release();
+	ret = ffa_mem_retrieve_req(msg_size, msg_size);
+	EXPECT_EQ(ret.func, FFA_MEM_RETRIEVE_RESP_32);
+	memory_region = (struct ffa_memory_region *)recv_buf;
+	EXPECT_EQ(memory_region->receiver_count, 1);
+	EXPECT_EQ(memory_region->receivers[0].receiver_permissions.receiver,
+		  hf_vm_get_id());
+
+	return sender;
+}
+
+/*
+ * Use the retrieve request from the receive buffer to retrieve a memory region
+ * which has been sent to us, expecting it to fail with the given error code.
+ * Returns the sender.
+ */
+ffa_vm_id_t retrieve_memory_from_message_expect_fail(void *recv_buf,
+						     void *send_buf,
+						     struct ffa_value msg_ret,
+						     int32_t expected_error)
+{
+	uint32_t msg_size;
+	struct ffa_value ret;
+	ffa_vm_id_t sender;
+
+	EXPECT_EQ(msg_ret.func, FFA_MSG_SEND_32);
+	msg_size = ffa_msg_send_size(msg_ret);
+	sender = ffa_msg_send_sender(msg_ret);
+
+	memcpy_s(send_buf, HF_MAILBOX_SIZE, recv_buf, msg_size);
+	ffa_rx_release();
+	ret = ffa_mem_retrieve_req(msg_size, msg_size);
+	EXPECT_FFA_ERROR(ret, expected_error);
+
+	return sender;
+}
diff --git a/test/vmapi/common/spci.c b/test/vmapi/common/spci.c
deleted file mode 100644
index 0bc3380..0000000
--- a/test/vmapi/common/spci.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright 2018 The Hafnium Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "hf/spci.h"
-
-#include "hf/mm.h"
-#include "hf/static_assert.h"
-
-#include "vmapi/hf/call.h"
-
-#include "test/hftest.h"
-#include "test/vmapi/spci.h"
-
-static alignas(PAGE_SIZE) uint8_t send_page[PAGE_SIZE];
-static alignas(PAGE_SIZE) uint8_t recv_page[PAGE_SIZE];
-static_assert(sizeof(send_page) == PAGE_SIZE, "Send page is not a page.");
-static_assert(sizeof(recv_page) == PAGE_SIZE, "Recv page is not a page.");
-
-static hf_ipaddr_t send_page_addr = (hf_ipaddr_t)send_page;
-static hf_ipaddr_t recv_page_addr = (hf_ipaddr_t)recv_page;
-
-struct mailbox_buffers set_up_mailbox(void)
-{
-	ASSERT_EQ(spci_rxtx_map(send_page_addr, recv_page_addr).func,
-		  SPCI_SUCCESS_32);
-	return (struct mailbox_buffers){
-		.send = send_page,
-		.recv = recv_page,
-	};
-}
-
-/*
- * Helper function to send memory to a VM then send a message with the retrieve
- * request it needs to retrieve it.
- */
-spci_memory_handle_t send_memory_and_retrieve_request(
-	uint32_t share_func, void *tx_buffer, spci_vm_id_t sender,
-	spci_vm_id_t recipient,
-	struct spci_memory_region_constituent constituents[],
-	uint32_t constituent_count, spci_memory_region_flags_t flags,
-	enum spci_data_access send_data_access,
-	enum spci_data_access retrieve_data_access,
-	enum spci_instruction_access send_instruction_access,
-	enum spci_instruction_access retrieve_instruction_access)
-{
-	uint32_t msg_size;
-	struct spci_value ret;
-	spci_memory_handle_t handle;
-
-	/* Send the memory. */
-	msg_size = spci_memory_region_init(
-		tx_buffer, sender, recipient, constituents, constituent_count,
-		0, flags, send_data_access, send_instruction_access,
-		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
-		SPCI_MEMORY_OUTER_SHAREABLE);
-	switch (share_func) {
-	case SPCI_MEM_DONATE_32:
-		ret = spci_mem_donate(msg_size, msg_size);
-		break;
-	case SPCI_MEM_LEND_32:
-		ret = spci_mem_lend(msg_size, msg_size);
-		break;
-	case SPCI_MEM_SHARE_32:
-		ret = spci_mem_share(msg_size, msg_size);
-		break;
-	default:
-		FAIL("Invalid share_func %#x.\n", share_func);
-		/* Never reached, but needed to keep clang-analyser happy. */
-		return 0;
-	}
-	EXPECT_EQ(ret.func, SPCI_SUCCESS_32);
-	handle = spci_mem_success_handle(ret);
-
-	/*
-	 * Send the appropriate retrieve request to the VM so that it can use it
-	 * to retrieve the memory.
-	 */
-	msg_size = spci_memory_retrieve_request_init(
-		tx_buffer, handle, sender, recipient, 0, 0,
-		retrieve_data_access, retrieve_instruction_access,
-		SPCI_MEMORY_NORMAL_MEM, SPCI_MEMORY_CACHE_WRITE_BACK,
-		SPCI_MEMORY_OUTER_SHAREABLE);
-	EXPECT_EQ(spci_msg_send(sender, recipient, msg_size, 0).func,
-		  SPCI_SUCCESS_32);
-
-	return handle;
-}
-
-/*
- * Use the retrieve request from the receive buffer to retrieve a memory region
- * which has been sent to us. Returns the sender, and the handle via a return
- * parameter.
- */
-spci_vm_id_t retrieve_memory_from_message(void *recv_buf, void *send_buf,
-					  struct spci_value msg_ret,
-					  spci_memory_handle_t *handle)
-{
-	uint32_t msg_size;
-	struct spci_value ret;
-	struct spci_memory_region *memory_region;
-	spci_vm_id_t sender;
-
-	EXPECT_EQ(msg_ret.func, SPCI_MSG_SEND_32);
-	msg_size = spci_msg_send_size(msg_ret);
-	sender = spci_msg_send_sender(msg_ret);
-
-	if (handle != NULL) {
-		struct spci_memory_region *retrieve_request =
-			(struct spci_memory_region *)recv_buf;
-		*handle = retrieve_request->handle;
-	}
-	memcpy_s(send_buf, HF_MAILBOX_SIZE, recv_buf, msg_size);
-	spci_rx_release();
-	ret = spci_mem_retrieve_req(msg_size, msg_size);
-	EXPECT_EQ(ret.func, SPCI_MEM_RETRIEVE_RESP_32);
-	memory_region = (struct spci_memory_region *)recv_buf;
-	EXPECT_EQ(memory_region->receiver_count, 1);
-	EXPECT_EQ(memory_region->receivers[0].receiver_permissions.receiver,
-		  hf_vm_get_id());
-
-	return sender;
-}
-
-/*
- * Use the retrieve request from the receive buffer to retrieve a memory region
- * which has been sent to us, expecting it to fail with the given error code.
- * Returns the sender.
- */
-spci_vm_id_t retrieve_memory_from_message_expect_fail(void *recv_buf,
-						      void *send_buf,
-						      struct spci_value msg_ret,
-						      int32_t expected_error)
-{
-	uint32_t msg_size;
-	struct spci_value ret;
-	spci_vm_id_t sender;
-
-	EXPECT_EQ(msg_ret.func, SPCI_MSG_SEND_32);
-	msg_size = spci_msg_send_size(msg_ret);
-	sender = spci_msg_send_sender(msg_ret);
-
-	memcpy_s(send_buf, HF_MAILBOX_SIZE, recv_buf, msg_size);
-	spci_rx_release();
-	ret = spci_mem_retrieve_req(msg_size, msg_size);
-	EXPECT_SPCI_ERROR(ret, expected_error);
-
-	return sender;
-}