2 * arch_x86.h: Definitions for the x86 architecture, derived from Linux.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; but only version 2 of the License given
7 * that this comes from the Linux kernel.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 * Copyright (c) 2009 Paul E. McKenney, IBM Corporation.
21 #define CONFIG_HAVE_FENCE 1
22 #define CONFIG_HAVE_MEM_COHERENCY
24 #define mb() asm volatile("sync":::"memory")
25 #define rmb() asm volatile("sync":::"memory")
26 #define wmb() asm volatile("sync"::: "memory")
29 * Architectures without cache coherency need something like the following:
34 * #define mc() arch_cache_flush()
35 * #define rmc() arch_cache_flush_read()
36 * #define wmc() arch_cache_flush_write()
39 #define mc() barrier()
40 #define rmc() barrier()
41 #define wmc() barrier()
43 static inline void cpu_relax(void)
48 #define PPC405_ERR77(ra,rb)
49 #define LWSYNC_ON_SMP "\n\tlwsync\n"
50 #define ISYNC_ON_SMP "\n\tisync\n"
52 #ifndef _INCLUDE_API_H
54 static __inline__
void atomic_inc(int *v
)
59 "1: lwarx %0,0,%2 # atomic_inc\n\
69 #endif /* #ifndef _INCLUDE_API_H */
74 #define __xg(x) ((struct __xchg_dummy *)(x))
76 #ifndef _INCLUDE_API_H
81 * Changes the memory location '*ptr' to be val and returns
82 * the previous value stored there.
84 static __always_inline
unsigned long
85 __xchg_u32(volatile void *p
, unsigned long val
)
96 : "=&r" (prev
), "+m" (*(volatile unsigned int *)p
)
104 * This function doesn't exist, so you'll get a linker error
105 * if something tries to do an invalid xchg().
107 extern void __xchg_called_with_bad_pointer(void);
109 static __always_inline
unsigned long
110 __xchg(volatile void *ptr
, unsigned long x
, unsigned int size
)
114 return __xchg_u32(ptr
, x
);
117 return __xchg_u64(ptr
, x
);
120 __xchg_called_with_bad_pointer();
124 #define xchg(ptr,x) \
126 __typeof__(*(ptr)) _x_ = (x); \
127 (__typeof__(*(ptr))) __xchg((ptr), (unsigned long)_x_, sizeof(*(ptr))); \
130 #endif /* #ifndef _INCLUDE_API_H */
132 #define mftbl() ({unsigned long rval; \
133 asm volatile("mftbl %0" : "=r" (rval)); rval;})
134 #define mftbu() ({unsigned long rval; \
135 asm volatile("mftbu %0" : "=r" (rval)); rval;})
137 typedef unsigned long long cycles_t
;
139 static inline cycles_t
get_cycles (void)
150 return (((long long)h
) << 32) + l
;
This page took 0.065968 seconds and 4 git commands to generate.