sl@0: // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test\nkernsa\testipi.cpp sl@0: // sl@0: // sl@0: sl@0: #include sl@0: sl@0: #ifdef __SMP__ sl@0: sl@0: class TTestIPI : public TGenericIPI sl@0: { sl@0: public: sl@0: TTestIPI(); sl@0: static TTestIPI* New(); sl@0: static void Isr(TGenericIPI*); sl@0: void Inc(TInt aCpu, TInt aInc=1) {iExpected[aCpu] += aInc;} sl@0: void IncM(TUint32 aMask); sl@0: void Check(); sl@0: public: sl@0: TInt iCount[KMaxCpus]; sl@0: TInt iExpected[KMaxCpus]; sl@0: }; sl@0: sl@0: TTestIPI::TTestIPI() sl@0: { sl@0: memclr(iCount, sizeof(iCount)); sl@0: memclr(iExpected, sizeof(iExpected)); sl@0: } sl@0: sl@0: TTestIPI* TTestIPI::New() sl@0: { sl@0: TTestIPI* p = new TTestIPI; sl@0: TEST_OOM(p); sl@0: return p; sl@0: } sl@0: sl@0: void TTestIPI::Isr(TGenericIPI* a) sl@0: { sl@0: TTestIPI& ipi = *(TTestIPI*)a; sl@0: TInt cpu = NKern::CurrentCpu(); sl@0: ++ipi.iCount[cpu]; sl@0: } sl@0: sl@0: void TTestIPI::IncM(TUint32 aMask) sl@0: { sl@0: TInt i; sl@0: for(i=0; i= TTestIPI2::EMaxIPI*KMaxCpus); sl@0: sl@0: TTestIPI2::TTestIPI2(TInt aId) sl@0: : iId(aId) sl@0: { sl@0: } sl@0: sl@0: TTestIPI2* TTestIPI2::New(TInt aId) sl@0: { sl@0: TTestIPI2* p = new TTestIPI2(aId); sl@0: TEST_OOM(p); sl@0: return p; sl@0: } sl@0: sl@0: void TTestIPI2::Isr(TGenericIPI* a) sl@0: { sl@0: TTestIPI2& ipi = *(TTestIPI2*)a; sl@0: TUint32 cpu = NKern::CurrentCpu(); sl@0: TUint32 x = (cpu<<16) | ipi.iId; sl@0: TInt pos = __e32_atomic_tas_ord32(&NextPos, EBufSize, 0, 1); sl@0: if (pos < EBufSize) sl@0: Buffer[pos] = x; sl@0: while (PauseHere == x) sl@0: {} sl@0: } sl@0: sl@0: void TTestIPI2::Thread(TAny*) sl@0: { sl@0: TTestIPI2* ipi[EMaxIPI]; sl@0: TUint32 all_cpus = ~(0xffffffffu << NKern::NumberOfCpus()); sl@0: TInt this_cpu = NKern::CurrentCpu(); sl@0: TInt pause_cpu = this_cpu + 1; sl@0: if (pause_cpu >= NKern::NumberOfCpus()) sl@0: pause_cpu = 0; sl@0: if (pause_cpu == this_cpu) sl@0: pause_cpu = -1; sl@0: TUint32 this_cpu_mask = 1u<=0) ? (1u<= 0) sl@0: PauseHere = (pause_cpu<<16) | (EMaxIPI/2); sl@0: sl@0: TEST_PRINT3("this_cpu=%d pause_cpu=%d PauseHere=%x", this_cpu, pause_cpu, PauseHere); sl@0: sl@0: TInt irq = NKern::DisableAllInterrupts(); sl@0: for (i=0; iQueueAll(&Isr); sl@0: sl@0: TInt expected1 = num_other_cpus*EMaxIPI + EMaxIPI/2; sl@0: while (NextPos != expected1) sl@0: {} sl@0: sl@0: PauseHere = 0; sl@0: TInt expected2 = num_other_cpus*EMaxIPI + EMaxIPI; sl@0: while (NextPos != expected2) sl@0: {} sl@0: NKern::RestoreInterrupts(irq); sl@0: ipi[EMaxIPI-1]->WaitCompletion(); sl@0: sl@0: for(i=0; i