Introduce typedef for [v]CPU IDs.

Change-Id: I99988988d8ac57c688c5fd52f072357202255f18
diff --git a/inc/hf/arch/cpu.h b/inc/hf/arch/cpu.h
index 384da06..f244a3c 100644
--- a/inc/hf/arch/cpu.h
+++ b/inc/hf/arch/cpu.h
@@ -41,7 +41,7 @@
  * `arch_regs_set_pc_arg()`.
  */
 void arch_regs_reset(struct arch_regs *r, bool is_primary, spci_vm_id_t vm_id,
-		     uint64_t vcpu_id, paddr_t table);
+		     cpu_id_t vcpu_id, paddr_t table);
 
 /**
  * Updates the given registers so that when a vcpu runs, it starts off at the
diff --git a/inc/hf/boot_params.h b/inc/hf/boot_params.h
index 591e353..ee46777 100644
--- a/inc/hf/boot_params.h
+++ b/inc/hf/boot_params.h
@@ -31,7 +31,7 @@
 };
 
 struct boot_params {
-	uint64_t cpu_ids[MAX_CPUS];
+	cpu_id_t cpu_ids[MAX_CPUS];
 	size_t cpu_count;
 	struct mem_range mem_ranges[MAX_MEM_RANGES];
 	size_t mem_ranges_count;
diff --git a/inc/hf/cpu.h b/inc/hf/cpu.h
index ca697e7..d44d68e 100644
--- a/inc/hf/cpu.h
+++ b/inc/hf/cpu.h
@@ -101,7 +101,7 @@
 /* TODO: Update alignment such that cpus are in different cache lines. */
 struct cpu {
 	/** CPU identifier. Doesn't have to be contiguous. */
-	uint64_t id;
+	cpu_id_t id;
 
 	/** Pointer to bottom of the stack. */
 	void *stack_bottom;
@@ -113,12 +113,12 @@
 	bool is_on;
 };
 
-void cpu_module_init(const uint64_t *cpu_ids, size_t count);
+void cpu_module_init(const cpu_id_t *cpu_ids, size_t count);
 
 size_t cpu_index(struct cpu *c);
 bool cpu_on(struct cpu *c, ipaddr_t entry, uintreg_t arg);
 void cpu_off(struct cpu *c);
-struct cpu *cpu_find(uint64_t id);
+struct cpu *cpu_find(cpu_id_t id);
 
 struct vcpu_locked vcpu_lock(struct vcpu *vcpu);
 void vcpu_unlock(struct vcpu_locked *locked);
diff --git a/inc/hf/fdt_handler.h b/inc/hf/fdt_handler.h
index bcb8c8b..49d242e 100644
--- a/inc/hf/fdt_handler.h
+++ b/inc/hf/fdt_handler.h
@@ -26,7 +26,7 @@
 			   struct mpool *ppool);
 bool fdt_unmap(struct mm_stage1_locked stage1_locked, struct fdt_header *fdt,
 	       struct mpool *ppool);
-void fdt_find_cpus(const struct fdt_node *root, uint64_t *cpu_ids,
+void fdt_find_cpus(const struct fdt_node *root, cpu_id_t *cpu_ids,
 		   size_t *cpu_count);
 void fdt_find_memory_ranges(const struct fdt_node *root, struct boot_params *p);
 bool fdt_find_initrd(struct fdt_node *n, paddr_t *begin, paddr_t *end);
diff --git a/src/arch/aarch64/cpu.c b/src/arch/aarch64/cpu.c
index dae0fd8..5993841 100644
--- a/src/arch/aarch64/cpu.c
+++ b/src/arch/aarch64/cpu.c
@@ -48,7 +48,7 @@
 }
 
 void arch_regs_reset(struct arch_regs *r, bool is_primary, spci_vm_id_t vm_id,
-		     uint64_t vcpu_id, paddr_t table)
+		     cpu_id_t vcpu_id, paddr_t table)
 {
 	uintreg_t pc = r->pc;
 	uintreg_t arg = r->r[0];
diff --git a/src/arch/aarch64/hftest/power_mgmt.c b/src/arch/aarch64/hftest/power_mgmt.c
index 97f0a37..7d0893d 100644
--- a/src/arch/aarch64/hftest/power_mgmt.c
+++ b/src/arch/aarch64/hftest/power_mgmt.c
@@ -107,7 +107,7 @@
 /**
  * Returns the power status of the given CPU.
  */
-enum power_status cpu_status(uint64_t cpu_id)
+enum power_status cpu_status(cpu_id_t cpu_id)
 {
 	uint32_t lowest_affinity_level = 0;
 
diff --git a/src/arch/aarch64/hypervisor/psci_handler.c b/src/arch/aarch64/hypervisor/psci_handler.c
index 2736814..5c87589 100644
--- a/src/arch/aarch64/hypervisor/psci_handler.c
+++ b/src/arch/aarch64/hypervisor/psci_handler.c
@@ -228,7 +228,7 @@
  * Convert a PSCI CPU / affinity ID for a secondary VM to the corresponding vCPU
  * index.
  */
-spci_vcpu_index_t vcpu_id_to_index(uint64_t vcpu_id)
+spci_vcpu_index_t vcpu_id_to_index(cpu_id_t vcpu_id)
 {
 	/* For now we use indices as IDs for the purposes of PSCI. */
 	return vcpu_id;
@@ -279,7 +279,7 @@
 		break;
 
 	case PSCI_AFFINITY_INFO: {
-		uint64_t target_affinity = arg0;
+		cpu_id_t target_affinity = arg0;
 		uint32_t lowest_affinity_level = arg1;
 		struct vm *vm = vcpu->vm;
 		struct vcpu_locked target_vcpu;
@@ -326,7 +326,7 @@
 
 	case PSCI_CPU_ON: {
 		/* Parameter names as per PSCI specification. */
-		uint64_t target_cpu = arg0;
+		cpu_id_t target_cpu = arg0;
 		ipaddr_t entry_point_address = ipa_init(arg1);
 		uint64_t context_id = arg2;
 		spci_vcpu_index_t target_vcpu_index =
diff --git a/src/arch/aarch64/inc/hf/arch/types.h b/src/arch/aarch64/inc/hf/arch/types.h
index 980a34c..6e3addc 100644
--- a/src/arch/aarch64/inc/hf/arch/types.h
+++ b/src/arch/aarch64/inc/hf/arch/types.h
@@ -38,6 +38,9 @@
 /** The integer type corresponding to the native register size. */
 typedef uint64_t uintreg_t;
 
+/** The ID of a physical or virtual CPU. */
+typedef uint64_t cpu_id_t;
+
 /**
  * The struct for storing a floating point register.
  *
diff --git a/src/arch/aarch64/inc/hf/arch/vm/power_mgmt.h b/src/arch/aarch64/inc/hf/arch/vm/power_mgmt.h
index 956091f..be8b9b4 100644
--- a/src/arch/aarch64/inc/hf/arch/vm/power_mgmt.h
+++ b/src/arch/aarch64/inc/hf/arch/vm/power_mgmt.h
@@ -21,6 +21,8 @@
 #include <stdint.h>
 #include <stdnoreturn.h>
 
+#include "hf/arch/types.h"
+
 enum power_status {
 	POWER_STATUS_ON,
 	POWER_STATUS_OFF,
@@ -33,4 +35,4 @@
 	       void (*entry)(uintptr_t arg), uintptr_t arg);
 
 noreturn void cpu_stop(void);
-enum power_status cpu_status(uint64_t cpu_id);
+enum power_status cpu_status(cpu_id_t cpu_id);
diff --git a/src/arch/fake/hypervisor/cpu.c b/src/arch/fake/hypervisor/cpu.c
index 8542dbc..f5885fd 100644
--- a/src/arch/fake/hypervisor/cpu.c
+++ b/src/arch/fake/hypervisor/cpu.c
@@ -27,7 +27,7 @@
 }
 
 void arch_regs_reset(struct arch_regs *r, bool is_primary, spci_vm_id_t vm_id,
-		     uint64_t vcpu_id, paddr_t table)
+		     cpu_id_t vcpu_id, paddr_t table)
 {
 	/* TODO */
 	(void)is_primary;
diff --git a/src/arch/fake/inc/hf/arch/types.h b/src/arch/fake/inc/hf/arch/types.h
index e4fda8d..bcf33f3 100644
--- a/src/arch/fake/inc/hf/arch/types.h
+++ b/src/arch/fake/inc/hf/arch/types.h
@@ -34,6 +34,9 @@
 /** The integer corresponding to the native register size. */
 typedef uint64_t uintreg_t;
 
+/** The ID of a physical or virtual CPU. */
+typedef uint32_t cpu_id_t;
+
 /** Arch-specifc information about a VM. */
 struct arch_vm {
 	/* This field is only here because empty structs aren't allowed. */
@@ -43,6 +46,6 @@
 /** Type to represent the register state of a VM.  */
 struct arch_regs {
 	uintreg_t r[5];
-	uintreg_t vcpu_id;
+	cpu_id_t vcpu_id;
 	bool virtual_interrupt;
 };
diff --git a/src/cpu.c b/src/cpu.c
index 802235a..9b44d97 100644
--- a/src/cpu.c
+++ b/src/cpu.c
@@ -50,11 +50,11 @@
 	sl_init(&c->lock);
 }
 
-void cpu_module_init(const uint64_t *cpu_ids, size_t count)
+void cpu_module_init(const cpu_id_t *cpu_ids, size_t count)
 {
 	uint32_t i;
 	uint32_t j;
-	uint64_t boot_cpu_id = cpus[0].id;
+	cpu_id_t boot_cpu_id = cpus[0].id;
 	bool found_boot_cpu = false;
 
 	cpu_count = count;
@@ -68,7 +68,7 @@
 	j = cpu_count;
 	for (i = 0; i < cpu_count; ++i) {
 		struct cpu *c;
-		uint64_t id = cpu_ids[i];
+		cpu_id_t id = cpu_ids[i];
 
 		if (found_boot_cpu || id != boot_cpu_id) {
 			c = &cpus[--j];
@@ -132,7 +132,7 @@
 /**
  * Searches for a CPU based on its id.
  */
-struct cpu *cpu_find(uint64_t id)
+struct cpu *cpu_find(cpu_id_t id)
 {
 	size_t i;
 
diff --git a/src/fdt_handler.c b/src/fdt_handler.c
index a87226e..db8c0ef 100644
--- a/src/fdt_handler.c
+++ b/src/fdt_handler.c
@@ -126,7 +126,7 @@
 	return true;
 }
 
-void fdt_find_cpus(const struct fdt_node *root, uint64_t *cpu_ids,
+void fdt_find_cpus(const struct fdt_node *root, cpu_id_t *cpu_ids,
 		   size_t *cpu_count)
 {
 	struct fdt_node n = *root;