1 #ifndef __PPC64_SYSTEM_H
2 #define __PPC64_SYSTEM_H
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.
11 #include <linux/config.h>
12 #include <linux/compiler.h>
14 #include <asm/processor.h>
15 #include <asm/hw_irq.h>
16 #include <asm/synch.h>
20 * The sync instruction guarantees that all memory accesses initiated
21 * by this processor have been performed (with respect to all other
22 * mechanisms that access memory). The eieio instruction is a barrier
23 * providing an ordering (separately) for (a) cacheable stores and (b)
24 * loads and stores to non-cacheable memory (e.g. I/O devices).
26 * mb() prevents loads and stores being reordered across this point.
27 * rmb() prevents loads being reordered across this point.
28 * wmb() prevents stores being reordered across this point.
29 * read_barrier_depends() prevents data-dependent loads being reordered
30 * across this point (nop on PPC).
32 * We have to use the sync instructions for mb(), since lwsync doesn't
33 * order loads with respect to previous stores. Lwsync is fine for
35 * For wmb(), we use sync since wmb is used in drivers to order
36 * stores to system memory with respect to writes to the device.
37 * However, smp_wmb() can be a lighter-weight eieio barrier on
38 * SMP since it is only used to order updates to system memory.
40 #define mb() __asm__ __volatile__ ("sync" : : : "memory")
41 #define rmb() __asm__ __volatile__ ("lwsync" : : : "memory")
42 #define wmb() __asm__ __volatile__ ("sync" : : : "memory")
43 #define read_barrier_depends() do { } while(0)
45 #define set_mb(var, value) do { var = value; smp_mb(); } while (0)
46 #define set_wmb(var, value) do { var = value; smp_wmb(); } while (0)
50 #define smp_rmb() rmb()
51 #define smp_wmb() eieio()
52 #define smp_read_barrier_depends() read_barrier_depends()
54 #define smp_mb() __asm__ __volatile__("": : :"memory")
55 #define smp_rmb() __asm__ __volatile__("": : :"memory")
56 #define smp_wmb() __asm__ __volatile__("": : :"memory")
57 #define smp_read_barrier_depends() do { } while(0)
58 #endif /* CONFIG_SMP */
64 #ifdef CONFIG_DEBUGGER
66 extern int (*__debugger
)(struct pt_regs
*regs
);
67 extern int (*__debugger_ipi
)(struct pt_regs
*regs
);
68 extern int (*__debugger_bpt
)(struct pt_regs
*regs
);
69 extern int (*__debugger_sstep
)(struct pt_regs
*regs
);
70 extern int (*__debugger_iabr_match
)(struct pt_regs
*regs
);
71 extern int (*__debugger_dabr_match
)(struct pt_regs
*regs
);
72 extern int (*__debugger_fault_handler
)(struct pt_regs
*regs
);
74 #define DEBUGGER_BOILERPLATE(__NAME) \
75 static inline int __NAME(struct pt_regs *regs) \
77 if (unlikely(__ ## __NAME)) \
78 return __ ## __NAME(regs); \
82 DEBUGGER_BOILERPLATE(debugger
)
83 DEBUGGER_BOILERPLATE(debugger_ipi
)
84 DEBUGGER_BOILERPLATE(debugger_bpt
)
85 DEBUGGER_BOILERPLATE(debugger_sstep
)
86 DEBUGGER_BOILERPLATE(debugger_iabr_match
)
87 DEBUGGER_BOILERPLATE(debugger_dabr_match
)
88 DEBUGGER_BOILERPLATE(debugger_fault_handler
)
91 extern void xmon_init(int enable
);
95 static inline int debugger(struct pt_regs
*regs
) { return 0; }
96 static inline int debugger_ipi(struct pt_regs
*regs
) { return 0; }
97 static inline int debugger_bpt(struct pt_regs
*regs
) { return 0; }
98 static inline int debugger_sstep(struct pt_regs
*regs
) { return 0; }
99 static inline int debugger_iabr_match(struct pt_regs
*regs
) { return 0; }
100 static inline int debugger_dabr_match(struct pt_regs
*regs
) { return 0; }
101 static inline int debugger_fault_handler(struct pt_regs
*regs
) { return 0; }
104 extern int set_dabr(unsigned long dabr
);
105 extern void _exception(int signr
, struct pt_regs
*regs
, int code
,
107 extern int fix_alignment(struct pt_regs
*regs
);
108 extern void bad_page_fault(struct pt_regs
*regs
, unsigned long address
,
110 extern void show_regs(struct pt_regs
* regs
);
111 extern void low_hash_fault(struct pt_regs
*regs
, unsigned long address
);
112 extern int die(const char *str
, struct pt_regs
*regs
, long err
);
114 extern int _get_PVR(void);
115 extern void giveup_fpu(struct task_struct
*);
116 extern void disable_kernel_fp(void);
117 extern void flush_fp_to_thread(struct task_struct
*);
118 extern void enable_kernel_fp(void);
119 extern void giveup_altivec(struct task_struct
*);
120 extern void disable_kernel_altivec(void);
121 extern void enable_kernel_altivec(void);
122 extern int emulate_altivec(struct pt_regs
*);
123 extern void cvt_fd(float *from
, double *to
, struct thread_struct
*thread
);
124 extern void cvt_df(double *from
, float *to
, struct thread_struct
*thread
);
126 #ifdef CONFIG_ALTIVEC
127 extern void flush_altivec_to_thread(struct task_struct
*);
129 static inline void flush_altivec_to_thread(struct task_struct
*t
)
134 static inline void flush_spe_to_thread(struct task_struct
*t
)
138 extern int mem_init_done
; /* set on boot once kmalloc can be called */
140 /* EBCDIC -> ASCII conversion for [0-9A-Z] on iSeries */
141 extern unsigned char e2a(unsigned char);
143 extern struct task_struct
*__switch_to(struct task_struct
*,
144 struct task_struct
*);
145 #define switch_to(prev, next, last) ((last) = __switch_to((prev), (next)))
147 struct thread_struct
;
148 extern struct task_struct
* _switch(struct thread_struct
*prev
,
149 struct thread_struct
*next
);
151 extern int powersave_nap
; /* set if nap mode can be used in idle loop */
156 * Changes the memory location '*ptr' to be val and returns
157 * the previous value stored there.
159 * Inline asm pulled from arch/ppc/kernel/misc.S so ppc64
160 * is more like most of the other architectures.
162 static __inline__
unsigned long
163 __xchg_u32(volatile unsigned int *m
, unsigned long val
)
167 __asm__
__volatile__(
169 "1: lwarx %0,0,%3 # __xchg_u32\n\
173 : "=&r" (dummy
), "=m" (*m
)
180 static __inline__
unsigned long
181 __xchg_u64(volatile long *m
, unsigned long val
)
185 __asm__
__volatile__(
187 "1: ldarx %0,0,%3 # __xchg_u64\n\
191 : "=&r" (dummy
), "=m" (*m
)
199 * This function doesn't exist, so you'll get a linker error
200 * if something tries to do an invalid xchg().
202 extern void __xchg_called_with_bad_pointer(void);
204 static __inline__
unsigned long
205 __xchg(volatile void *ptr
, unsigned long x
, unsigned int size
)
209 return __xchg_u32(ptr
, x
);
211 return __xchg_u64(ptr
, x
);
213 __xchg_called_with_bad_pointer();
217 #define xchg(ptr,x) \
219 __typeof__(*(ptr)) _x_ = (x); \
220 (__typeof__(*(ptr))) __xchg((ptr), (unsigned long)_x_, sizeof(*(ptr))); \
223 #define tas(ptr) (xchg((ptr),1))
225 #define __HAVE_ARCH_CMPXCHG 1
227 static __inline__
unsigned long
228 __cmpxchg_u32(volatile unsigned int *p
, unsigned long old
, unsigned long new)
232 __asm__
__volatile__ (
234 "1: lwarx %0,0,%2 # __cmpxchg_u32\n\
242 : "=&r" (prev
), "=m" (*p
)
243 : "r" (p
), "r" (old
), "r" (new), "m" (*p
)
249 static __inline__
unsigned long
250 __cmpxchg_u64(volatile long *p
, unsigned long old
, unsigned long new)
254 __asm__
__volatile__ (
256 "1: ldarx %0,0,%2 # __cmpxchg_u64\n\
264 : "=&r" (prev
), "=m" (*p
)
265 : "r" (p
), "r" (old
), "r" (new), "m" (*p
)
271 /* This function doesn't exist, so you'll get a linker error
272 if something tries to do an invalid cmpxchg(). */
273 extern void __cmpxchg_called_with_bad_pointer(void);
275 static __inline__
unsigned long
276 __cmpxchg(volatile void *ptr
, unsigned long old
, unsigned long new,
281 return __cmpxchg_u32(ptr
, old
, new);
283 return __cmpxchg_u64(ptr
, old
, new);
285 __cmpxchg_called_with_bad_pointer();
289 #define cmpxchg(ptr,o,n)\
290 ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\
291 (unsigned long)(n),sizeof(*(ptr))))
294 * We handle most unaligned accesses in hardware. On the other hand
295 * unaligned DMA can be very expensive on some ppc64 IO chips (it does
296 * powers of 2 writes until it reaches sufficient alignment).
298 * Based on this we disable the IP header alignment in network drivers.
300 #define NET_IP_ALIGN 0
302 #define arch_align_stack(x) (x)
304 extern unsigned long reloc_offset(void);
306 #endif /* __KERNEL__ */
This page took 0.061031 seconds and 5 git commands to generate.