Add helper functions for VM/vCPU IDs in SPCI calls.

This also changes all calls to encode VM IDs in high bits, vCPU index in
low bits. This is inconsistent with the current spec but is what we
expect it to be corrected to in the next draft.

Change-Id: I3da130b9070c6c43856509ba80b532e7e8c263e0
diff --git a/inc/vmapi/hf/abi.h b/inc/vmapi/hf/abi.h
index 9423442..bdb6705 100644
--- a/inc/vmapi/hf/abi.h
+++ b/inc/vmapi/hf/abi.h
@@ -62,13 +62,3 @@
 	 */
 	HF_MEMORY_SHARE,
 };
-
-static inline spci_vm_id_t wake_up_get_vm_id(struct spci_value v)
-{
-	return v.arg1 & 0xffff;
-}
-
-static inline spci_vcpu_index_t wake_up_get_vcpu(struct spci_value v)
-{
-	return (v.arg1 >> 16) & 0xffff;
-}
diff --git a/inc/vmapi/hf/call.h b/inc/vmapi/hf/call.h
index 94f70e8..d446754 100644
--- a/inc/vmapi/hf/call.h
+++ b/inc/vmapi/hf/call.h
@@ -66,7 +66,7 @@
 					 spci_vcpu_index_t vcpu_idx)
 {
 	return spci_call((struct spci_value){.func = SPCI_RUN_32,
-					     (uint32_t)vm_id << 16 | vcpu_idx});
+					     spci_vm_vcpu(vm_id, vcpu_idx)});
 }
 
 /**
diff --git a/inc/vmapi/hf/spci.h b/inc/vmapi/hf/spci.h
index d5d55ff..fe8e7df 100644
--- a/inc/vmapi/hf/spci.h
+++ b/inc/vmapi/hf/spci.h
@@ -207,6 +207,22 @@
 	return args.arg4;
 }
 
+static inline spci_vm_id_t spci_vm_id(struct spci_value args)
+{
+	return (args.arg1 >> 16) & 0xffff;
+}
+
+static inline spci_vcpu_index_t spci_vcpu_index(struct spci_value args)
+{
+	return args.arg1 & 0xffff;
+}
+
+static inline uint64_t spci_vm_vcpu(spci_vm_id_t vm_id,
+				    spci_vcpu_index_t vcpu_index)
+{
+	return ((uint32_t)vm_id << 16) | vcpu_index;
+}
+
 struct spci_architected_message_header {
 	uint16_t type;