4 * Copyright (c) 2005-2007 Analog Devices Inc.
6 * See file CREDITS for list of people who contributed to this
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
25 #ifndef _BLACKFIN_SYSTEM_H
26 #define _BLACKFIN_SYSTEM_H
29 * Interrupt configuring macros.
34 #define local_irq_enable() \
35 __asm__ __volatile__ ( \
41 #define local_irq_disable() \
44 __asm__ __volatile__ ( \
46 : "=d" (__tmp_dummy) \
50 # define local_irq_save(x) \
51 __asm__ __volatile__ ( \
56 #define local_save_flags(x) \
57 __asm__ __volatile__ ( \
63 #define irqs_enabled_from_flags(x) ((x) != 0x1f)
65 #define local_irq_restore(x) \
67 if (irqs_enabled_from_flags(x)) \
72 * Force strict CPU ordering.
74 #define nop() asm volatile ("nop;\n\t"::)
75 #define mb() asm volatile ("" : : :"memory")
76 #define rmb() asm volatile ("" : : :"memory")
77 #define wmb() asm volatile ("" : : :"memory")
78 #define set_rmb(var, value) do { xchg(&var, value); } while (0)
79 #define set_mb(var, value) set_rmb(var, value)
80 #define set_wmb(var, value) do { var = value; wmb(); } while (0)
82 #define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
87 #define __xg(x) ((volatile struct __xchg_dummy *)(x))
89 static inline unsigned long __xchg(unsigned long x, volatile void *ptr,
92 unsigned long tmp = 0;
93 unsigned long flags = 0;
95 local_irq_save(flags);
102 : "=&d" (tmp) : "d" (x), "m" (*__xg(ptr)) : "memory");
108 : "=&d" (tmp) : "d" (x), "m" (*__xg(ptr)) : "memory");
114 : "=&d" (tmp) : "d" (x), "m" (*__xg(ptr)) : "memory");
117 local_irq_restore(flags);
121 #endif /* _BLACKFIN_SYSTEM_H */