Replace the asm implementations of HalpAcquireSystemHardwareSpinLock and HalpReleaseCmosSpinLock with C implementations. The old ones didn't work on SMP, as they were only compiled once as UP.

svn path=/branches/ros-amd64-bringup/; revision=44840
This commit is contained in:
Timo Kreuzer 2009-12-31 23:45:36 +00:00
parent a4123875f0
commit a1bc42e31a
3 changed files with 43 additions and 86 deletions

View file

@ -14,9 +14,6 @@
.data
_UnhandledMsg:
.asciz "\n\x7\x7!!! Unhandled or Unexpected Code at line: %lx!!!\n"
.global _MsgUnimplemented
_MsgUnimplemented:
.asciz "WARNING: %s at %s:%d is UNIMPLEMENTED!\n"
@ -27,18 +24,6 @@ _MsgUnimplemented:
.text
.code64
.global _HalpReleaseCmosSpinLock
.func HalpReleaseCmosSpinLock
_HalpReleaseCmosSpinLock:
.endfunc
.global _HalpAcquireSystemHardwareSpinLock
.func HalpAcquireSystemHardwareSpinLock
_HalpAcquireSystemHardwareSpinLock:
.endfunc
.global _HalpCalibrateStallExecution@0
.func HalpCalibrateStallExecution@0
_HalpCalibrateStallExecution@0:

View file

@ -5,6 +5,7 @@
* PURPOSE: CMOS Access Routines (Real Time Clock and LastKnownGood)
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
* Eric Kohl (ekohl@abo.rhein-zeitung.de)
* Timo Kreuzer (timo.kreuzer@reactos.org)
*/
/* INCLUDES ******************************************************************/
@ -17,9 +18,51 @@
KSPIN_LOCK HalpSystemHardwareLock;
UCHAR HalpCmosCenturyOffset;
ULONG HalpSystemHardwareFlags;
/* PRIVATE FUNCTIONS *********************************************************/
VOID
NTAPI
HalpAcquireSystemHardwareSpinLock(VOID)
{
ULONG Flags;
/* Get flags and disable interrupts */
Flags = __readeflags();
_disable();
/* Try to acquire the lock */
while (InterlockedBitTestAndSet((PLONG)&HalpSystemHardwareLock, 0))
{
/* Lock is held, short wait and try again */
YieldProcessor();
}
/* We have the lock, save the flags now */
HalpSystemHardwareFlags = Flags;
}
VOID
NTAPI
HalpReleaseCmosSpinLock(VOID)
{
ULONG Flags;
/* Get the flags */
Flags = HalpSystemHardwareFlags;
/* Release lock and check if we owned it */
if (!InterlockedBitTestAndReset((PLONG)&HalpSystemHardwareLock, 0))
{
/* The spin lock was not owned! */
KeBugCheckEx(SPIN_LOCK_NOT_OWNED, 0, 0, 0, 0);
}
/* Restore the flags */
__writeeflags(Flags);
}
FORCEINLINE
UCHAR
HalpReadCmos(IN UCHAR Reg)

View file

@ -17,83 +17,12 @@ _HalpLastPerfCounterLow: .long 0
_HalpLastPerfCounterHigh: .long 0
_HalpPerfCounterLow: .long 0
_HalpPerfCounterHigh: .long 0
_HalpSystemHardwareFlags: .long 0
_UnhandledMsg:
.asciz "\n\x7\x7!!! Unhandled or Unexpected Code at line: %lx!!!\n"
/* FUNCTIONS *****************************************************************/
.global _HalpReleaseCmosSpinLock@0
.func HalpReleaseCmosSpinLock@0
_HalpReleaseCmosSpinLock@0:
#ifdef CONFIG_SMP
/* Save clobbered register */
push eax
/* Push saved EFLAGS */
push _HalpSystemHardwareFlags
/* Release the lock */
lea eax, _HalpSystemHardwareLock
RELEASE_SPINLOCK(eax)
/* Restore EFLAGS */
popf
/* Return */
pop eax
ret
#else
/* Restore EFLAGS and return */
push _HalpSystemHardwareFlags
popf
ret
#endif
.endfunc
.global _HalpAcquireSystemHardwareSpinLock@0
.func HalpAcquireSystemHardwareSpinLock@0
_HalpAcquireSystemHardwareSpinLock@0:
#ifdef CONFIG_SMP
/* Save clobbered register */
push eax
HardwareLock:
/* Save EFLAGS and disable interrupts */
pushf
cli
/* This is the CMOS lock, acquire it */
lea eax, _HalpSystemHardwareLock
ACQUIRE_SPINLOCK(eax, CmosSpin)
/* We have it, return the flags */
pop _HalpSystemHardwareFlags
pop eax
ret
CmosSpin:
/* Restore EFLAGS */
pushf _HalpSystemHardwareLock
popf
/* Spin */
SPIN_ON_LOCK(eax, HardwareLock)
#else
/* Save EFLAGS, disable interrupts and return */
pushf
cli
pop _HalpSystemHardwareFlags
ret
#endif
.endfunc
.global _HalpCalibrateStallExecution@0
.func HalpCalibrateStallExecution@0
_HalpCalibrateStallExecution@0: