FF-A: implement direct messaging interface

Implement direct messaging ABI for message passing (PSA FF-A EAC spec
sections 4.4, 10.2, 10.3).
In this implementation only the primary VM is allowed to send direct
message requests to secondary VMs. Only secondary VMs are allowed to
reply with direct message responses. When a direct message request is
being serviced, a secondary VM is not allowed to call other FF-A ABIs
that may result in a vCPU switch (e.g. yield, indirect messaging).
A new vCPU field is introduced indicating if a direct message request is
on-going for the corresponding VM.
Per PSA FF-A v1.0, secondary VMs implement the same number of vCPUs as
the number of PEs. A direct message request arrives on the same vCPU
index as the originating vCPU index which emitted the request.
A direct message request sent from the primary VM or a direct message
response sent from a secondary VM blocks the corresponding vCPU.

Change-Id: Iae6f76d82e91253b6685b3d5fe0d087d3cf7e242
Signed-off-by: Jose Marinho <jose.marinho@arm.com>
Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
diff --git a/inc/vmapi/hf/call.h b/inc/vmapi/hf/call.h
index 71f579f..900a74e 100644
--- a/inc/vmapi/hf/call.h
+++ b/inc/vmapi/hf/call.h
@@ -354,3 +354,33 @@
 	return ffa_call((struct ffa_value){.func = FFA_FEATURES_32,
 					   .arg1 = function_id});
 }
+
+static inline struct ffa_value ffa_msg_send_direct_req(
+	ffa_vm_id_t sender_vm_id, ffa_vm_id_t target_vm_id, uint32_t arg3,
+	uint32_t arg4, uint32_t arg5, uint32_t arg6, uint32_t arg7)
+{
+	return ffa_call((struct ffa_value){
+		.func = FFA_MSG_SEND_DIRECT_REQ_32,
+		.arg1 = ((uint64_t)sender_vm_id << 16) | target_vm_id,
+		.arg3 = arg3,
+		.arg4 = arg4,
+		.arg5 = arg5,
+		.arg6 = arg6,
+		.arg7 = arg7,
+	});
+}
+
+static inline struct ffa_value ffa_msg_send_direct_resp(
+	ffa_vm_id_t sender_vm_id, ffa_vm_id_t target_vm_id, uint32_t arg3,
+	uint32_t arg4, uint32_t arg5, uint32_t arg6, uint32_t arg7)
+{
+	return ffa_call((struct ffa_value){
+		.func = FFA_MSG_SEND_DIRECT_RESP_32,
+		.arg1 = ((uint64_t)sender_vm_id << 16) | target_vm_id,
+		.arg3 = arg3,
+		.arg4 = arg4,
+		.arg5 = arg5,
+		.arg6 = arg6,
+		.arg7 = arg7,
+	});
+}
diff --git a/inc/vmapi/hf/types.h b/inc/vmapi/hf/types.h
index 14516ef..794dedc 100644
--- a/inc/vmapi/hf/types.h
+++ b/inc/vmapi/hf/types.h
@@ -27,6 +27,8 @@
 
 #endif
 
+#define HF_INVALID_VM_ID 0x7fff
+
 #define HF_HYPERVISOR_VM_ID 0
 
 /**