3 * Copyright 2007 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #ifndef INCLUDED_GCELL_MEMORY_BARRIER_H
23 #define INCLUDED_GCELL_MEMORY_BARRIER_H
26 * powerpc memory barriers
28 * The sync instruction guarantees that all memory accesses initiated
29 * by this processor have been performed (with respect to all other
30 * mechanisms that access memory). The eieio instruction is a barrier
31 * providing an ordering (separately) for (a) cacheable stores and (b)
32 * loads and stores to non-cacheable memory (e.g. I/O devices).
34 * smp_mb() prevents loads and stores being reordered across this point.
35 * smp_rmb() prevents loads being reordered across this point.
36 * smp_wmb() prevents stores being reordered across this point.
38 * We have to use the sync instructions for smp_mb(), since lwsync
39 * doesn't order loads with respect to previous stores. Lwsync is
40 * fine for smp_rmb(), though. For smp_wmb(), we use eieio since it
41 * is only used to order updates to system memory.
43 * For details, see "PowerPC Virtual Environment Architecture, Book
44 * II". Especially Chapter 1, "Storage Model" and Chapter 3, "Storage
45 * Control Instructions." (site:ibm.com)
48 static inline void smp_mb(void)
50 __asm__ volatile ("sync" : : : "memory");
53 static inline void smp_rmb(void)
55 __asm__ volatile ("lwsync" : : : "memory");
58 static inline void smp_wmb(void)
60 __asm__ volatile ("eieio" : : : "memory");
64 #endif /* INCLUDED_GCELL_MEMORY_BARRIER_H */