diff -r 000000000000 -r bde4ae8d615e os/kernelhwsrv/kerneltest/e32test/nkernsa/testipi.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/os/kernelhwsrv/kerneltest/e32test/nkernsa/testipi.cpp Fri Jun 15 03:10:57 2012 +0200 @@ -0,0 +1,241 @@ +// Copyright (c) 2006-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: +// e32test\nkernsa\testipi.cpp +// +// + +#include + +#ifdef __SMP__ + +class TTestIPI : public TGenericIPI + { +public: + TTestIPI(); + static TTestIPI* New(); + static void Isr(TGenericIPI*); + void Inc(TInt aCpu, TInt aInc=1) {iExpected[aCpu] += aInc;} + void IncM(TUint32 aMask); + void Check(); +public: + TInt iCount[KMaxCpus]; + TInt iExpected[KMaxCpus]; + }; + +TTestIPI::TTestIPI() + { + memclr(iCount, sizeof(iCount)); + memclr(iExpected, sizeof(iExpected)); + } + +TTestIPI* TTestIPI::New() + { + TTestIPI* p = new TTestIPI; + TEST_OOM(p); + return p; + } + +void TTestIPI::Isr(TGenericIPI* a) + { + TTestIPI& ipi = *(TTestIPI*)a; + TInt cpu = NKern::CurrentCpu(); + ++ipi.iCount[cpu]; + } + +void TTestIPI::IncM(TUint32 aMask) + { + TInt i; + for(i=0; i= TTestIPI2::EMaxIPI*KMaxCpus); + +TTestIPI2::TTestIPI2(TInt aId) + : iId(aId) + { + } + +TTestIPI2* TTestIPI2::New(TInt aId) + { + TTestIPI2* p = new TTestIPI2(aId); + TEST_OOM(p); + return p; + } + +void TTestIPI2::Isr(TGenericIPI* a) + { + TTestIPI2& ipi = *(TTestIPI2*)a; + TUint32 cpu = NKern::CurrentCpu(); + TUint32 x = (cpu<<16) | ipi.iId; + TInt pos = __e32_atomic_tas_ord32(&NextPos, EBufSize, 0, 1); + if (pos < EBufSize) + Buffer[pos] = x; + while (PauseHere == x) + {} + } + +void TTestIPI2::Thread(TAny*) + { + TTestIPI2* ipi[EMaxIPI]; + TUint32 all_cpus = ~(0xffffffffu << NKern::NumberOfCpus()); + TInt this_cpu = NKern::CurrentCpu(); + TInt pause_cpu = this_cpu + 1; + if (pause_cpu >= NKern::NumberOfCpus()) + pause_cpu = 0; + if (pause_cpu == this_cpu) + pause_cpu = -1; + TUint32 this_cpu_mask = 1u<=0) ? (1u<= 0) + PauseHere = (pause_cpu<<16) | (EMaxIPI/2); + + TEST_PRINT3("this_cpu=%d pause_cpu=%d PauseHere=%x", this_cpu, pause_cpu, PauseHere); + + TInt irq = NKern::DisableAllInterrupts(); + for (i=0; iQueueAll(&Isr); + + TInt expected1 = num_other_cpus*EMaxIPI + EMaxIPI/2; + while (NextPos != expected1) + {} + + PauseHere = 0; + TInt expected2 = num_other_cpus*EMaxIPI + EMaxIPI; + while (NextPos != expected2) + {} + NKern::RestoreInterrupts(irq); + ipi[EMaxIPI-1]->WaitCompletion(); + + for(i=0; i