SPCI is now called PSA FF-A.

Change-Id: Iaa10e0449edf5f6493ab21e648219392b17cc5ec
diff --git a/inc/hf/api.h b/inc/hf/api.h
index 07b9061..e56a2d2 100644
--- a/inc/hf/api.h
+++ b/inc/hf/api.h
@@ -21,15 +21,15 @@
 #include "hf/vm.h"
 
 #include "vmapi/hf/call.h"
-#include "vmapi/hf/spci.h"
+#include "vmapi/hf/ffa.h"
 
 void api_init(struct mpool *ppool);
-spci_vm_count_t api_vm_get_count(void);
-spci_vcpu_count_t api_vcpu_get_count(spci_vm_id_t vm_id,
-				     const struct vcpu *current);
+ffa_vm_count_t api_vm_get_count(void);
+ffa_vcpu_count_t api_vcpu_get_count(ffa_vm_id_t vm_id,
+				    const struct vcpu *current);
 void api_regs_state_saved(struct vcpu *vcpu);
 int64_t api_mailbox_writable_get(const struct vcpu *current);
-int64_t api_mailbox_waiter_get(spci_vm_id_t vm_id, const struct vcpu *current);
+int64_t api_mailbox_waiter_get(ffa_vm_id_t vm_id, const struct vcpu *current);
 int64_t api_debug_log(char c, struct vcpu *current);
 
 struct vcpu *api_preempt(struct vcpu *current);
@@ -40,36 +40,35 @@
 
 int64_t api_interrupt_enable(uint32_t intid, bool enable, struct vcpu *current);
 uint32_t api_interrupt_get(struct vcpu *current);
-int64_t api_interrupt_inject(spci_vm_id_t target_vm_id,
-			     spci_vcpu_index_t target_vcpu_idx, uint32_t intid,
+int64_t api_interrupt_inject(ffa_vm_id_t target_vm_id,
+			     ffa_vcpu_index_t target_vcpu_idx, uint32_t intid,
 			     struct vcpu *current, struct vcpu **next);
 
-struct spci_value api_spci_msg_send(spci_vm_id_t sender_vm_id,
-				    spci_vm_id_t receiver_vm_id, uint32_t size,
-				    uint32_t attributes, struct vcpu *current,
-				    struct vcpu **next);
-struct spci_value api_spci_msg_recv(bool block, struct vcpu *current,
-				    struct vcpu **next);
-struct spci_value api_spci_rx_release(struct vcpu *current, struct vcpu **next);
-struct spci_value api_spci_rxtx_map(ipaddr_t send, ipaddr_t recv,
-				    uint32_t page_count, struct vcpu *current,
-				    struct vcpu **next);
+struct ffa_value api_ffa_msg_send(ffa_vm_id_t sender_vm_id,
+				  ffa_vm_id_t receiver_vm_id, uint32_t size,
+				  uint32_t attributes, struct vcpu *current,
+				  struct vcpu **next);
+struct ffa_value api_ffa_msg_recv(bool block, struct vcpu *current,
+				  struct vcpu **next);
+struct ffa_value api_ffa_rx_release(struct vcpu *current, struct vcpu **next);
+struct ffa_value api_ffa_rxtx_map(ipaddr_t send, ipaddr_t recv,
+				  uint32_t page_count, struct vcpu *current,
+				  struct vcpu **next);
 void api_yield(struct vcpu *current, struct vcpu **next);
-struct spci_value api_spci_version(uint32_t requested_version);
-struct spci_value api_spci_id_get(const struct vcpu *current);
-struct spci_value api_spci_features(uint32_t function_id);
-struct spci_value api_spci_run(spci_vm_id_t vm_id, spci_vcpu_index_t vcpu_idx,
-			       const struct vcpu *current, struct vcpu **next);
-struct spci_value api_spci_mem_send(uint32_t share_func, uint32_t length,
-				    uint32_t fragment_length, ipaddr_t address,
-				    uint32_t page_count, struct vcpu *current,
-				    struct vcpu **next);
-struct spci_value api_spci_mem_retrieve_req(uint32_t length,
-					    uint32_t fragment_length,
-					    ipaddr_t address,
-					    uint32_t page_count,
-					    struct vcpu *current);
-struct spci_value api_spci_mem_relinquish(struct vcpu *current);
-struct spci_value api_spci_mem_reclaim(spci_memory_handle_t handle,
-				       spci_memory_region_flags_t flags,
-				       struct vcpu *current);
+struct ffa_value api_ffa_version(uint32_t requested_version);
+struct ffa_value api_ffa_id_get(const struct vcpu *current);
+struct ffa_value api_ffa_features(uint32_t function_id);
+struct ffa_value api_ffa_run(ffa_vm_id_t vm_id, ffa_vcpu_index_t vcpu_idx,
+			     const struct vcpu *current, struct vcpu **next);
+struct ffa_value api_ffa_mem_send(uint32_t share_func, uint32_t length,
+				  uint32_t fragment_length, ipaddr_t address,
+				  uint32_t page_count, struct vcpu *current,
+				  struct vcpu **next);
+struct ffa_value api_ffa_mem_retrieve_req(uint32_t length,
+					  uint32_t fragment_length,
+					  ipaddr_t address, uint32_t page_count,
+					  struct vcpu *current);
+struct ffa_value api_ffa_mem_relinquish(struct vcpu *current);
+struct ffa_value api_ffa_mem_reclaim(ffa_memory_handle_t handle,
+				     ffa_memory_region_flags_t flags,
+				     struct vcpu *current);
diff --git a/inc/hf/arch/cpu.h b/inc/hf/arch/cpu.h
index a7fe5a8..171abaa 100644
--- a/inc/hf/arch/cpu.h
+++ b/inc/hf/arch/cpu.h
@@ -25,7 +25,7 @@
 #include "hf/addr.h"
 #include "hf/vcpu.h"
 
-#include "vmapi/hf/spci.h"
+#include "vmapi/hf/ffa.h"
 
 /**
  * Reset the register values other than the PC and argument which are set with
@@ -48,7 +48,7 @@
  * This function must only be called on an arch_regs that is known not be in use
  * by any other physical CPU.
  */
-void arch_regs_set_retval(struct arch_regs *r, struct spci_value v);
+void arch_regs_set_retval(struct arch_regs *r, struct ffa_value v);
 
 /**
  * Initialize and reset CPU-wide register values.
diff --git a/inc/hf/arch/plat/smc.h b/inc/hf/arch/plat/smc.h
index 29493fc..4d5b9a0 100644
--- a/inc/hf/arch/plat/smc.h
+++ b/inc/hf/arch/plat/smc.h
@@ -16,11 +16,11 @@
 
 #pragma once
 
-#include "vmapi/hf/spci.h"
+#include "vmapi/hf/ffa.h"
 
 /**
  * Called after an SMC has been forwarded. `args` contains the arguments passed
  * to the SMC and `ret` contains the return values that will be set in the vCPU
  * registers after this call returns.
  */
-void plat_smc_post_forward(struct spci_value args, struct spci_value *ret);
+void plat_smc_post_forward(struct ffa_value args, struct ffa_value *ret);
diff --git a/inc/hf/arch/tee.h b/inc/hf/arch/tee.h
index f37fe0b..5cf4f81 100644
--- a/inc/hf/arch/tee.h
+++ b/inc/hf/arch/tee.h
@@ -16,7 +16,7 @@
 
 #pragma once
 
-#include "hf/spci.h"
+#include "hf/ffa.h"
 
 void arch_tee_init(void);
-struct spci_value arch_tee_call(struct spci_value args);
+struct ffa_value arch_tee_call(struct ffa_value args);
diff --git a/inc/hf/dlog.h b/inc/hf/dlog.h
index 5451f85..65b3ac2 100644
--- a/inc/hf/dlog.h
+++ b/inc/hf/dlog.h
@@ -19,7 +19,7 @@
 #include <stdarg.h>
 #include <stddef.h>
 
-#include "hf/spci.h"
+#include "hf/ffa.h"
 
 #define DLOG_BUFFER_SIZE 8192
 
@@ -67,4 +67,4 @@
 #define dlog_verbose(...)
 #endif
 
-void dlog_flush_vm_buffer(spci_vm_id_t id, char buffer[], size_t length);
+void dlog_flush_vm_buffer(ffa_vm_id_t id, char buffer[], size_t length);
diff --git a/inc/hf/spci_internal.h b/inc/hf/ffa_internal.h
similarity index 67%
rename from inc/hf/spci_internal.h
rename to inc/hf/ffa_internal.h
index 1c2ccff..201f04f 100644
--- a/inc/hf/spci_internal.h
+++ b/inc/hf/ffa_internal.h
@@ -18,15 +18,15 @@
 
 #include <stdint.h>
 
-#include "vmapi/hf/spci.h"
+#include "vmapi/hf/ffa.h"
 
-#define SPCI_VERSION_MAJOR 0x1
-#define SPCI_VERSION_MINOR 0x0
+#define FFA_VERSION_MAJOR 0x1
+#define FFA_VERSION_MINOR 0x0
 
-#define SPCI_VERSION_MAJOR_OFFSET 16
-#define SPCI_VERSION_RESERVED_BIT UINT32_C(1U << 31)
+#define FFA_VERSION_MAJOR_OFFSET 16
+#define FFA_VERSION_RESERVED_BIT UINT32_C(1U << 31)
 
-static inline struct spci_value spci_error(uint64_t error_code)
+static inline struct ffa_value ffa_error(uint64_t error_code)
 {
-	return (struct spci_value){.func = SPCI_ERROR_32, .arg2 = error_code};
+	return (struct ffa_value){.func = FFA_ERROR_32, .arg2 = error_code};
 }
diff --git a/inc/hf/ffa_memory.h b/inc/hf/ffa_memory.h
new file mode 100644
index 0000000..c133f76
--- /dev/null
+++ b/inc/hf/ffa_memory.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2019 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.
+ */
+
+#pragma once
+
+#include "hf/mpool.h"
+#include "hf/vm.h"
+
+#include "vmapi/hf/ffa.h"
+
+struct ffa_value ffa_memory_send(struct vm *to, struct vm_locked from_locked,
+				 struct ffa_memory_region *memory_region,
+				 uint32_t memory_share_size,
+				 uint32_t share_func, struct mpool *page_pool);
+struct ffa_value ffa_memory_retrieve(struct vm_locked to_locked,
+				     struct ffa_memory_region *retrieve_request,
+				     uint32_t retrieve_request_size,
+				     struct mpool *page_pool);
+struct ffa_value ffa_memory_relinquish(
+	struct vm_locked from_locked,
+	struct ffa_mem_relinquish *relinquish_request, struct mpool *page_pool);
+struct ffa_value ffa_memory_reclaim(struct vm_locked to_locked,
+				    ffa_memory_handle_t handle, bool clear,
+				    struct mpool *page_pool);
+struct ffa_value ffa_memory_tee_reclaim(struct vm_locked to_locked,
+					ffa_memory_handle_t handle,
+					struct ffa_memory_region *memory_region,
+					bool clear, struct mpool *page_pool);
diff --git a/inc/hf/manifest.h b/inc/hf/manifest.h
index 4c3c5dc..ab3a92f 100644
--- a/inc/hf/manifest.h
+++ b/inc/hf/manifest.h
@@ -16,8 +16,8 @@
 
 #pragma once
 
+#include "hf/ffa.h"
 #include "hf/memiter.h"
-#include "hf/spci.h"
 #include "hf/string.h"
 #include "hf/vm.h"
 
@@ -41,7 +41,7 @@
 		/* Properties specific to secondary VMs. */
 		struct {
 			uint64_t mem_size;
-			spci_vcpu_count_t vcpu_count;
+			ffa_vcpu_count_t vcpu_count;
 		} secondary;
 	};
 };
@@ -50,8 +50,8 @@
  * Hafnium manifest parsed from FDT.
  */
 struct manifest {
-	bool spci_tee_enabled;
-	spci_vm_count_t vm_count;
+	bool ffa_tee_enabled;
+	ffa_vm_count_t vm_count;
 	struct manifest_vm vm[MAX_VMS];
 };
 
diff --git a/inc/hf/spci_memory.h b/inc/hf/spci_memory.h
deleted file mode 100644
index 7b6f086..0000000
--- a/inc/hf/spci_memory.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2019 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.
- */
-
-#pragma once
-
-#include "hf/mpool.h"
-#include "hf/vm.h"
-
-#include "vmapi/hf/spci.h"
-
-struct spci_value spci_memory_send(struct vm *to, struct vm_locked from_locked,
-				   struct spci_memory_region *memory_region,
-				   uint32_t memory_share_size,
-				   uint32_t share_func,
-				   struct mpool *page_pool);
-struct spci_value spci_memory_retrieve(
-	struct vm_locked to_locked, struct spci_memory_region *retrieve_request,
-	uint32_t retrieve_request_size, struct mpool *page_pool);
-struct spci_value spci_memory_relinquish(
-	struct vm_locked from_locked,
-	struct spci_mem_relinquish *relinquish_request,
-	struct mpool *page_pool);
-struct spci_value spci_memory_reclaim(struct vm_locked to_locked,
-				      spci_memory_handle_t handle, bool clear,
-				      struct mpool *page_pool);
-struct spci_value spci_memory_tee_reclaim(
-	struct vm_locked to_locked, spci_memory_handle_t handle,
-	struct spci_memory_region *memory_region, bool clear,
-	struct mpool *page_pool);
diff --git a/inc/hf/vcpu.h b/inc/hf/vcpu.h
index 87d5e8c..397ecff 100644
--- a/inc/hf/vcpu.h
+++ b/inc/hf/vcpu.h
@@ -19,7 +19,7 @@
 #include "hf/addr.h"
 #include "hf/spinlock.h"
 
-#include "vmapi/hf/spci.h"
+#include "vmapi/hf/ffa.h"
 
 /** The number of bits in each element of the interrupt bitfields. */
 #define INTERRUPT_REGISTER_BITS 32
@@ -96,7 +96,7 @@
 void vcpu_unlock(struct vcpu_locked *locked);
 void vcpu_init(struct vcpu *vcpu, struct vm *vm);
 void vcpu_on(struct vcpu_locked vcpu, ipaddr_t entry, uintreg_t arg);
-spci_vcpu_index_t vcpu_index(const struct vcpu *vcpu);
+ffa_vcpu_index_t vcpu_index(const struct vcpu *vcpu);
 bool vcpu_is_off(struct vcpu_locked vcpu);
 bool vcpu_secondary_reset_and_start(struct vcpu *vcpu, ipaddr_t entry,
 				    uintreg_t arg);
diff --git a/inc/hf/vm.h b/inc/hf/vm.h
index 0d7735e..7803d3f 100644
--- a/inc/hf/vm.h
+++ b/inc/hf/vm.h
@@ -25,7 +25,7 @@
 #include "hf/mm.h"
 #include "hf/mpool.h"
 
-#include "vmapi/hf/spci.h"
+#include "vmapi/hf/ffa.h"
 
 #define MAX_SMCS 32
 #define LOG_BUFFER_SIZE 256
@@ -35,10 +35,10 @@
  *
  * EMPTY is the initial state. The follow state transitions are possible:
  * * EMPTY → RECEIVED: message sent to the VM.
- * * RECEIVED → READ: secondary VM returns from SPCI_MSG_WAIT or
- *   SPCI_MSG_POLL, or primary VM returns from SPCI_RUN with an SPCI_MSG_SEND
+ * * RECEIVED → READ: secondary VM returns from FFA_MSG_WAIT or
+ *   FFA_MSG_POLL, or primary VM returns from FFA_RUN with an FFA_MSG_SEND
  *   where the receiver is itself.
- * * READ → EMPTY: VM called SPCI_RX_RELEASE.
+ * * READ → EMPTY: VM called FFA_RX_RELEASE.
  */
 enum mailbox_state {
 	/** There is no message in the mailbox. */
@@ -74,13 +74,13 @@
 	const void *send;
 
 	/** The ID of the VM which sent the message currently in `recv`. */
-	spci_vm_id_t recv_sender;
+	ffa_vm_id_t recv_sender;
 
 	/** The size of the message currently in `recv`. */
 	uint32_t recv_size;
 
 	/**
-	 * The SPCI function ID to use to deliver the message currently in
+	 * The FF-A function ID to use to deliver the message currently in
 	 * `recv`.
 	 */
 	uint32_t recv_func;
@@ -107,12 +107,12 @@
 };
 
 struct vm {
-	spci_vm_id_t id;
+	ffa_vm_id_t id;
 	struct smc_whitelist smc_whitelist;
 
 	/** See api.c for the partial ordering on locks. */
 	struct spinlock lock;
-	spci_vcpu_count_t vcpu_count;
+	ffa_vcpu_count_t vcpu_count;
 	struct vcpu vcpus[MAX_CPUS];
 	struct mm_ptable ptable;
 	struct mailbox mailbox;
@@ -142,18 +142,18 @@
 	struct vm_locked vm2;
 };
 
-struct vm *vm_init(spci_vm_id_t id, spci_vcpu_count_t vcpu_count,
+struct vm *vm_init(ffa_vm_id_t id, ffa_vcpu_count_t vcpu_count,
 		   struct mpool *ppool);
-bool vm_init_next(spci_vcpu_count_t vcpu_count, struct mpool *ppool,
+bool vm_init_next(ffa_vcpu_count_t vcpu_count, struct mpool *ppool,
 		  struct vm **new_vm);
-spci_vm_count_t vm_get_count(void);
-struct vm *vm_find(spci_vm_id_t id);
+ffa_vm_count_t vm_get_count(void);
+struct vm *vm_find(ffa_vm_id_t id);
 struct vm_locked vm_lock(struct vm *vm);
 struct two_vm_locked vm_lock_both(struct vm *vm1, struct vm *vm2);
 void vm_unlock(struct vm_locked *locked);
-struct vcpu *vm_get_vcpu(struct vm *vm, spci_vcpu_index_t vcpu_index);
-struct wait_entry *vm_get_wait_entry(struct vm *vm, spci_vm_id_t for_vm);
-spci_vm_id_t vm_id_for_wait_entry(struct vm *vm, struct wait_entry *entry);
+struct vcpu *vm_get_vcpu(struct vm *vm, ffa_vcpu_index_t vcpu_index);
+struct wait_entry *vm_get_wait_entry(struct vm *vm, ffa_vm_id_t for_vm);
+ffa_vm_id_t vm_id_for_wait_entry(struct vm *vm, struct wait_entry *entry);
 
 bool vm_identity_map(struct vm_locked vm_locked, paddr_t begin, paddr_t end,
 		     uint32_t mode, struct mpool *ppool, ipaddr_t *ipa);