2005-04-17 06:20:36 +08:00
|
|
|
#ifndef __ASM_ARM_SYSTEM_H
|
|
|
|
#define __ASM_ARM_SYSTEM_H
|
|
|
|
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
|
|
|
|
#define CPU_ARCH_UNKNOWN 0
|
|
|
|
#define CPU_ARCH_ARMv3 1
|
|
|
|
#define CPU_ARCH_ARMv4 2
|
|
|
|
#define CPU_ARCH_ARMv4T 3
|
|
|
|
#define CPU_ARCH_ARMv5 4
|
|
|
|
#define CPU_ARCH_ARMv5T 5
|
|
|
|
#define CPU_ARCH_ARMv5TE 6
|
|
|
|
#define CPU_ARCH_ARMv5TEJ 7
|
|
|
|
#define CPU_ARCH_ARMv6 8
|
2007-05-09 05:27:46 +08:00
|
|
|
#define CPU_ARCH_ARMv7 9
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This is used to ensure the compiler did actually allocate the register we
|
|
|
|
* asked it for some inline assembly sequences. Apparently we can't trust
|
|
|
|
* the compiler from one version to another so a bit of paranoia won't hurt.
|
|
|
|
* This string is meant to be concatenated with the inline asm string and
|
|
|
|
* will cause compilation to stop on mismatch.
|
|
|
|
* (for details, see gcc PR 15089)
|
|
|
|
*/
|
|
|
|
#define __asmeq(x, y) ".ifnc " x "," y " ; .err ; .endif\n\t"
|
|
|
|
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
|
2011-08-20 00:58:35 +08:00
|
|
|
#include <linux/compiler.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/linkage.h>
|
2006-12-18 08:12:47 +08:00
|
|
|
#include <linux/irqflags.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-03-24 23:49:54 +08:00
|
|
|
#include <asm/outercache.h>
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
struct thread_info;
|
|
|
|
struct task_struct;
|
|
|
|
|
|
|
|
/* information about the system we're running on */
|
|
|
|
extern unsigned int system_rev;
|
|
|
|
extern unsigned int system_serial_low;
|
|
|
|
extern unsigned int system_serial_high;
|
|
|
|
extern unsigned int mem_fclk_21285;
|
|
|
|
|
|
|
|
struct pt_regs;
|
|
|
|
|
2010-01-21 01:02:54 +08:00
|
|
|
void die(const char *msg, struct pt_regs *regs, int err);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-06-30 18:06:49 +08:00
|
|
|
struct siginfo;
|
2007-05-08 15:27:03 +08:00
|
|
|
void arm_notify_die(const char *str, struct pt_regs *regs, struct siginfo *info,
|
2005-06-30 18:06:49 +08:00
|
|
|
unsigned long err, unsigned long trap);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2011-11-23 01:30:31 +08:00
|
|
|
#ifdef CONFIG_ARM_LPAE
|
|
|
|
#define FAULT_CODE_ALIGNMENT 33
|
|
|
|
#define FAULT_CODE_DEBUG 34
|
|
|
|
#else
|
|
|
|
#define FAULT_CODE_ALIGNMENT 1
|
|
|
|
#define FAULT_CODE_DEBUG 2
|
|
|
|
#endif
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
void hook_fault_code(int nr, int (*fn)(unsigned long, unsigned int,
|
|
|
|
struct pt_regs *),
|
2010-07-22 20:18:19 +08:00
|
|
|
int sig, int code, const char *name);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-09-03 17:39:59 +08:00
|
|
|
void hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int,
|
|
|
|
struct pt_regs *),
|
|
|
|
int sig, int code, const char *name);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#define xchg(ptr,x) \
|
|
|
|
((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
|
|
|
|
|
2005-04-17 22:50:36 +08:00
|
|
|
extern asmlinkage void c_backtrace(unsigned long fp, int pmode);
|
2005-11-17 02:36:49 +08:00
|
|
|
|
|
|
|
struct mm_struct;
|
2005-04-17 22:50:36 +08:00
|
|
|
extern void show_pte(struct mm_struct *mm, unsigned long addr);
|
|
|
|
extern void __show_regs(struct pt_regs *);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2011-08-20 00:58:35 +08:00
|
|
|
extern int __pure cpu_architecture(void);
|
2005-06-20 01:39:33 +08:00
|
|
|
extern void cpu_init(void);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2011-11-01 21:16:26 +08:00
|
|
|
void soft_restart(unsigned long);
|
2009-03-20 00:20:24 +08:00
|
|
|
extern void (*arm_pm_restart)(char str, const char *cmd);
|
2006-06-20 02:57:12 +08:00
|
|
|
|
2007-02-05 21:48:02 +08:00
|
|
|
#define UDBG_UNDEFINED (1 << 0)
|
|
|
|
#define UDBG_SYSCALL (1 << 1)
|
|
|
|
#define UDBG_BADABORT (1 << 2)
|
|
|
|
#define UDBG_SEGV (1 << 3)
|
|
|
|
#define UDBG_BUS (1 << 4)
|
|
|
|
|
|
|
|
extern unsigned int user_debug;
|
|
|
|
|
2010-12-23 18:32:41 +08:00
|
|
|
#if __LINUX_ARM_ARCH__ >= 7 || \
|
|
|
|
(__LINUX_ARM_ARCH__ == 6 && defined(CONFIG_CPU_32v6K))
|
|
|
|
#define sev() __asm__ __volatile__ ("sev" : : : "memory")
|
|
|
|
#define wfe() __asm__ __volatile__ ("wfe" : : : "memory")
|
|
|
|
#define wfi() __asm__ __volatile__ ("wfi" : : : "memory")
|
|
|
|
#endif
|
|
|
|
|
2007-05-09 05:53:44 +08:00
|
|
|
#if __LINUX_ARM_ARCH__ >= 7
|
|
|
|
#define isb() __asm__ __volatile__ ("isb" : : : "memory")
|
|
|
|
#define dsb() __asm__ __volatile__ ("dsb" : : : "memory")
|
|
|
|
#define dmb() __asm__ __volatile__ ("dmb" : : : "memory")
|
|
|
|
#elif defined(CONFIG_CPU_XSC3) || __LINUX_ARM_ARCH__ == 6
|
2007-02-05 21:48:02 +08:00
|
|
|
#define isb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c5, 4" \
|
|
|
|
: : "r" (0) : "memory")
|
|
|
|
#define dsb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 4" \
|
|
|
|
: : "r" (0) : "memory")
|
|
|
|
#define dmb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" \
|
|
|
|
: : "r" (0) : "memory")
|
2009-03-25 19:10:01 +08:00
|
|
|
#elif defined(CONFIG_CPU_FA526)
|
|
|
|
#define isb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c5, 4" \
|
|
|
|
: : "r" (0) : "memory")
|
|
|
|
#define dsb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 4" \
|
|
|
|
: : "r" (0) : "memory")
|
|
|
|
#define dmb() __asm__ __volatile__ ("" : : : "memory")
|
2007-02-05 21:48:02 +08:00
|
|
|
#else
|
|
|
|
#define isb() __asm__ __volatile__ ("" : : : "memory")
|
|
|
|
#define dsb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 4" \
|
|
|
|
: : "r" (0) : "memory")
|
|
|
|
#define dmb() __asm__ __volatile__ ("" : : : "memory")
|
|
|
|
#endif
|
2007-02-28 19:30:38 +08:00
|
|
|
|
2010-03-24 23:49:54 +08:00
|
|
|
#ifdef CONFIG_ARCH_HAS_BARRIERS
|
|
|
|
#include <mach/barriers.h>
|
2010-05-18 00:24:04 +08:00
|
|
|
#elif defined(CONFIG_ARM_DMA_MEM_BUFFERABLE) || defined(CONFIG_SMP)
|
2010-03-24 23:49:54 +08:00
|
|
|
#define mb() do { dsb(); outer_sync(); } while (0)
|
2011-04-06 23:18:47 +08:00
|
|
|
#define rmb() dsb()
|
2010-03-24 23:49:54 +08:00
|
|
|
#define wmb() mb()
|
2009-11-21 05:06:43 +08:00
|
|
|
#else
|
2011-01-03 09:26:53 +08:00
|
|
|
#include <asm/memory.h>
|
2007-03-31 19:03:20 +08:00
|
|
|
#define mb() do { if (arch_is_coherent()) dmb(); else barrier(); } while (0)
|
|
|
|
#define rmb() do { if (arch_is_coherent()) dmb(); else barrier(); } while (0)
|
|
|
|
#define wmb() do { if (arch_is_coherent()) dmb(); else barrier(); } while (0)
|
2009-11-21 05:06:43 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CONFIG_SMP
|
2007-03-31 19:03:20 +08:00
|
|
|
#define smp_mb() barrier()
|
|
|
|
#define smp_rmb() barrier()
|
|
|
|
#define smp_wmb() barrier()
|
2007-02-28 19:30:38 +08:00
|
|
|
#else
|
2010-03-24 23:49:54 +08:00
|
|
|
#define smp_mb() dmb()
|
|
|
|
#define smp_rmb() dmb()
|
|
|
|
#define smp_wmb() dmb()
|
2007-03-31 19:03:20 +08:00
|
|
|
#endif
|
2009-11-21 05:06:43 +08:00
|
|
|
|
2007-03-31 19:03:20 +08:00
|
|
|
#define read_barrier_depends() do { } while(0)
|
|
|
|
#define smp_read_barrier_depends() do { } while(0)
|
2007-02-28 19:30:38 +08:00
|
|
|
|
|
|
|
#define set_mb(var, value) do { var = value; smp_mb(); } while (0)
|
2007-02-05 21:48:02 +08:00
|
|
|
#define nop() __asm__ __volatile__("mov\tr0,r0\t@ nop\n\t");
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
2005-06-26 05:57:23 +08:00
|
|
|
* switch_mm() may do a full cache flush over the context switch,
|
|
|
|
* so enable interrupts over the context switch to avoid high
|
|
|
|
* latency.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
2005-06-26 05:57:23 +08:00
|
|
|
#define __ARCH_WANT_INTERRUPTS_ON_CTXSW
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* switch_to(prev, next) should switch from task `prev' to `next'
|
|
|
|
* `prev' will never be the same as `next'. schedule() itself
|
|
|
|
* contains the memory barrier to tell GCC not to cache `current'.
|
|
|
|
*/
|
|
|
|
extern struct task_struct *__switch_to(struct task_struct *, struct thread_info *, struct thread_info *);
|
|
|
|
|
|
|
|
#define switch_to(prev,next,last) \
|
|
|
|
do { \
|
2006-01-12 17:05:56 +08:00
|
|
|
last = __switch_to(prev,task_thread_info(prev), task_thread_info(next)); \
|
2005-04-17 06:20:36 +08:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#if defined(CONFIG_CPU_SA1100) || defined(CONFIG_CPU_SA110)
|
|
|
|
/*
|
|
|
|
* On the StrongARM, "swp" is terminally broken since it bypasses the
|
|
|
|
* cache totally. This means that the cache becomes inconsistent, and,
|
|
|
|
* since we use normal loads/stores as well, this is really bad.
|
|
|
|
* Typically, this causes oopsen in filp_close, but could have other,
|
2011-03-31 09:57:33 +08:00
|
|
|
* more disastrous effects. There are two work-arounds:
|
2005-04-17 06:20:36 +08:00
|
|
|
* 1. Disable interrupts and emulate the atomic swap
|
|
|
|
* 2. Clean the cache, perform atomic swap, flush the cache
|
|
|
|
*
|
|
|
|
* We choose (1) since its the "easiest" to achieve here and is not
|
|
|
|
* dependent on the processor type.
|
2005-06-29 02:22:25 +08:00
|
|
|
*
|
|
|
|
* NOTE that this solution won't work on an SMP system, so explcitly
|
|
|
|
* forbid it here.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
#define swp_is_buggy
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size)
|
|
|
|
{
|
|
|
|
extern void __bad_xchg(volatile void *, int);
|
|
|
|
unsigned long ret;
|
|
|
|
#ifdef swp_is_buggy
|
|
|
|
unsigned long flags;
|
|
|
|
#endif
|
2005-07-27 02:39:31 +08:00
|
|
|
#if __LINUX_ARM_ARCH__ >= 6
|
|
|
|
unsigned int tmp;
|
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-05-26 03:58:00 +08:00
|
|
|
smp_mb();
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
switch (size) {
|
2005-07-27 02:39:31 +08:00
|
|
|
#if __LINUX_ARM_ARCH__ >= 6
|
|
|
|
case 1:
|
|
|
|
asm volatile("@ __xchg1\n"
|
|
|
|
"1: ldrexb %0, [%3]\n"
|
|
|
|
" strexb %1, %2, [%3]\n"
|
|
|
|
" teq %1, #0\n"
|
|
|
|
" bne 1b"
|
|
|
|
: "=&r" (ret), "=&r" (tmp)
|
|
|
|
: "r" (x), "r" (ptr)
|
|
|
|
: "memory", "cc");
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
asm volatile("@ __xchg4\n"
|
|
|
|
"1: ldrex %0, [%3]\n"
|
|
|
|
" strex %1, %2, [%3]\n"
|
|
|
|
" teq %1, #0\n"
|
|
|
|
" bne 1b"
|
|
|
|
: "=&r" (ret), "=&r" (tmp)
|
|
|
|
: "r" (x), "r" (ptr)
|
|
|
|
: "memory", "cc");
|
|
|
|
break;
|
|
|
|
#elif defined(swp_is_buggy)
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
#error SMP is not supported on this platform
|
|
|
|
#endif
|
|
|
|
case 1:
|
2006-09-21 10:35:20 +08:00
|
|
|
raw_local_irq_save(flags);
|
2005-07-27 02:39:31 +08:00
|
|
|
ret = *(volatile unsigned char *)ptr;
|
|
|
|
*(volatile unsigned char *)ptr = x;
|
2006-09-21 10:35:20 +08:00
|
|
|
raw_local_irq_restore(flags);
|
2005-07-27 02:39:31 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
2006-09-21 10:35:20 +08:00
|
|
|
raw_local_irq_save(flags);
|
2005-07-27 02:39:31 +08:00
|
|
|
ret = *(volatile unsigned long *)ptr;
|
|
|
|
*(volatile unsigned long *)ptr = x;
|
2006-09-21 10:35:20 +08:00
|
|
|
raw_local_irq_restore(flags);
|
2005-07-27 02:39:31 +08:00
|
|
|
break;
|
2005-04-17 06:20:36 +08:00
|
|
|
#else
|
2005-07-27 02:39:31 +08:00
|
|
|
case 1:
|
|
|
|
asm volatile("@ __xchg1\n"
|
|
|
|
" swpb %0, %1, [%2]"
|
|
|
|
: "=&r" (ret)
|
|
|
|
: "r" (x), "r" (ptr)
|
|
|
|
: "memory", "cc");
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
asm volatile("@ __xchg4\n"
|
|
|
|
" swp %0, %1, [%2]"
|
|
|
|
: "=&r" (ret)
|
|
|
|
: "r" (x), "r" (ptr)
|
|
|
|
: "memory", "cc");
|
|
|
|
break;
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
2005-07-27 02:39:31 +08:00
|
|
|
default:
|
|
|
|
__bad_xchg(ptr, size), ret = 0;
|
|
|
|
break;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2009-05-26 03:58:00 +08:00
|
|
|
smp_mb();
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-03-16 07:17:26 +08:00
|
|
|
extern void disable_hlt(void);
|
|
|
|
extern void enable_hlt(void);
|
|
|
|
|
2010-10-02 05:13:47 +08:00
|
|
|
void cpu_idle_wait(void);
|
|
|
|
|
2008-02-07 16:16:11 +08:00
|
|
|
#include <asm-generic/cmpxchg-local.h>
|
|
|
|
|
2009-05-29 04:07:39 +08:00
|
|
|
#if __LINUX_ARM_ARCH__ < 6
|
2011-01-17 23:42:42 +08:00
|
|
|
/* min ARCH < ARMv6 */
|
2009-05-29 04:07:39 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
#error "SMP is not supported on this platform"
|
|
|
|
#endif
|
|
|
|
|
2008-02-07 16:16:11 +08:00
|
|
|
/*
|
|
|
|
* cmpxchg_local and cmpxchg64_local are atomic wrt current CPU. Always make
|
|
|
|
* them available.
|
|
|
|
*/
|
|
|
|
#define cmpxchg_local(ptr, o, n) \
|
|
|
|
((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\
|
|
|
|
(unsigned long)(n), sizeof(*(ptr))))
|
|
|
|
#define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
|
|
|
|
|
|
|
|
#ifndef CONFIG_SMP
|
|
|
|
#include <asm-generic/cmpxchg.h>
|
|
|
|
#endif
|
|
|
|
|
2011-01-17 23:42:42 +08:00
|
|
|
#else /* min ARCH >= ARMv6 */
|
2009-05-29 04:07:39 +08:00
|
|
|
|
|
|
|
extern void __bad_cmpxchg(volatile void *ptr, int size);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* cmpxchg only support 32-bits operands on ARMv6.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
|
|
|
|
unsigned long new, int size)
|
|
|
|
{
|
|
|
|
unsigned long oldval, res;
|
|
|
|
|
|
|
|
switch (size) {
|
2011-01-17 23:42:42 +08:00
|
|
|
#ifndef CONFIG_CPU_V6 /* min ARCH >= ARMv6K */
|
2009-05-29 04:07:39 +08:00
|
|
|
case 1:
|
|
|
|
do {
|
|
|
|
asm volatile("@ __cmpxchg1\n"
|
|
|
|
" ldrexb %1, [%2]\n"
|
|
|
|
" mov %0, #0\n"
|
|
|
|
" teq %1, %3\n"
|
|
|
|
" strexbeq %0, %4, [%2]\n"
|
|
|
|
: "=&r" (res), "=&r" (oldval)
|
|
|
|
: "r" (ptr), "Ir" (old), "r" (new)
|
|
|
|
: "memory", "cc");
|
|
|
|
} while (res);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
do {
|
|
|
|
asm volatile("@ __cmpxchg1\n"
|
|
|
|
" ldrexh %1, [%2]\n"
|
|
|
|
" mov %0, #0\n"
|
|
|
|
" teq %1, %3\n"
|
|
|
|
" strexheq %0, %4, [%2]\n"
|
|
|
|
: "=&r" (res), "=&r" (oldval)
|
|
|
|
: "r" (ptr), "Ir" (old), "r" (new)
|
|
|
|
: "memory", "cc");
|
|
|
|
} while (res);
|
|
|
|
break;
|
2011-01-17 23:42:42 +08:00
|
|
|
#endif
|
2009-05-29 04:07:39 +08:00
|
|
|
case 4:
|
|
|
|
do {
|
|
|
|
asm volatile("@ __cmpxchg4\n"
|
|
|
|
" ldrex %1, [%2]\n"
|
|
|
|
" mov %0, #0\n"
|
|
|
|
" teq %1, %3\n"
|
|
|
|
" strexeq %0, %4, [%2]\n"
|
|
|
|
: "=&r" (res), "=&r" (oldval)
|
|
|
|
: "r" (ptr), "Ir" (old), "r" (new)
|
|
|
|
: "memory", "cc");
|
|
|
|
} while (res);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
__bad_cmpxchg(ptr, size);
|
|
|
|
oldval = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return oldval;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned long __cmpxchg_mb(volatile void *ptr, unsigned long old,
|
|
|
|
unsigned long new, int size)
|
|
|
|
{
|
|
|
|
unsigned long ret;
|
|
|
|
|
|
|
|
smp_mb();
|
|
|
|
ret = __cmpxchg(ptr, old, new, size);
|
|
|
|
smp_mb();
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define cmpxchg(ptr,o,n) \
|
|
|
|
((__typeof__(*(ptr)))__cmpxchg_mb((ptr), \
|
|
|
|
(unsigned long)(o), \
|
|
|
|
(unsigned long)(n), \
|
|
|
|
sizeof(*(ptr))))
|
|
|
|
|
|
|
|
static inline unsigned long __cmpxchg_local(volatile void *ptr,
|
|
|
|
unsigned long old,
|
|
|
|
unsigned long new, int size)
|
|
|
|
{
|
|
|
|
unsigned long ret;
|
|
|
|
|
|
|
|
switch (size) {
|
2011-01-17 23:42:42 +08:00
|
|
|
#ifdef CONFIG_CPU_V6 /* min ARCH == ARMv6 */
|
2009-05-29 04:07:39 +08:00
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
ret = __cmpxchg_local_generic(ptr, old, new, size);
|
|
|
|
break;
|
2011-01-17 23:42:42 +08:00
|
|
|
#endif
|
2009-05-29 04:07:39 +08:00
|
|
|
default:
|
|
|
|
ret = __cmpxchg(ptr, old, new, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define cmpxchg_local(ptr,o,n) \
|
|
|
|
((__typeof__(*(ptr)))__cmpxchg_local((ptr), \
|
|
|
|
(unsigned long)(o), \
|
|
|
|
(unsigned long)(n), \
|
|
|
|
sizeof(*(ptr))))
|
|
|
|
|
2011-01-17 23:42:42 +08:00
|
|
|
#ifndef CONFIG_CPU_V6 /* min ARCH >= ARMv6K */
|
2009-05-29 04:07:39 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Note : ARMv7-M (currently unsupported by Linux) does not support
|
|
|
|
* ldrexd/strexd. If ARMv7-M is ever supported by the Linux kernel, it should
|
|
|
|
* not be allowed to use __cmpxchg64.
|
|
|
|
*/
|
|
|
|
static inline unsigned long long __cmpxchg64(volatile void *ptr,
|
|
|
|
unsigned long long old,
|
|
|
|
unsigned long long new)
|
|
|
|
{
|
|
|
|
register unsigned long long oldval asm("r0");
|
|
|
|
register unsigned long long __old asm("r2") = old;
|
|
|
|
register unsigned long long __new asm("r4") = new;
|
|
|
|
unsigned long res;
|
|
|
|
|
|
|
|
do {
|
|
|
|
asm volatile(
|
|
|
|
" @ __cmpxchg8\n"
|
|
|
|
" ldrexd %1, %H1, [%2]\n"
|
|
|
|
" mov %0, #0\n"
|
|
|
|
" teq %1, %3\n"
|
|
|
|
" teqeq %H1, %H3\n"
|
|
|
|
" strexdeq %0, %4, %H4, [%2]\n"
|
|
|
|
: "=&r" (res), "=&r" (oldval)
|
|
|
|
: "r" (ptr), "Ir" (__old), "r" (__new)
|
|
|
|
: "memory", "cc");
|
|
|
|
} while (res);
|
|
|
|
|
|
|
|
return oldval;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned long long __cmpxchg64_mb(volatile void *ptr,
|
|
|
|
unsigned long long old,
|
|
|
|
unsigned long long new)
|
|
|
|
{
|
|
|
|
unsigned long long ret;
|
|
|
|
|
|
|
|
smp_mb();
|
|
|
|
ret = __cmpxchg64(ptr, old, new);
|
|
|
|
smp_mb();
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define cmpxchg64(ptr,o,n) \
|
|
|
|
((__typeof__(*(ptr)))__cmpxchg64_mb((ptr), \
|
|
|
|
(unsigned long long)(o), \
|
|
|
|
(unsigned long long)(n)))
|
|
|
|
|
|
|
|
#define cmpxchg64_local(ptr,o,n) \
|
|
|
|
((__typeof__(*(ptr)))__cmpxchg64((ptr), \
|
|
|
|
(unsigned long long)(o), \
|
|
|
|
(unsigned long long)(n)))
|
|
|
|
|
2011-01-17 23:42:42 +08:00
|
|
|
#else /* min ARCH = ARMv6 */
|
2009-05-29 04:07:39 +08:00
|
|
|
|
|
|
|
#define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
|
|
|
|
|
2011-01-17 23:42:42 +08:00
|
|
|
#endif
|
2009-05-29 04:07:39 +08:00
|
|
|
|
|
|
|
#endif /* __LINUX_ARM_ARCH__ >= 6 */
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif /* __ASSEMBLY__ */
|
|
|
|
|
|
|
|
#define arch_align_stack(x) (x)
|
|
|
|
|
|
|
|
#endif /* __KERNEL__ */
|
|
|
|
|
|
|
|
#endif
|