blob: fbe5cf3ab8dc0db74001a074960e8217b92bcb06 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _ASM_IA64_PERCPU_H
2#define _ASM_IA64_PERCPU_H
3
4/*
5 * Copyright (C) 2002-2003 Hewlett-Packard Co
6 * David Mosberger-Tang <davidm@hpl.hp.com>
7 */
8
9#define PERCPU_ENOUGH_ROOM PERCPU_PAGE_SIZE
10
11#ifdef __ASSEMBLY__
12# define THIS_CPU(var) (per_cpu__##var) /* use this to mark accesses to per-CPU variables... */
13#else /* !__ASSEMBLY__ */
14
Linus Torvalds1da177e2005-04-16 15:20:36 -070015
16#include <linux/threads.h>
17
18#ifdef HAVE_MODEL_SMALL_ATTRIBUTE
19# define __SMALL_ADDR_AREA __attribute__((__model__ (__small__)))
20#else
21# define __SMALL_ADDR_AREA
22#endif
23
24#define DECLARE_PER_CPU(type, name) \
25 extern __SMALL_ADDR_AREA __typeof__(type) per_cpu__##name
26
27/* Separate out the type, so (int[3], foo) works. */
28#define DEFINE_PER_CPU(type, name) \
29 __attribute__((__section__(".data.percpu"))) \
30 __SMALL_ADDR_AREA __typeof__(type) per_cpu__##name
31
32/*
33 * Pretty much a literal copy of asm-generic/percpu.h, except that percpu_modcopy() is an
34 * external routine, to avoid include-hell.
35 */
36#ifdef CONFIG_SMP
37
38extern unsigned long __per_cpu_offset[NR_CPUS];
Ingo Molnara875a692006-07-03 00:24:26 -070039#define per_cpu_offset(x) (__per_cpu_offset(x))
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
41/* Equal to __per_cpu_offset[smp_processor_id()], but faster to access: */
42DECLARE_PER_CPU(unsigned long, local_per_cpu_offset);
43
44#define per_cpu(var, cpu) (*RELOC_HIDE(&per_cpu__##var, __per_cpu_offset[cpu]))
45#define __get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, __ia64_per_cpu_var(local_per_cpu_offset)))
Paul Mackerrasbfe5d832006-06-25 05:47:14 -070046#define __raw_get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, __ia64_per_cpu_var(local_per_cpu_offset)))
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
48extern void percpu_modcopy(void *pcpudst, const void *src, unsigned long size);
49extern void setup_per_cpu_areas (void);
50extern void *per_cpu_init(void);
51
52#else /* ! SMP */
53
Jan Beulich11c80c82005-06-23 00:09:59 -070054#define per_cpu(var, cpu) (*((void)(cpu), &per_cpu__##var))
Linus Torvalds1da177e2005-04-16 15:20:36 -070055#define __get_cpu_var(var) per_cpu__##var
Paul Mackerrasbfe5d832006-06-25 05:47:14 -070056#define __raw_get_cpu_var(var) per_cpu__##var
Linus Torvalds1da177e2005-04-16 15:20:36 -070057#define per_cpu_init() (__phys_per_cpu_start)
58
59#endif /* SMP */
60
61#define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var)
62#define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var)
63
64/*
65 * Be extremely careful when taking the address of this variable! Due to virtual
66 * remapping, it is different from the canonical address returned by __get_cpu_var(var)!
67 * On the positive side, using __ia64_per_cpu_var() instead of __get_cpu_var() is slightly
68 * more efficient.
69 */
70#define __ia64_per_cpu_var(var) (per_cpu__##var)
71
72#endif /* !__ASSEMBLY__ */
73
74#endif /* _ASM_IA64_PERCPU_H */