SPCI: Introduce SPCI_MSG_SEND.

Morph the vmapi service HF_MAILBOX_SEND onto SPCI_MSG_SEND.
The current SPCI_MSG_SEND only allows for implementation defined
messages to be exchanged between VMs.

The new SPCI service returns SPCI_SUCCESS if message is delivered or one
of the following error codes:
        SPCI_INVALID_PARAMETER: one of the parameters in the header does
        not conform;
        SPCI_BUSY: the mailbox was full or the target VM does not exist.

Adapted the tests to this new service.
Added tests specific to spci_message_init and spci_msg_send.

Change-Id: I55adfe68502ddc7bf864432f3e567b6cfe785f92
diff --git a/inc/hf/api.h b/inc/hf/api.h
index 4604123..e588575 100644
--- a/inc/hf/api.h
+++ b/inc/hf/api.h
@@ -32,8 +32,6 @@
 				       struct vcpu **next);
 int64_t api_vm_configure(ipaddr_t send, ipaddr_t recv, struct vcpu *current,
 			 struct vcpu **next);
-int64_t api_mailbox_send(uint32_t vm_id, size_t size, bool notify,
-			 struct vcpu *current, struct vcpu **next);
 struct hf_mailbox_receive_return api_mailbox_receive(bool block,
 						     struct vcpu *current,
 						     struct vcpu **next);
@@ -53,3 +51,6 @@
 int64_t api_interrupt_inject(uint32_t target_vm_id, uint32_t target_vcpu_idx,
 			     uint32_t intid, struct vcpu *current,
 			     struct vcpu **next);
+
+int32_t api_spci_msg_send(uint32_t attributes, struct vcpu *current,
+			  struct vcpu **next);
diff --git a/inc/hf/vm.h b/inc/hf/vm.h
index b3b7492..069a265 100644
--- a/inc/hf/vm.h
+++ b/inc/hf/vm.h
@@ -22,6 +22,7 @@
 #include "hf/list.h"
 #include "hf/mm.h"
 #include "hf/mpool.h"
+#include "hf/spci.h"
 
 enum mailbox_state {
 	/** There is no message in the mailbox. */
@@ -55,8 +56,8 @@
 	enum mailbox_state state;
 	uint32_t recv_from_id;
 	int16_t recv_bytes;
-	void *recv;
-	const void *send;
+	struct spci_message *recv;
+	const struct spci_message *send;
 
 	/**
 	 * List of wait_entry structs representing VMs that want to be notified
diff --git a/inc/vmapi/hf/call.h b/inc/vmapi/hf/call.h
index 5c8b1c6..8bc9627 100644
--- a/inc/vmapi/hf/call.h
+++ b/inc/vmapi/hf/call.h
@@ -17,6 +17,7 @@
 #pragma once
 
 #include "hf/abi.h"
+#include "hf/spci.h"
 #include "hf/types.h"
 
 /* Keep macro alignment */
@@ -29,7 +30,6 @@
 #define HF_VCPU_RUN             0xff03
 #define HF_VCPU_YIELD           0xff04
 #define HF_VM_CONFIGURE         0xff05
-#define HF_MAILBOX_SEND         0xff06
 #define HF_MAILBOX_RECEIVE      0xff07
 #define HF_MAILBOX_CLEAR        0xff08
 #define HF_MAILBOX_WRITABLE_GET 0xff09
@@ -115,11 +115,14 @@
  * If the recipient's receive buffer is busy, it can optionally register the
  * caller to be notified when the recipient's receive buffer becomes available.
  *
- * Returns -1 on failure and 0 on success.
+ * Returns SPCI_SUCCESS if the message is sent, an error code otherwise:
+ *  - INVALID_PARAMETER: one or more of the parameters do not conform.
+ *  - BUSY: the message could not be delivered either because the mailbox
+ *            was full or the target VM does not yet exist.
  */
-static inline int64_t hf_mailbox_send(uint32_t vm_id, size_t size, bool notify)
+static inline int64_t spci_msg_send(uint32_t attributes)
 {
-	return hf_call(HF_MAILBOX_SEND, vm_id, size, notify);
+	return hf_call(SPCI_MSG_SEND_32, attributes, 0, 0);
 }
 
 /**