AFS: Use patched rxrpc_kernel_send_data() correctly
[wrt350n-kernel.git] / include / asm-ia64 / system.h
blob91bb8e00066c76b5a59c00fd3f8a4649ba6e7fb7
1 #ifndef _ASM_IA64_SYSTEM_H
2 #define _ASM_IA64_SYSTEM_H
4 /*
5 * System defines. Note that this is included both from .c and .S
6 * files, so it does only defines, not any C code. This is based
7 * on information published in the Processor Abstraction Layer
8 * and the System Abstraction Layer manual.
10 * Copyright (C) 1998-2003 Hewlett-Packard Co
11 * David Mosberger-Tang <davidm@hpl.hp.com>
12 * Copyright (C) 1999 Asit Mallick <asit.k.mallick@intel.com>
13 * Copyright (C) 1999 Don Dugger <don.dugger@intel.com>
16 #include <asm/kregs.h>
17 #include <asm/page.h>
18 #include <asm/pal.h>
19 #include <asm/percpu.h>
21 #define GATE_ADDR RGN_BASE(RGN_GATE)
24 * 0xa000000000000000+2*PERCPU_PAGE_SIZE
25 * - 0xa000000000000000+3*PERCPU_PAGE_SIZE remain unmapped (guard page)
27 #define KERNEL_START (GATE_ADDR+__IA64_UL_CONST(0x100000000))
28 #define PERCPU_ADDR (-PERCPU_PAGE_SIZE)
30 #ifndef __ASSEMBLY__
32 #include <linux/kernel.h>
33 #include <linux/types.h>
35 struct pci_vector_struct {
36 __u16 segment; /* PCI Segment number */
37 __u16 bus; /* PCI Bus number */
38 __u32 pci_id; /* ACPI split 16 bits device, 16 bits function (see section 6.1.1) */
39 __u8 pin; /* PCI PIN (0 = A, 1 = B, 2 = C, 3 = D) */
40 __u32 irq; /* IRQ assigned */
43 extern struct ia64_boot_param {
44 __u64 command_line; /* physical address of command line arguments */
45 __u64 efi_systab; /* physical address of EFI system table */
46 __u64 efi_memmap; /* physical address of EFI memory map */
47 __u64 efi_memmap_size; /* size of EFI memory map */
48 __u64 efi_memdesc_size; /* size of an EFI memory map descriptor */
49 __u32 efi_memdesc_version; /* memory descriptor version */
50 struct {
51 __u16 num_cols; /* number of columns on console output device */
52 __u16 num_rows; /* number of rows on console output device */
53 __u16 orig_x; /* cursor's x position */
54 __u16 orig_y; /* cursor's y position */
55 } console_info;
56 __u64 fpswa; /* physical address of the fpswa interface */
57 __u64 initrd_start;
58 __u64 initrd_size;
59 } *ia64_boot_param;
62 * Macros to force memory ordering. In these descriptions, "previous"
63 * and "subsequent" refer to program order; "visible" means that all
64 * architecturally visible effects of a memory access have occurred
65 * (at a minimum, this means the memory has been read or written).
67 * wmb(): Guarantees that all preceding stores to memory-
68 * like regions are visible before any subsequent
69 * stores and that all following stores will be
70 * visible only after all previous stores.
71 * rmb(): Like wmb(), but for reads.
72 * mb(): wmb()/rmb() combo, i.e., all previous memory
73 * accesses are visible before all subsequent
74 * accesses and vice versa. This is also known as
75 * a "fence."
77 * Note: "mb()" and its variants cannot be used as a fence to order
78 * accesses to memory mapped I/O registers. For that, mf.a needs to
79 * be used. However, we don't want to always use mf.a because (a)
80 * it's (presumably) much slower than mf and (b) mf.a is supported for
81 * sequential memory pages only.
83 #define mb() ia64_mf()
84 #define rmb() mb()
85 #define wmb() mb()
86 #define read_barrier_depends() do { } while(0)
88 #ifdef CONFIG_SMP
89 # define smp_mb() mb()
90 # define smp_rmb() rmb()
91 # define smp_wmb() wmb()
92 # define smp_read_barrier_depends() read_barrier_depends()
93 #else
94 # define smp_mb() barrier()
95 # define smp_rmb() barrier()
96 # define smp_wmb() barrier()
97 # define smp_read_barrier_depends() do { } while(0)
98 #endif
101 * XXX check on this ---I suspect what Linus really wants here is
102 * acquire vs release semantics but we can't discuss this stuff with
103 * Linus just yet. Grrr...
105 #define set_mb(var, value) do { (var) = (value); mb(); } while (0)
107 #define safe_halt() ia64_pal_halt_light() /* PAL_HALT_LIGHT */
110 * The group barrier in front of the rsm & ssm are necessary to ensure
111 * that none of the previous instructions in the same group are
112 * affected by the rsm/ssm.
114 /* For spinlocks etc */
117 * - clearing psr.i is implicitly serialized (visible by next insn)
118 * - setting psr.i requires data serialization
119 * - we need a stop-bit before reading PSR because we sometimes
120 * write a floating-point register right before reading the PSR
121 * and that writes to PSR.mfl
123 #define __local_irq_save(x) \
124 do { \
125 ia64_stop(); \
126 (x) = ia64_getreg(_IA64_REG_PSR); \
127 ia64_stop(); \
128 ia64_rsm(IA64_PSR_I); \
129 } while (0)
131 #define __local_irq_disable() \
132 do { \
133 ia64_stop(); \
134 ia64_rsm(IA64_PSR_I); \
135 } while (0)
137 #define __local_irq_restore(x) ia64_intrin_local_irq_restore((x) & IA64_PSR_I)
139 #ifdef CONFIG_IA64_DEBUG_IRQ
141 extern unsigned long last_cli_ip;
143 # define __save_ip() last_cli_ip = ia64_getreg(_IA64_REG_IP)
145 # define local_irq_save(x) \
146 do { \
147 unsigned long psr; \
149 __local_irq_save(psr); \
150 if (psr & IA64_PSR_I) \
151 __save_ip(); \
152 (x) = psr; \
153 } while (0)
155 # define local_irq_disable() do { unsigned long x; local_irq_save(x); } while (0)
157 # define local_irq_restore(x) \
158 do { \
159 unsigned long old_psr, psr = (x); \
161 local_save_flags(old_psr); \
162 __local_irq_restore(psr); \
163 if ((old_psr & IA64_PSR_I) && !(psr & IA64_PSR_I)) \
164 __save_ip(); \
165 } while (0)
167 #else /* !CONFIG_IA64_DEBUG_IRQ */
168 # define local_irq_save(x) __local_irq_save(x)
169 # define local_irq_disable() __local_irq_disable()
170 # define local_irq_restore(x) __local_irq_restore(x)
171 #endif /* !CONFIG_IA64_DEBUG_IRQ */
173 #define local_irq_enable() ({ ia64_stop(); ia64_ssm(IA64_PSR_I); ia64_srlz_d(); })
174 #define local_save_flags(flags) ({ ia64_stop(); (flags) = ia64_getreg(_IA64_REG_PSR); })
176 #define irqs_disabled() \
177 ({ \
178 unsigned long __ia64_id_flags; \
179 local_save_flags(__ia64_id_flags); \
180 (__ia64_id_flags & IA64_PSR_I) == 0; \
183 #ifdef __KERNEL__
185 #ifdef CONFIG_IA32_SUPPORT
186 # define IS_IA32_PROCESS(regs) (ia64_psr(regs)->is != 0)
187 #else
188 # define IS_IA32_PROCESS(regs) 0
189 struct task_struct;
190 static inline void ia32_save_state(struct task_struct *t __attribute__((unused))){}
191 static inline void ia32_load_state(struct task_struct *t __attribute__((unused))){}
192 #endif
195 * Context switch from one thread to another. If the two threads have
196 * different address spaces, schedule() has already taken care of
197 * switching to the new address space by calling switch_mm().
199 * Disabling access to the fph partition and the debug-register
200 * context switch MUST be done before calling ia64_switch_to() since a
201 * newly created thread returns directly to
202 * ia64_ret_from_syscall_clear_r8.
204 extern struct task_struct *ia64_switch_to (void *next_task);
206 struct task_struct;
208 extern void ia64_save_extra (struct task_struct *task);
209 extern void ia64_load_extra (struct task_struct *task);
211 #ifdef CONFIG_PERFMON
212 DECLARE_PER_CPU(unsigned long, pfm_syst_info);
213 # define PERFMON_IS_SYSWIDE() (__get_cpu_var(pfm_syst_info) & 0x1)
214 #else
215 # define PERFMON_IS_SYSWIDE() (0)
216 #endif
218 #define IA64_HAS_EXTRA_STATE(t) \
219 ((t)->thread.flags & (IA64_THREAD_DBG_VALID|IA64_THREAD_PM_VALID) \
220 || IS_IA32_PROCESS(task_pt_regs(t)) || PERFMON_IS_SYSWIDE())
222 #define __switch_to(prev,next,last) do { \
223 if (IA64_HAS_EXTRA_STATE(prev)) \
224 ia64_save_extra(prev); \
225 if (IA64_HAS_EXTRA_STATE(next)) \
226 ia64_load_extra(next); \
227 ia64_psr(task_pt_regs(next))->dfh = !ia64_is_local_fpu_owner(next); \
228 (last) = ia64_switch_to((next)); \
229 } while (0)
231 #ifdef CONFIG_SMP
233 * In the SMP case, we save the fph state when context-switching away from a thread that
234 * modified fph. This way, when the thread gets scheduled on another CPU, the CPU can
235 * pick up the state from task->thread.fph, avoiding the complication of having to fetch
236 * the latest fph state from another CPU. In other words: eager save, lazy restore.
238 # define switch_to(prev,next,last) do { \
239 if (ia64_psr(task_pt_regs(prev))->mfh && ia64_is_local_fpu_owner(prev)) { \
240 ia64_psr(task_pt_regs(prev))->mfh = 0; \
241 (prev)->thread.flags |= IA64_THREAD_FPH_VALID; \
242 __ia64_save_fpu((prev)->thread.fph); \
244 __switch_to(prev, next, last); \
245 /* "next" in old context is "current" in new context */ \
246 if (unlikely((current->thread.flags & IA64_THREAD_MIGRATION) && \
247 (task_cpu(current) != \
248 task_thread_info(current)->last_cpu))) { \
249 platform_migrate(current); \
250 task_thread_info(current)->last_cpu = task_cpu(current); \
252 } while (0)
253 #else
254 # define switch_to(prev,next,last) __switch_to(prev, next, last)
255 #endif
257 #define __ARCH_WANT_UNLOCKED_CTXSW
258 #define ARCH_HAS_PREFETCH_SWITCH_STACK
259 #define ia64_platform_is(x) (strcmp(x, platform_name) == 0)
261 void cpu_idle_wait(void);
263 #define arch_align_stack(x) (x)
265 void default_idle(void);
267 #endif /* __KERNEL__ */
269 #endif /* __ASSEMBLY__ */
271 #endif /* _ASM_IA64_SYSTEM_H */