diff -r 000000000000 -r bde4ae8d615e os/kernelhwsrv/kernel/eka/nkernsmp/x86/ncirq.cia --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/os/kernelhwsrv/kernel/eka/nkernsmp/x86/ncirq.cia Fri Jun 15 03:10:57 2012 +0200 @@ -0,0 +1,214 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// e32\nkernsmp\x86\ncirq.cia +// +// + +/** + @file + @internalTechnology +*/ + +#include "nk_priv.h" +#include "nk_plat.h" +#include +#include + +#define OFFSET_NIrqHandler_iHState 8 + +__ASSERT_COMPILE(_FOFF(NIrqHandler, iHState) == OFFSET_NIrqHandler_iHState); + +// +// Atomically increment run count provided ECount set or count <2. +// If originally zero, atomically set CPU field +// Wait for EWait to be clear +// Return state of iIState immediately before increment +// +__NAKED__ TUint32 NIrq::EnterIsr() + { + THISCALL_PROLOG0() + asm("push ebx "); + asm("xor ebx, ebx "); + asm("str bx "); + asm("sub bl, 0x28 "); + asm("shr bl, 3 "); // BL = CPU number + asm("mov eax, [ecx+%0]" : : "i" _FOFF(NIrq,iIState)); + asm("enterisr_loop: "); + asm("mov edx, eax "); + asm("cmp edx, 0x10000 "); // compare run count to 1 + asm("jae short enterisr_not0 "); // skip if >=1 + asm("mov dh, bl "); // else update CPU + asm("enterisr_not0: "); + asm("add edx, 0x10000 "); // increment run count + asm("cmp edx, 0x20000 "); // compare to 2 + asm("jb short enterisr_lt2 "); + asm("test dl, 6 "); // ECount|ERaw + asm("jz short enterisr_wait "); // if !ECount && !ERaw limit count to 2 + asm("enterisr_lt2: "); + asm("lock cmpxchg [ecx+%0], edx" : : "i" _FOFF(NIrq,iIState)); + asm("jne short enterisr_loop "); + + asm("enterisr_wait: "); + asm("mov edx, 1 "); // EWait + asm("enterisr_loop1: "); + asm("test edx, [ecx+%0]" : : "i" _FOFF(NIrq,iIState)); + asm("jnz short enterisr_loop2 "); // loop while EWait set + asm("pop ebx "); + asm("lock add dword ptr [esp], 0 "); + THISCALL_EPILOG0() + + asm("enterisr_loop2: "); + X86_PAUSE + asm("jmp short enterisr_loop "); + } + +// +// Atomically decrement run count +// Return TRUE if run count nonzero after decrement +// +__NAKED__ TBool NIrq::IsrDone() + { + THISCALL_PROLOG0() + asm("mov eax, 0xffff0000 "); // -1<