2 * linux/include/asm-arm/proc-armv/system.h
4 * Copyright (C) 1996 Russell King
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 #ifndef __ASM_PROC_SYSTEM_H
11 #define __ASM_PROC_SYSTEM_H
14 * Save the current interrupt enable state & disable IRQs
16 #define local_irq_save(x) \
19 __asm__ __volatile__( \
20 "mrs %0, cpsr @ local_irq_save\n" \
21 " orr %1, %0, #128\n" \
23 : "=r" (x), "=r" (temp) \
31 #define local_irq_enable() \
34 __asm__ __volatile__( \
35 "mrs %0, cpsr @ local_irq_enable\n" \
36 " bic %0, %0, #128\n" \
46 #define local_irq_disable() \
49 __asm__ __volatile__( \
50 "mrs %0, cpsr @ local_irq_disable\n" \
51 " orr %0, %0, #128\n" \
64 __asm__ __volatile__( \
65 "mrs %0, cpsr @ stf\n" \
66 " bic %0, %0, #64\n" \
79 __asm__ __volatile__( \
80 "mrs %0, cpsr @ clf\n" \
81 " orr %0, %0, #64\n" \
89 * Save the current interrupt enable state.
91 #define local_save_flags(x) \
93 __asm__ __volatile__( \
94 "mrs %0, cpsr @ local_save_flags\n" \
101 * restore saved IRQ & FIQ state
103 #define local_irq_restore(x) \
104 __asm__ __volatile__( \
105 "msr cpsr_c, %0 @ local_irq_restore\n" \
110 #if defined(CONFIG_CPU_SA1100) || defined(CONFIG_CPU_SA110)
112 * On the StrongARM, "swp" is terminally broken since it bypasses the
113 * cache totally. This means that the cache becomes inconsistent, and,
114 * since we use normal loads/stores as well, this is really bad.
115 * Typically, this causes oopsen in filp_close, but could have other,
116 * more disasterous effects. There are two work-arounds:
117 * 1. Disable interrupts and emulate the atomic swap
118 * 2. Clean the cache, perform atomic swap, flush the cache
120 * We choose (1) since its the "easiest" to achieve here and is not
121 * dependent on the processor type.
126 static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size)
128 extern void __bad_xchg(volatile void *, int);
137 local_irq_save(flags);
138 ret = *(volatile unsigned char *)ptr;
139 *(volatile unsigned char *)ptr = x;
140 local_irq_restore(flags);
144 local_irq_save(flags);
145 ret = *(volatile unsigned long *)ptr;
146 *(volatile unsigned long *)ptr = x;
147 local_irq_restore(flags);
150 case 1: __asm__ __volatile__ ("swpb %0, %1, [%2]"
155 case 4: __asm__ __volatile__ ("swp %0, %1, [%2]"
161 default: __bad_xchg(ptr, size), ret = 0;