Update contrib.
1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\realtime\t_latncy.cpp
21 LOCAL_D RTest test(_L("Latency"));
22 LOCAL_D CConsoleBase* console=NULL;
32 struct SMaxLatencyValues
35 TUint iMaxIntLatencyRetAddr;
36 TInt iMaxThreadLatency;
37 TUint iMaxThreadLatencyRetAddr;
40 extern void GetLatencyValues(TInt, TInt&, SLatencyValues*);
42 inline TInt* NullTIntPtr() // to allow generation of a NULL reference without the compiler complaining
45 void GetMaxLatencyValues(SMaxLatencyValues& a)
47 GetLatencyValues(2,*NullTIntPtr(),(SLatencyValues*)&a);
50 LOCAL_C void DumpValues(TInt aCount, SLatencyValues* aValues)
53 for (i=0; i<aCount; i++)
55 SLatencyValues v=aValues[i];
57 TInt iticks=v.iLatencies>>16;
58 TInt tticks=v.iLatencies & 0xffff;
59 TInt ius=(iticks*125+124)>>6;
60 TInt tus=(tticks*125+124)>>6;
61 // TInt oldtid=v.iThreadIds & 0xffff;
62 // TInt newtid=v.iThreadIds >> 16;
64 RDebug::Print(_L("%08x %4d %4d %08x %08x"),addr,ius,tus,v.iThreadIds,swi);
68 LOCAL_C void DisplayMaxLatencyValues()
71 GetMaxLatencyValues(v);
72 TInt ius=(v.iMaxIntLatency*125+124)>>6;
73 TInt tus=(v.iMaxThreadLatency*125+124)>>6;
74 console->Printf(_L("Interrupt: %4dus return address %08x\n"),ius,v.iMaxIntLatencyRetAddr);
75 console->Printf(_L("Thread: %4dus return address %08x\n"),tus,v.iMaxThreadLatencyRetAddr);
78 GLDEF_C TInt E32Main()
81 SLatencyValues* pV=new SLatencyValues[28672];
84 console=test.Console();
86 User::Panic(_L("OOM"),0);
91 TKeyCode k=test.Getch();
95 console->Printf(_L("Getting Latency Values\n"));
96 GetLatencyValues(0,c,pV);
100 console->Printf(_L("Clearing Latency Values\n"));
101 GetLatencyValues(1,c,pV);
104 DisplayMaxLatencyValues();