sl@0: // Copyright (c) 1995-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\realtime\t_latncy.cpp sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: sl@0: LOCAL_D RTest test(_L("Latency")); sl@0: LOCAL_D CConsoleBase* console=NULL; sl@0: sl@0: struct SLatencyValues sl@0: { sl@0: TUint iAddress; sl@0: TUint iLatencies; sl@0: TUint iThreadIds; sl@0: TUint iSwi; sl@0: }; sl@0: sl@0: struct SMaxLatencyValues sl@0: { sl@0: TInt iMaxIntLatency; sl@0: TUint iMaxIntLatencyRetAddr; sl@0: TInt iMaxThreadLatency; sl@0: TUint iMaxThreadLatencyRetAddr; sl@0: }; sl@0: sl@0: extern void GetLatencyValues(TInt, TInt&, SLatencyValues*); sl@0: sl@0: inline TInt* NullTIntPtr() // to allow generation of a NULL reference without the compiler complaining sl@0: { return 0; } sl@0: sl@0: void GetMaxLatencyValues(SMaxLatencyValues& a) sl@0: { sl@0: GetLatencyValues(2,*NullTIntPtr(),(SLatencyValues*)&a); sl@0: } sl@0: sl@0: LOCAL_C void DumpValues(TInt aCount, SLatencyValues* aValues) sl@0: { sl@0: TInt i; sl@0: for (i=0; i>16; sl@0: TInt tticks=v.iLatencies & 0xffff; sl@0: TInt ius=(iticks*125+124)>>6; sl@0: TInt tus=(tticks*125+124)>>6; sl@0: // TInt oldtid=v.iThreadIds & 0xffff; sl@0: // TInt newtid=v.iThreadIds >> 16; sl@0: TInt swi=v.iSwi; sl@0: RDebug::Print(_L("%08x %4d %4d %08x %08x"),addr,ius,tus,v.iThreadIds,swi); sl@0: } sl@0: } sl@0: sl@0: LOCAL_C void DisplayMaxLatencyValues() sl@0: { sl@0: SMaxLatencyValues v; sl@0: GetMaxLatencyValues(v); sl@0: TInt ius=(v.iMaxIntLatency*125+124)>>6; sl@0: TInt tus=(v.iMaxThreadLatency*125+124)>>6; sl@0: console->Printf(_L("Interrupt: %4dus return address %08x\n"),ius,v.iMaxIntLatencyRetAddr); sl@0: console->Printf(_L("Thread: %4dus return address %08x\n"),tus,v.iMaxThreadLatencyRetAddr); sl@0: } sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: { sl@0: TInt c; sl@0: SLatencyValues* pV=new SLatencyValues[28672]; sl@0: sl@0: test.Title(); sl@0: console=test.Console(); sl@0: if (!pV) sl@0: User::Panic(_L("OOM"),0); sl@0: sl@0: TBool exit=EFalse; sl@0: while(!exit) sl@0: { sl@0: TKeyCode k=test.Getch(); sl@0: switch(k) sl@0: { sl@0: case '0': sl@0: console->Printf(_L("Getting Latency Values\n")); sl@0: GetLatencyValues(0,c,pV); sl@0: DumpValues(c,pV); sl@0: break; sl@0: case '1': sl@0: console->Printf(_L("Clearing Latency Values\n")); sl@0: GetLatencyValues(1,c,pV); sl@0: break; sl@0: case '2': sl@0: DisplayMaxLatencyValues(); sl@0: break; sl@0: case 'x': sl@0: case 'X': sl@0: exit=ETrue; sl@0: break; sl@0: default: sl@0: break; sl@0: } sl@0: } sl@0: sl@0: test.End(); sl@0: return 0; sl@0: } sl@0: