1 #ifndef __ARM_PERCPU_H__
2 #define __ARM_PERCPU_H__
3 
4 #ifndef __ASSEMBLY__
5 
6 #include <xen/types.h>
7 #if defined(CONFIG_ARM_32)
8 # include <asm/arm32/processor.h>
9 #elif defined(CONFIG_ARM_64)
10 # include <asm/arm64/processor.h>
11 #else
12 # error "unknown ARM variant"
13 #endif
14 
15 extern char __per_cpu_start[], __per_cpu_data_end[];
16 extern unsigned long __per_cpu_offset[NR_CPUS];
17 void percpu_init_areas(void);
18 
19 /* Separate out the type, so (int[3], foo) works. */
20 #define __DEFINE_PER_CPU(type, name, suffix)                    \
21     __section(".bss.percpu" #suffix)                            \
22     __typeof__(type) per_cpu_##name
23 
24 #define per_cpu(var, cpu)  \
25     (*RELOC_HIDE(&per_cpu__##var, __per_cpu_offset[cpu]))
26 #define __get_cpu_var(var) \
27     (*RELOC_HIDE(&per_cpu__##var, READ_SYSREG(TPIDR_EL2)))
28 
29 #define per_cpu_ptr(var, cpu)  \
30     (*RELOC_HIDE(var, __per_cpu_offset[cpu]))
31 #define __get_cpu_ptr(var) \
32     (*RELOC_HIDE(var, READ_SYSREG(TPIDR_EL2)))
33 
34 #define DECLARE_PER_CPU(type, name) extern __typeof__(type) per_cpu__##name
35 
36 DECLARE_PER_CPU(unsigned int, cpu_id);
37 #define get_processor_id()    (this_cpu(cpu_id))
38 #define set_processor_id(id)  do {                      \
39     WRITE_SYSREG(__per_cpu_offset[id], TPIDR_EL2);      \
40     this_cpu(cpu_id) = (id);                            \
41 } while(0)
42 #endif
43 
44 #endif /* __ARM_PERCPU_H__ */
45 /*
46  * Local variables:
47  * mode: C
48  * c-file-style: "BSD"
49  * c-basic-offset: 4
50  * indent-tabs-mode: nil
51  * End:
52  */
53