blob: 408d60b4f75bc779a5bf356d13c1624ba209ce25 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __ARCH_S390_PERCPU__
2#define __ARCH_S390_PERCPU__
3
4#include <linux/compiler.h>
5#include <asm/lowcore.h>
6
Linus Torvalds1da177e2005-04-16 15:20:36 -07007/*
8 * s390 uses its own implementation for per cpu data, the offset of
9 * the cpu local data area is cached in the cpu's lowcore memory.
10 * For 64 bit module code s390 forces the use of a GOT slot for the
11 * address of the per cpu variable. This is needed because the module
12 * may be more than 4G above the per cpu area.
13 */
14#if defined(__s390x__) && defined(MODULE)
15
travis@sgi.comf0343472008-01-30 23:27:58 +010016#define SHIFT_PERCPU_PTR(ptr,offset) (({ \
Jan Bluncka666ecf2006-10-06 00:43:58 -070017 extern int simple_identifier_##var(void); \
Jan Blunck632bbfe2006-09-25 23:30:53 -070018 unsigned long *__ptr; \
travis@sgi.comf0343472008-01-30 23:27:58 +010019 asm ( "larl %0, %1@GOTENT" \
20 : "=a" (__ptr) : "X" (ptr) ); \
21 (typeof(ptr))((*__ptr) + (offset)); }))
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
23#else
24
travis@sgi.comf0343472008-01-30 23:27:58 +010025#define SHIFT_PERCPU_PTR(ptr, offset) (({ \
Jan Bluncka666ecf2006-10-06 00:43:58 -070026 extern int simple_identifier_##var(void); \
Jan Blunck632bbfe2006-09-25 23:30:53 -070027 unsigned long __ptr; \
travis@sgi.comf0343472008-01-30 23:27:58 +010028 asm ( "" : "=a" (__ptr) : "0" (ptr) ); \
29 (typeof(ptr)) (__ptr + (offset)); }))
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
31#endif
32
travis@sgi.comf0343472008-01-30 23:27:58 +010033#define __my_cpu_offset S390_lowcore.percpu_offset
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
travis@sgi.comf0343472008-01-30 23:27:58 +010035#include <asm-generic/percpu.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
Linus Torvalds1da177e2005-04-16 15:20:36 -070037#endif /* __ARCH_S390_PERCPU__ */