From 943fd378a1324ca60da72b271769fea4a86e36cb Mon Sep 17 00:00:00 2001 From: rsc Date: Mon, 1 Oct 2007 20:43:15 +0000 Subject: 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. --- x86.h | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) (limited to 'x86.h') diff --git a/x86.h b/x86.h index a1c66b5..1f2c881 100644 --- a/x86.h +++ b/x86.h @@ -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; } -- cgit v1.2.3