|
||||
Warning, cross-references for /kernel/include/smp/atomic.h need to be fixed.
0001 /* The Quest Operating System 0002 * Copyright (C) 2005-2010 Richard West, Boston University 0003 * 0004 * This program is free software: you can redistribute it and/or modify 0005 * it under the terms of the GNU General Public License as published by 0006 * the Free Software Foundation, either version 3 of the License, or 0007 * (at your option) any later version. 0008 * 0009 * This program is distributed in the hope that it will be useful, 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0012 * GNU General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU General Public License 0015 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0016 */ 0017 0018 #ifndef _ATOMIC_H_ 0019 #define _ATOMIC_H_ 0020 0021 #include "types.h" 0022 0023 /* Intel Manual 3A 8.10.6.7 recommends no more than one lock or 0024 * semaphore be present within each 128-byte aligned block of memory, 0025 * to reduce bus traffic. */ 0026 #define LOCK_ALIGNMENT_LOG2 7 0027 #define LOCK_ALIGNMENT (1<<LOCK_ALIGNMENT_LOG2) 0028 0029 static inline uint32 0030 atomic_load_dword (uint32 * addr) 0031 { 0032 return *((volatile uint32 *) addr); 0033 } 0034 0035 static inline void 0036 atomic_store_dword (uint32 * addr, uint32 x) 0037 { 0038 *((volatile uint32 *) addr) = x; 0039 } 0040 0041 static inline uint32 0042 atomic_xchg_dword (uint32 * addr, uint32 x) 0043 { 0044 asm volatile ("xchgl %1,(%0)":"=r" (addr), "=ir" (x):"0" (addr), "1" (x)); 0045 return x; 0046 } 0047 0048 #endif 0049 0050 /* 0051 * Local Variables: 0052 * indent-tabs-mode: nil 0053 * mode: C 0054 * c-file-style: "gnu" 0055 * c-basic-offset: 2 0056 * End: 0057 */ 0058 0059 /* vi: set et sw=2 sts=2: */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 1.2.0 LXR engine. |