aboutsummaryrefslogtreecommitdiffstats
path: root/xen/include/asm-x86/percpu.h
diff options
context:
space:
mode:
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>2006-04-21 17:35:15 +0100
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>2006-04-21 17:35:15 +0100
commitea608cc36d26fb5b100630b98cbe28555dad8434 (patch)
tree61f68ff13710ba157d8216da7739bc3a1a387b57 /xen/include/asm-x86/percpu.h
parentdadf394db4b56349c0aea6f72e406e5d3e2e80ac (diff)
downloadxen-ea608cc36d26fb5b100630b98cbe28555dad8434.tar.gz
xen-ea608cc36d26fb5b100630b98cbe28555dad8434.tar.bz2
xen-ea608cc36d26fb5b100630b98cbe28555dad8434.zip
Pull the Linux percpu interface into Xen. Implemented for
x86 and used it to eliminate the percpu_ctxt struct from arch/x86/domain.c. Signed-off-by: Keir Fraser <keir@xensource.com>
Diffstat (limited to 'xen/include/asm-x86/percpu.h')
-rw-r--r--xen/include/asm-x86/percpu.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/xen/include/asm-x86/percpu.h b/xen/include/asm-x86/percpu.h
new file mode 100644
index 0000000000..d76206587f
--- /dev/null
+++ b/xen/include/asm-x86/percpu.h
@@ -0,0 +1,20 @@
+#ifndef __X86_PERCPU_H__
+#define __X86_PERCPU_H__
+
+#define PERCPU_SHIFT 12
+#define PERCPU_SIZE (1UL << PERCPU_SHIFT)
+
+/* Separate out the type, so (int[3], foo) works. */
+#define DEFINE_PER_CPU(type, name) \
+ __attribute__((__section__(".data.percpu"))) \
+ __typeof__(type) per_cpu__##name
+
+/* var is in discarded region: offset to particular copy we want */
+#define per_cpu(var, cpu) \
+ (*RELOC_HIDE(&per_cpu__##var, ((unsigned int)(cpu))<<PERCPU_SHIFT))
+#define __get_cpu_var(var) \
+ (per_cpu(var, smp_processor_id()))
+
+#define DECLARE_PER_CPU(type, name) extern __typeof__(type) per_cpu__##name
+
+#endif /* __X86_PERCPU_H__ */