1 /******************************************************************************
2 * Copyright (c) 2004, 2008 IBM Corporation
4 * This program and the accompanying materials
5 * are made available under the terms of the BSD License
6 * which accompanies this distribution, and is available at
7 * http://www.opensource.org/licenses/bsd-license.php
10 * IBM Corporation - initial implementation
11 *****************************************************************************/
16 /* Used in boot_abort.S, will need something better for KVM */
19 /* XXX FIXME: Can be more efficient, no dcbst nor loop needed on P7 */
20 /* This macro uses r0 */
21 #define FLUSH_CACHE(r, n) add n, n, r; \
23 rlwinm r, r, 0,0,24; \
24 rlwinm n, n, 0,0,24; \
37 #define STRINGIFY(x...) #x
38 #define EXPAND(x) STRINGIFY(x)
40 static inline void flush_cache(void* r, long n)
42 asm volatile(EXPAND(FLUSH_CACHE(%0, %1))
44 :: "memory", "cc", "r0", "ctr");
47 static inline void eieio(void)
49 asm volatile ("eieio":::"memory");
52 static inline void barrier(void)
54 asm volatile("" : : : "memory");
56 #define cpu_relax() barrier()
58 static inline void sync(void)
60 asm volatile ("sync" ::: "memory");
64 #endif /* __ASSEMBLER__ */