Provide get cpu by index helper
Change-Id: I0d080e7a70bca25c80470e5a5d10c7f800a30d48
Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
diff --git a/inc/hf/cpu.h b/inc/hf/cpu.h
index c66e5a4..25eab3b 100644
--- a/inc/hf/cpu.h
+++ b/inc/hf/cpu.h
@@ -28,6 +28,7 @@
void cpu_module_init(const cpu_id_t *cpu_ids, size_t count);
size_t cpu_index(struct cpu *c);
+struct cpu *cpu_find_index(size_t index);
bool cpu_on(struct cpu *c, ipaddr_t entry, uintreg_t arg);
void cpu_off(struct cpu *c);
struct cpu *cpu_find(cpu_id_t id);
diff --git a/src/cpu.c b/src/cpu.c
index 384814b..0a3fc6f 100644
--- a/src/cpu.c
+++ b/src/cpu.c
@@ -118,6 +118,14 @@
return c - cpus;
}
+/*
+ * Return cpu with the given index.
+ */
+struct cpu *cpu_find_index(size_t index)
+{
+ return (index < MAX_CPUS) ? &cpus[index] : NULL;
+}
+
/**
* Turns CPU on and returns the previous state.
*/