os/kernelhwsrv/kerneltest/e32test/realtime/t_latncy.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/realtime/t_latncy.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,118 @@
     1.4 +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32test\realtime\t_latncy.cpp
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include <e32test.h>
    1.22 +#include <e32svr.h>
    1.23 +
    1.24 +LOCAL_D RTest test(_L("Latency"));
    1.25 +LOCAL_D CConsoleBase* console=NULL;
    1.26 +
    1.27 +struct SLatencyValues
    1.28 +	{
    1.29 +	TUint iAddress;
    1.30 +	TUint iLatencies;
    1.31 +	TUint iThreadIds;
    1.32 +	TUint iSwi;
    1.33 +	};
    1.34 +
    1.35 +struct SMaxLatencyValues
    1.36 +	{
    1.37 +	TInt iMaxIntLatency;
    1.38 +	TUint iMaxIntLatencyRetAddr;
    1.39 +	TInt iMaxThreadLatency;
    1.40 +	TUint iMaxThreadLatencyRetAddr;
    1.41 +	};
    1.42 +
    1.43 +extern void GetLatencyValues(TInt, TInt&, SLatencyValues*);
    1.44 +
    1.45 +inline TInt* NullTIntPtr()	// to allow generation of a NULL reference without the compiler complaining
    1.46 +	{ return 0; }
    1.47 +
    1.48 +void GetMaxLatencyValues(SMaxLatencyValues& a)
    1.49 +	{
    1.50 +	GetLatencyValues(2,*NullTIntPtr(),(SLatencyValues*)&a);
    1.51 +	}
    1.52 +
    1.53 +LOCAL_C void DumpValues(TInt aCount, SLatencyValues* aValues)
    1.54 +	{
    1.55 +	TInt i;
    1.56 +	for (i=0; i<aCount; i++)
    1.57 +		{
    1.58 +		SLatencyValues v=aValues[i];
    1.59 +		TInt addr=v.iAddress;
    1.60 +		TInt iticks=v.iLatencies>>16;
    1.61 +		TInt tticks=v.iLatencies & 0xffff;
    1.62 +		TInt ius=(iticks*125+124)>>6;
    1.63 +		TInt tus=(tticks*125+124)>>6;
    1.64 +//		TInt oldtid=v.iThreadIds & 0xffff;
    1.65 +//		TInt newtid=v.iThreadIds >> 16;
    1.66 +		TInt swi=v.iSwi;
    1.67 +		RDebug::Print(_L("%08x %4d %4d %08x %08x"),addr,ius,tus,v.iThreadIds,swi);
    1.68 +		}
    1.69 +	}
    1.70 +
    1.71 +LOCAL_C void DisplayMaxLatencyValues()
    1.72 +	{
    1.73 +	SMaxLatencyValues v;
    1.74 +	GetMaxLatencyValues(v);
    1.75 +	TInt ius=(v.iMaxIntLatency*125+124)>>6;
    1.76 +	TInt tus=(v.iMaxThreadLatency*125+124)>>6;
    1.77 +	console->Printf(_L("Interrupt: %4dus return address %08x\n"),ius,v.iMaxIntLatencyRetAddr);
    1.78 +	console->Printf(_L("Thread:    %4dus return address %08x\n"),tus,v.iMaxThreadLatencyRetAddr);
    1.79 +	}
    1.80 +
    1.81 +GLDEF_C TInt E32Main()
    1.82 +	{
    1.83 +	TInt c;
    1.84 +	SLatencyValues* pV=new SLatencyValues[28672];
    1.85 +
    1.86 +	test.Title();
    1.87 +	console=test.Console();
    1.88 +	if (!pV)
    1.89 +		User::Panic(_L("OOM"),0);
    1.90 +
    1.91 +	TBool exit=EFalse;
    1.92 +	while(!exit)
    1.93 +		{
    1.94 +		TKeyCode k=test.Getch();
    1.95 +		switch(k)
    1.96 +			{
    1.97 +			case '0':
    1.98 +				console->Printf(_L("Getting Latency Values\n"));
    1.99 +				GetLatencyValues(0,c,pV);
   1.100 +				DumpValues(c,pV);
   1.101 +				break;
   1.102 +			case '1':
   1.103 +				console->Printf(_L("Clearing Latency Values\n"));
   1.104 +				GetLatencyValues(1,c,pV);
   1.105 +				break;
   1.106 +			case '2':
   1.107 +				DisplayMaxLatencyValues();
   1.108 +				break;
   1.109 +			case 'x':
   1.110 +			case 'X':
   1.111 +				exit=ETrue;
   1.112 +				break;
   1.113 +			default:
   1.114 +				break;
   1.115 +			}
   1.116 +		}
   1.117 +
   1.118 +	test.End();
   1.119 +	return 0;
   1.120 +	}
   1.121 +