From ab8a8ee784261615611c7d2dffa9b2723e89aaf3 Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Sun, 24 Jan 2010 23:12:30 +0000 Subject: [PATCH] [HAL] Merge HalpAcquireSystemHardwareSpinLock and HalpReleaseCmosSpinLock from Timo's AMD64 branch, and delete ASM implementations. svn path=/trunk/; revision=45233 --- reactos/hal/halx86/generic/spinlock.c | 40 +++++++++++++++ reactos/hal/halx86/generic/systimer.S | 72 +-------------------------- 2 files changed, 42 insertions(+), 70 deletions(-) diff --git a/reactos/hal/halx86/generic/spinlock.c b/reactos/hal/halx86/generic/spinlock.c index ef0672688fc..8917d385d2e 100644 --- a/reactos/hal/halx86/generic/spinlock.c +++ b/reactos/hal/halx86/generic/spinlock.c @@ -113,6 +113,46 @@ KxReleaseSpinLock(IN PKSPIN_LOCK SpinLock) #endif +/* GLOBALS ********************************************************************/ + +ULONG HalpSystemHardwareFlags; +KSPIN_LOCK HalpSystemHardwareLock; + +/* PRIVATE FUNCTIONS **********************************************************/ + +VOID +NTAPI +HalpAcquireSystemHardwareSpinLock(VOID) +{ + ULONG Flags; + + /* Get flags and disable interrupts */ + Flags = __readeflags(); + _disable(); + + /* Acquire the lock */ + KxAcquireSpinLock(&HalpSystemHardwareLock); + + /* We have the lock, save the flags now */ + HalpSystemHardwareFlags = Flags; +} + +VOID +NTAPI +HalpReleaseCmosSpinLock(VOID) +{ + ULONG Flags; + + /* Get the flags */ + Flags = HalpSystemHardwareFlags; + + /* Release the lock */ + KxReleaseSpinLock(&HalpSystemHardwareLock); + + /* Restore the flags */ + __writeeflags(Flags); +} + /* FUNCTIONS *****************************************************************/ /* diff --git a/reactos/hal/halx86/generic/systimer.S b/reactos/hal/halx86/generic/systimer.S index 62f11c1d5d1..eabbe2e0b0d 100644 --- a/reactos/hal/halx86/generic/systimer.S +++ b/reactos/hal/halx86/generic/systimer.S @@ -13,8 +13,10 @@ /* GLOBALS *******************************************************************/ +.globl _HalpPerfCounter _HalpLastPerfCounterLow: .long 0 _HalpLastPerfCounterHigh: .long 0 +_HalpPerfCounter: _HalpPerfCounterLow: .long 0 _HalpPerfCounterHigh: .long 0 _HalpSystemHardwareFlags: .long 0 @@ -24,76 +26,6 @@ _UnhandledMsg: /* 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: