Implement SPCI_RXTX_MAP to replace hf_vm_configure.

Bug: 132421502
Change-Id: I699f412f5090dead6a4c0dbfdc12f40b5aa8fe20
diff --git a/inc/hf/api.h b/inc/hf/api.h
index 91f02b2..292f036 100644
--- a/inc/hf/api.h
+++ b/inc/hf/api.h
@@ -28,8 +28,6 @@
 spci_vcpu_count_t api_vcpu_get_count(spci_vm_id_t vm_id,
 				     const struct vcpu *current);
 void api_regs_state_saved(struct vcpu *vcpu);
-int64_t api_vm_configure(ipaddr_t send, ipaddr_t recv, struct vcpu *current,
-			 struct vcpu **next);
 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_share_memory(spci_vm_id_t vm_id, ipaddr_t addr, size_t size,
@@ -55,6 +53,9 @@
 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);
 void api_yield(struct vcpu *current, struct vcpu **next);
 struct spci_value api_spci_version(void);
 struct spci_value api_spci_id_get(const struct vcpu *current);
diff --git a/inc/vmapi/hf/abi.h b/inc/vmapi/hf/abi.h
index 434c7c9..ac6fe4b 100644
--- a/inc/vmapi/hf/abi.h
+++ b/inc/vmapi/hf/abi.h
@@ -25,17 +25,16 @@
 /* TODO: Define constants below according to spec. */
 #define HF_VM_GET_COUNT                0xff01
 #define HF_VCPU_GET_COUNT              0xff02
-#define HF_VM_CONFIGURE                0xff03
-#define HF_MAILBOX_WRITABLE_GET        0xff04
-#define HF_MAILBOX_WAITER_GET          0xff05
-#define HF_INTERRUPT_ENABLE            0xff06
-#define HF_INTERRUPT_GET               0xff07
-#define HF_INTERRUPT_INJECT            0xff08
-#define HF_SHARE_MEMORY                0xff09
+#define HF_MAILBOX_WRITABLE_GET        0xff03
+#define HF_MAILBOX_WAITER_GET          0xff04
+#define HF_INTERRUPT_ENABLE            0xff05
+#define HF_INTERRUPT_GET               0xff06
+#define HF_INTERRUPT_INJECT            0xff07
+#define HF_SHARE_MEMORY                0xff08
 
 /* Custom SPCI-like calls returned from SPCI_RUN. */
-#define HF_SPCI_RUN_WAIT_FOR_INTERRUPT 0xff0a
-#define HF_SPCI_RUN_WAKE_UP            0xff0b
+#define HF_SPCI_RUN_WAIT_FOR_INTERRUPT 0xff09
+#define HF_SPCI_RUN_WAKE_UP            0xff0a
 
 /* This matches what Trusty and its ATF module currently use. */
 #define HF_DEBUG_LOG            0xbd000000
diff --git a/inc/vmapi/hf/call.h b/inc/vmapi/hf/call.h
index ad12122..6ec1694 100644
--- a/inc/vmapi/hf/call.h
+++ b/inc/vmapi/hf/call.h
@@ -83,14 +83,24 @@
  * shared.
  *
  * Returns:
- *  - -1 on failure.
- *  - 0 on success if no further action is needed.
- *  - 1 if it was called by the primary VM and the primary VM now needs to wake
- *    up or kick waiters.
+ *  - SPCI_ERROR SPCI_INVALID_PARAMETERS if the given addresses are not properly
+ *    aligned or are the same.
+ *  - SPCI_ERROR SPCI_NO_MEMORY if the hypervisor was unable to map the buffers
+ *    due to insuffient page table memory.
+ *  - SPCI_ERROR SPCI_DENIED if the pages are already mapped or are not owned by
+ *    the caller.
+ *  - SPCI_SUCCESS on success if no further action is needed.
+ *  - SPCI_RX_RELEASE if it was called by the primary VM and the primary VM now
+ *    needs to wake up or kick waiters.
  */
-static inline int64_t hf_vm_configure(hf_ipaddr_t send, hf_ipaddr_t recv)
+static inline struct spci_value spci_rxtx_map(hf_ipaddr_t send,
+					      hf_ipaddr_t recv)
 {
-	return hf_call(HF_VM_CONFIGURE, send, recv, 0);
+	return spci_call(
+		(struct spci_value){.func = SPCI_RXTX_MAP_32,
+				    .arg1 = send,
+				    .arg2 = recv,
+				    .arg3 = HF_MAILBOX_SIZE / SPCI_PAGE_SIZE});
 }
 
 /**
diff --git a/inc/vmapi/hf/spci.h b/inc/vmapi/hf/spci.h
index fe8e7df..1c3ae01 100644
--- a/inc/vmapi/hf/spci.h
+++ b/inc/vmapi/hf/spci.h
@@ -73,6 +73,13 @@
 
 #define SPCI_SLEEP_INDEFINITE 0
 
+/**
+ * For use where the SPCI specification refers explicitly to '4K pages'. Not to
+ * be confused with PAGE_SIZE, which is the translation granule Hafnium is
+ * configured to use.
+ */
+#define SPCI_PAGE_SIZE 4096
+
 /* The maximum length possible for a single message. */
 #define SPCI_MSG_PAYLOAD_MAX HF_MAILBOX_SIZE