]> rtime.felk.cvut.cz Git - jailhouse.git/blob - hypervisor/arch/arm/lib.c
arm: psci: support multiple affinity levels in MPIDR
[jailhouse.git] / hypervisor / arch / arm / lib.c
1 /*
2  * Jailhouse, a Linux-based partitioning hypervisor
3  *
4  * Copyright (c) ARM Limited, 2014
5  *
6  * Authors:
7  *  Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
8  *
9  * This work is licensed under the terms of the GNU GPL, version 2.  See
10  * the COPYING file in the top-level directory.
11  */
12
13 #include <jailhouse/control.h>
14 #include <jailhouse/processor.h>
15 #include <jailhouse/string.h>
16 #include <jailhouse/types.h>
17 #include <asm/control.h>
18 #include <asm/percpu.h>
19 #include <asm/sysregs.h>
20
21 unsigned long phys_processor_id(void)
22 {
23         unsigned long mpidr;
24
25         arm_read_sysreg(MPIDR_EL1, mpidr);
26         return mpidr & MPIDR_CPUID_MASK;
27 }
28
29 unsigned int arm_cpu_by_mpidr(struct cell *cell, unsigned long mpidr)
30 {
31         unsigned int cpu;
32
33         for_each_cpu(cpu, cell->cpu_set)
34                 if (mpidr == (per_cpu(cpu)->mpidr & MPIDR_CPUID_MASK))
35                         return cpu;
36
37         return -1;
38 }