This helps to find out on which CPU we are currently running on.

Signed-off-by: Ralf Ramsauer <[email protected]>
---
 inmates/lib/arm-common/include/inmate.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/inmates/lib/arm-common/include/inmate.h 
b/inmates/lib/arm-common/include/inmate.h
index 3d35f35a..8e3f1e4b 100644
--- a/inmates/lib/arm-common/include/inmate.h
+++ b/inmates/lib/arm-common/include/inmate.h
@@ -39,6 +39,8 @@
 #ifndef _JAILHOUSE_INMATE_H
 #define _JAILHOUSE_INMATE_H
 
+#include <asm/sysregs.h>
+
 typedef signed char s8;
 typedef unsigned char u8;
 
@@ -81,6 +83,14 @@ static inline void cpu_relax(void)
        asm volatile("" : : : "memory");
 }
 
+static inline unsigned long cpu_id(void)
+{
+       unsigned long mpidr;
+
+       arm_read_sysreg(MPIDR_EL1, mpidr);
+       return mpidr & MPIDR_CPUID_MASK;
+}
+
 typedef void (*irq_handler_t)(unsigned int);
 void gic_setup(irq_handler_t handler);
 void gic_enable_irq(unsigned int irq);
-- 
2.14.1

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to