aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Deprez <olivier.deprez@arm.com>2020-09-22 15:06:58 +0200
committerOlivier Deprez <olivier.deprez@arm.com>2020-09-28 12:20:47 +0200
commit7d5e55389f7c0d798be1ef4217fa0fac3ef34db8 (patch)
treec40791742a6e6578314d17045cdea54b6a13f814
parent41890ffad4b624404f509f617c9dd2b3f35f41fc (diff)
downloadhafnium-7d5e55389f7c0d798be1ef4217fa0fac3ef34db8.tar.gz
Provide get cpu by index helper
Change-Id: I0d080e7a70bca25c80470e5a5d10c7f800a30d48 Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
-rw-r--r--inc/hf/cpu.h1
-rw-r--r--src/cpu.c8
2 files changed, 9 insertions, 0 deletions
diff --git a/inc/hf/cpu.h b/inc/hf/cpu.h
index c66e5a4f9..25eab3b86 100644
--- a/inc/hf/cpu.h
+++ b/inc/hf/cpu.h
@@ -28,6 +28,7 @@ struct cpu {
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 384814b35..0a3fc6ffa 100644
--- a/src/cpu.c
+++ b/src/cpu.c
@@ -118,6 +118,14 @@ size_t cpu_index(struct cpu *c)
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.
*/