0
|
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".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// e32test\realtime\t_latncy.cpp
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#include <e32test.h>
|
|
19 |
#include <e32svr.h>
|
|
20 |
|
|
21 |
LOCAL_D RTest test(_L("Latency"));
|
|
22 |
LOCAL_D CConsoleBase* console=NULL;
|
|
23 |
|
|
24 |
struct SLatencyValues
|
|
25 |
{
|
|
26 |
TUint iAddress;
|
|
27 |
TUint iLatencies;
|
|
28 |
TUint iThreadIds;
|
|
29 |
TUint iSwi;
|
|
30 |
};
|
|
31 |
|
|
32 |
struct SMaxLatencyValues
|
|
33 |
{
|
|
34 |
TInt iMaxIntLatency;
|
|
35 |
TUint iMaxIntLatencyRetAddr;
|
|
36 |
TInt iMaxThreadLatency;
|
|
37 |
TUint iMaxThreadLatencyRetAddr;
|
|
38 |
};
|
|
39 |
|
|
40 |
extern void GetLatencyValues(TInt, TInt&, SLatencyValues*);
|
|
41 |
|
|
42 |
inline TInt* NullTIntPtr() // to allow generation of a NULL reference without the compiler complaining
|
|
43 |
{ return 0; }
|
|
44 |
|
|
45 |
void GetMaxLatencyValues(SMaxLatencyValues& a)
|
|
46 |
{
|
|
47 |
GetLatencyValues(2,*NullTIntPtr(),(SLatencyValues*)&a);
|
|
48 |
}
|
|
49 |
|
|
50 |
LOCAL_C void DumpValues(TInt aCount, SLatencyValues* aValues)
|
|
51 |
{
|
|
52 |
TInt i;
|
|
53 |
for (i=0; i<aCount; i++)
|
|
54 |
{
|
|
55 |
SLatencyValues v=aValues[i];
|
|
56 |
TInt addr=v.iAddress;
|
|
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;
|
|
63 |
TInt swi=v.iSwi;
|
|
64 |
RDebug::Print(_L("%08x %4d %4d %08x %08x"),addr,ius,tus,v.iThreadIds,swi);
|
|
65 |
}
|
|
66 |
}
|
|
67 |
|
|
68 |
LOCAL_C void DisplayMaxLatencyValues()
|
|
69 |
{
|
|
70 |
SMaxLatencyValues v;
|
|
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);
|
|
76 |
}
|
|
77 |
|
|
78 |
GLDEF_C TInt E32Main()
|
|
79 |
{
|
|
80 |
TInt c;
|
|
81 |
SLatencyValues* pV=new SLatencyValues[28672];
|
|
82 |
|
|
83 |
test.Title();
|
|
84 |
console=test.Console();
|
|
85 |
if (!pV)
|
|
86 |
User::Panic(_L("OOM"),0);
|
|
87 |
|
|
88 |
TBool exit=EFalse;
|
|
89 |
while(!exit)
|
|
90 |
{
|
|
91 |
TKeyCode k=test.Getch();
|
|
92 |
switch(k)
|
|
93 |
{
|
|
94 |
case '0':
|
|
95 |
console->Printf(_L("Getting Latency Values\n"));
|
|
96 |
GetLatencyValues(0,c,pV);
|
|
97 |
DumpValues(c,pV);
|
|
98 |
break;
|
|
99 |
case '1':
|
|
100 |
console->Printf(_L("Clearing Latency Values\n"));
|
|
101 |
GetLatencyValues(1,c,pV);
|
|
102 |
break;
|
|
103 |
case '2':
|
|
104 |
DisplayMaxLatencyValues();
|
|
105 |
break;
|
|
106 |
case 'x':
|
|
107 |
case 'X':
|
|
108 |
exit=ETrue;
|
|
109 |
break;
|
|
110 |
default:
|
|
111 |
break;
|
|
112 |
}
|
|
113 |
}
|
|
114 |
|
|
115 |
test.End();
|
|
116 |
return 0;
|
|
117 |
}
|
|
118 |
|