Implement SPCI_ID_GET, and a convenience wrapper for clients.

Change-Id: Ic85256bc71002380ff16ebc2af8206af00f66654
diff --git a/inc/hf/api.h b/inc/hf/api.h
index 8c6328c..406b620 100644
--- a/inc/hf/api.h
+++ b/inc/hf/api.h
@@ -24,7 +24,6 @@
 #include "vmapi/hf/spci.h"
 
 void api_init(struct mpool *ppool);
-spci_vm_id_t api_vm_get_id(const struct vcpu *current);
 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);
@@ -62,6 +61,7 @@
 				    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);
 struct spci_value api_spci_share_memory(
 	struct vm_locked to_locked, struct vm_locked from_locked,
 	struct spci_memory_region *memory_region, uint32_t memory_to_attributes,
diff --git a/inc/vmapi/hf/call.h b/inc/vmapi/hf/call.h
index b3db3fc..9091875 100644
--- a/inc/vmapi/hf/call.h
+++ b/inc/vmapi/hf/call.h
@@ -24,7 +24,6 @@
 /* clang-format off */
 
 /* TODO: Define constants below according to spec. */
-#define HF_VM_GET_ID            0xff00
 #define HF_VM_GET_COUNT         0xff01
 #define HF_VCPU_GET_COUNT       0xff02
 #define HF_VCPU_RUN             0xff03
@@ -52,9 +51,17 @@
 /**
  * Returns the VM's own ID.
  */
+static inline struct spci_value spci_id_get(void)
+{
+	return spci_call((struct spci_value){.func = SPCI_ID_GET_32});
+}
+
+/**
+ * Returns the VM's own ID.
+ */
 static inline spci_vm_id_t hf_vm_get_id(void)
 {
-	return hf_call(HF_VM_GET_ID, 0, 0, 0);
+	return spci_id_get().arg2;
 }
 
 /**
diff --git a/src/api.c b/src/api.c
index d11b305..5261688 100644
--- a/src/api.c
+++ b/src/api.c
@@ -210,9 +210,10 @@
 /**
  * Returns the ID of the VM.
  */
-spci_vm_id_t api_vm_get_id(const struct vcpu *current)
+struct spci_value api_spci_id_get(const struct vcpu *current)
 {
-	return current->vm->id;
+	return (struct spci_value){.func = SPCI_SUCCESS_32,
+				   .arg2 = current->vm->id};
 }
 
 /**
diff --git a/src/arch/aarch64/hypervisor/handler.c b/src/arch/aarch64/hypervisor/handler.c
index c4719ab..bbb115f 100644
--- a/src/arch/aarch64/hypervisor/handler.c
+++ b/src/arch/aarch64/hypervisor/handler.c
@@ -316,6 +316,9 @@
 	case SPCI_VERSION_32:
 		*args = api_spci_version();
 		return true;
+	case SPCI_ID_GET_32:
+		*args = api_spci_id_get(current());
+		return true;
 	case SPCI_YIELD_32:
 		api_yield(current(), next);
 
@@ -425,10 +428,6 @@
 	}
 
 	switch (args.func) {
-	case HF_VM_GET_ID:
-		vcpu->regs.r[0] = api_vm_get_id(vcpu);
-		break;
-
 	case HF_VM_GET_COUNT:
 		vcpu->regs.r[0] = api_vm_get_count();
 		break;