diff options
author | rsc <rsc> | 2007-10-01 20:43:15 +0000 |
---|---|---|
committer | rsc <rsc> | 2007-10-01 20:43:15 +0000 |
commit | 943fd378a1324ca60da72b271769fea4a86e36cb (patch) | |
tree | a2510dc65a996e7d7fc49ab1e594ccb5a45f20ba /x86.h | |
parent | 9fd9f80431ad85552c0969831a3ccc3e800ac464 (diff) | |
download | xv6-labs-943fd378a1324ca60da72b271769fea4a86e36cb.tar.gz xv6-labs-943fd378a1324ca60da72b271769fea4a86e36cb.tar.bz2 xv6-labs-943fd378a1324ca60da72b271769fea4a86e36cb.zip |
Incorporate new understanding of/with Intel SMP spec.
Dropped cmpxchg in favor of xchg, to match lecture notes.
Use xchg to release lock, for future protection and to
keep gcc from acting clever.
Diffstat (limited to 'x86.h')
-rw-r--r-- | x86.h | 29 |
1 files changed, 5 insertions, 24 deletions
@@ -96,35 +96,16 @@ write_eflags(uint eflags) asm volatile("pushl %0; popfl" : : "r" (eflags)); } -// XXX: Kill this if not used. -static inline void -cpuid(uint info, uint *eaxp, uint *ebxp, uint *ecxp, uint *edxp) -{ - uint eax, ebx, ecx, edx; - - asm volatile("cpuid" : - "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) : - "a" (info)); - if(eaxp) - *eaxp = eax; - if(ebxp) - *ebxp = ebx; - if(ecxp) - *ecxp = ecx; - if(edxp) - *edxp = edx; -} - static inline uint -cmpxchg(uint oldval, uint newval, volatile uint* lock_addr) +xchg(volatile uint *addr, uint newval) { uint result; // The + in "+m" denotes a read-modify-write operand. - asm volatile("lock; cmpxchgl %2, %0" : - "+m" (*lock_addr), "=a" (result) : - "r"(newval), "1"(oldval) : - "cc"); + asm volatile("lock; xchgl %0, %1" : + "+m" (*addr), "=a" (result) : + "1" (newval) : + "cc"); return result; } |