diff options
author | Olivier Deprez <olivier.deprez@arm.com> | 2020-09-22 15:06:58 +0200 |
---|---|---|
committer | Olivier Deprez <olivier.deprez@arm.com> | 2020-09-28 12:20:47 +0200 |
commit | 7d5e55389f7c0d798be1ef4217fa0fac3ef34db8 (patch) | |
tree | c40791742a6e6578314d17045cdea54b6a13f814 | |
parent | 41890ffad4b624404f509f617c9dd2b3f35f41fc (diff) | |
download | hafnium-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.h | 1 | ||||
-rw-r--r-- | src/cpu.c | 8 |
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); @@ -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. */ |